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?

有帮助吗?

解决方案

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);

其他提示

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();
 }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top