Beispiel #1
0
    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")
Beispiel #2
0
    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
Beispiel #3
0
    def from_param(cls, instance):
        if instance is None:
            return ctypes.c_void_p()
        elif isinstance(instance, FieldConfig):
            return FieldConfig.from_param(instance)

        # The Container class which is used to support summary based
        # source in the BLOCK_OBS configuration is not yet supported
        # in Python.

        # elif isinstance(instance , ContainerConfig):
        #    return ContainerConfig.from_param( instance )
        else:
            raise ValueError("Currently ONLY field data is supported")
Beispiel #4
0
    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)
Beispiel #5
0
    def test_field_guess_filetype(self):
        with TestAreaContext("field_config") as test_context:
            fname = abspath("test.kw.grdecl")
            with open(fname, "w") as f:
                f.write("-- my comment\n")
                f.write("-- more comments\n")
                f.write("SOWCR\n")
                # The function guessing file types determines whether the file
                # is binary or 7 bit ASCII based on bit 8 heuristics. For this
                # to be "reliable" the file is required to be more than 256
                # bytes.
                for i in range(256 // 8):
                    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)
Beispiel #6
0
 def test_basics(self):
     nx = 17
     ny = 13
     nz = 11
     actnum = [1] * nx * ny * nz
     actnum[0] = 0
     grid = EclGridGenerator.create_rectangular((nx, ny, nz), (1, 1, 1), actnum)
     fc = FieldConfig("PORO", grid)
     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 = nx, ny, nz
     self.assertEqual(ex_xyz, fc_xyz)
     self.assertEqual(0, fc.get_truncation_mode())
     self.assertEqual(ex_xyz, (grid.getNX(), grid.getNY(), grid.getNZ()))
     self.assertEqual(fc.get_data_size(), grid.get_num_active())
Beispiel #7
0
 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()))
Beispiel #8
0
 def getFieldModelConfig(self):
     """ @rtype: FieldConfig """
     return FieldConfig.createCReference(self._get_ref(), parent=self)
Beispiel #9
0
 def test_create(self):
     grid = EclGridGenerator.create_rectangular((10, 10, 5), (1, 1, 1))
     field_config = FieldConfig("SWAT", grid)