Question

I'm currently working on a plug-in in which I need to get the current unit system in petrel(i.e is in field or in metric system). How to get it?

Was it helpful?

Solution

To get the invariant unit (the unit data is stored in):

var invUnit = PetrelUnitSystem.GetInvariantUnit(someTemplate);

To get the unit the system/project is currently using:

var dispUnit = PetrelUnitSystem.GetDisplayUnit(someTemplate);

A converter to convert between them.

var convInvDisp = PetrelUnitSystem.GetConverter(invUnit, dispUnit);

var fahrenheit=convInvDisp.Convert(100);

OTHER TIPS

Are you referring to the unit system for a simulation case (which will be either Field or Metric)?

I’m afraid that ‘Simulation Units’ are not exposed via the Ocean API.

You can however test whether each (exported) Simulation Case is FIELD or METRIC by examining the presence of the FIELD or METRIC keyword in the ECLIPSE deck.

The following snippet will run through the Cases and output whether they are FIELD or METRIC.

 using (ITransaction trans = DataManager.NewTransaction())
 {
     SimulationRoot SimRoot = SimulationRoot.Get(PetrelProject.PrimaryProject);

     foreach (Case Case in SimRoot.Cases)
     {
         EclipseKeywordEditor editor = SimulationSystem.CreateEclipseKeywordEditor(Case);

         trans.Lock(editor);

         foreach (EclipseKeyword keyword in editor.Sections.RunSpec.GetAll("FIELD"))
         {
             // found FIELD keyword

             PetrelLogger.InfoOutputWindow(String.Format("### Case {0} is FIELD", Case.Name));
         }

         foreach (EclipseKeyword keyword in editor.Sections.RunSpec.GetAll("METRIC"))
         {
             // found METRIC keyword

             PetrelLogger.InfoOutputWindow(String.Format("### Case {0} is METRIC", Case.Name));
         }
     }

     trans.Commit();
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top