def test_basics(self): grid = EclGrid.createRectangular((17,13,11),(1,1,1)) fc = FieldConfig('PORO',grid) print(fc) print(str(fc)) print(repr(fc)) pfx = 'FieldConfig(type' rep = repr(fc) self.assertEqual(pfx, rep[:len(pfx)]) fc_xyz = fc.get_nx(),fc.get_ny(),fc.get_nz() ex_xyz = 17,13,11 self.assertEqual(ex_xyz, fc_xyz) self.assertEqual(0, fc.get_truncation_mode()) self.assertEqual(ex_xyz, (grid.getNX(), grid.getNY(), grid.getNZ()))
def test_export_format(self): self.assertEqual(FieldConfig.exportFormat("file.grdecl"), EnkfFieldFileFormatEnum.ECL_GRDECL_FILE) self.assertEqual(FieldConfig.exportFormat("file.xyz.grdecl"), EnkfFieldFileFormatEnum.ECL_GRDECL_FILE) self.assertEqual(FieldConfig.exportFormat("file.roFF"), EnkfFieldFileFormatEnum.RMS_ROFF_FILE) self.assertEqual(FieldConfig.exportFormat("file.xyz.roFF"), EnkfFieldFileFormatEnum.RMS_ROFF_FILE) with self.assertRaises(ValueError): FieldConfig.exportFormat("file.xyz") with self.assertRaises(ValueError): FieldConfig.exportFormat("file.xyz")
def export(self , filename , file_type = None , init_file = None): output_transform = False if file_type is None: try: file_type = FieldConfig.exportFormat( filename ) except ValueError: sys.stderr.write("Sorry - could not infer output format from filename:%s\n" % filename) return False self._export(filename , None , file_type , output_transform , init_file ) return True
def export(self, filename, file_type=None, init_file=None): output_transform = False if file_type is None: try: file_type = FieldConfig.exportFormat(filename) except ValueError: sys.stderr.write( "Sorry - could not infer output format from filename:%s\n" % filename) return False self._export(filename, None, file_type, output_transform, init_file) return True
def test_field_guess_filetype(self): with TestAreaContext('field_config') as test_context: fname = abspath('test.kw.grdecl') print(fname) with open(fname, 'w') as f: f.write("-- my comment\n") f.write("-- more comments\n") f.write("SOWCR\n") for i in range(256//8): # technicalities demand file has >= 256B f.write("0 0 0 0\n") ft = FieldConfig.guessFiletype(fname) grdecl_type = EnkfFieldFileFormatEnum(5) self.assertEqual('ECL_GRDECL_FILE', grdecl_type.name) self.assertEqual(grdecl_type, ft)
def test_field_guess_filetype(self): with TestAreaContext('field_config') as test_context: fname = abspath('test.kw.grdecl') print(fname) with open(fname, 'w') as f: f.write("-- my comment\n") f.write("-- more comments\n") f.write("SOWCR\n") for i in range(256 // 8): # technicalities demand file has >= 256B f.write("0 0 0 0\n") ft = FieldConfig.guessFiletype(fname) grdecl_type = EnkfFieldFileFormatEnum(5) self.assertEqual('ECL_GRDECL_FILE', grdecl_type.name) self.assertEqual(grdecl_type, ft)
def test_basics(self): grid = EclGrid.createRectangular((17, 13, 11), (1, 1, 1)) fc = FieldConfig('PORO', grid) print(fc) print(str(fc)) print(repr(fc)) pfx = 'FieldConfig(type' rep = repr(fc) self.assertEqual(pfx, rep[:len(pfx)]) fc_xyz = fc.get_nx(), fc.get_ny(), fc.get_nz() ex_xyz = 17, 13, 11 self.assertEqual(ex_xyz, fc_xyz) self.assertEqual(0, fc.get_truncation_mode()) self.assertEqual(ex_xyz, (grid.getNX(), grid.getNY(), grid.getNZ()))
def getFieldModelConfig(self): """ @rtype: FieldConfig """ return FieldConfig.createCReference(EnkfConfigNode.cNamespace().get_ref(self), parent=self)
def getFieldModelConfig(self): """ @rtype: FieldConfig """ return FieldConfig.createCReference( EnkfConfigNode.cNamespace().get_ref(self), parent=self)
def getFieldModelConfig(self): """ @rtype: FieldConfig """ return FieldConfig.createCReference(self._get_ref(), parent=self)