예제 #1
0
파일: test_vectors.py 프로젝트: blattms/ert
    def test_activeList(self):
        active_list = IntVector.active_list("1,10,100-105")
        self.assertTrue(len(active_list) == 8)
        self.assertTrue(active_list[0] == 1)
        self.assertTrue(active_list[2] == 100)
        self.assertTrue(active_list[7] == 105)

        active_list = IntVector.active_list("1,10,100-105X")
        self.assertFalse(active_list)
예제 #2
0
    def test_activeList(self):
        active_list = IntVector.active_list("1,10,100-105")
        self.assertTrue(len(active_list) == 8)
        self.assertTrue(active_list[0] == 1)
        self.assertTrue(active_list[2] == 100)
        self.assertTrue(active_list[7] == 105)
        self.assertEqual(active_list.count(100), 1)
        active_list.append(100)
        active_list.append(100)
        self.assertEqual(active_list.count(100), 3)

        active_list = IntVector.active_list("1,10,100-105X")
        self.assertFalse(active_list)
예제 #3
0
    def test_activeList(self):
        active_list = IntVector.active_list("1,10,100-105")
        self.assertTrue(len(active_list) == 8)
        self.assertTrue(active_list[0] == 1)
        self.assertTrue(active_list[2] == 100)
        self.assertTrue(active_list[7] == 105)
        self.assertEqual( active_list.count(100) , 1)
        active_list.append(100)
        active_list.append(100)
        self.assertEqual( active_list.count(100) , 3)

        active_list = IntVector.active_list("1,10,100-105X")
        self.assertFalse(active_list)
예제 #4
0
파일: export.py 프로젝트: agchitu/ert
    def exportFIELD(self, line):
        arguments = splitArguments(line)

        if len(arguments) >= 1:
            ens_config = self.ert().ensembleConfig()
            key = arguments[0]
            if key in self.supportedFIELDKeys():
                config_node = ens_config[key]
                if len(arguments) >= 2:
                    path_fmt = arguments[1]
                else:
                    path_fmt = Export.DEFAULT_EXPORT_PATH % (key, key) + ".grdecl"

                if len(arguments) >= 3:
                    range_string = "".join(arguments[2:])
                    iens_list = IntVector.active_list(range_string)
                else:
                    ens_size = self.ert().getEnsembleSize()
                    iens_list = IntVector.createRange(0, ens_size, 1)

                fs_manager = self.ert().getEnkfFsManager()
                fs = fs_manager.getCurrentFileSystem()
                init_file = self.ert().fieldInitFile(config_node)
                if init_file:
                    print('Using init file: %s' % init_file)

                EnkfNode.exportMany(config_node, path_fmt, fs, iens_list, arg=init_file)
            else:
                self.lastCommandFailed("No such FIELD node: %s" % key)
        else:
            self.lastCommandFailed("Expected at least one argument: <keyword> received: '%s'" % line)
예제 #5
0
    def __init__(self , obs_key , data_config , scalar_value = None , obs_file = None , data_index = None):
        c_pointer = GenObservation.cNamespace().alloc( data_config , obs_key )
        super(GenObservation, self).__init__(c_pointer)

        if scalar_value is None and obs_file is None:
            raise ValueError("Exactly one the scalar_value and obs_file arguments must be present")

        if scalar_value is not None and obs_file is not None:
            raise ValueError("Exactly one the scalar_value and obs_file arguments must be present")

        if obs_file is not None:
            if not os.path.isfile( obs_file ):
                raise IOError("The file with observation data:%s does not exist" % obs_file )
            else:
                GenObservation.cNamespace().load( self , obs_file )
        else:
            obs_value , obs_std = scalar_value
            GenObservation.cNamespace().scalar_set( self , obs_value , obs_std )

        if not data_index is None:
            if os.path.isfile( data_index ):
                GenObservation.cNamespace().load_data_index( self , data_index )
            else:
                index_list = IntVector.active_list( data_index )
                GenObservation.cNamespace().add_data_index( self , index_list )
예제 #6
0
    def __init__(self , obs_key , data_config , scalar_value = None , obs_file = None , data_index = None):
        c_pointer = GenObservation.cNamespace().alloc( data_config , obs_key )
        super(GenObservation, self).__init__(c_pointer)

        if scalar_value is None and obs_file is None:
            raise ValueError("Exactly one the scalar_value and obs_file arguments must be present")

        if scalar_value is not None and obs_file is not None:
            raise ValueError("Exactly one the scalar_value and obs_file arguments must be present")

        if obs_file is not None:
            if not os.path.isfile( obs_file ):
                raise IOError("The file with observation data:%s does not exist" % obs_file )
            else:
                GenObservation.cNamespace().load( self , obs_file )
        else:
            obs_value , obs_std = scalar_value
            GenObservation.cNamespace().scalar_set( self , obs_value , obs_std )

        if not data_index is None:
            if os.path.isfile( data_index ):
                GenObservation.cNamespace().load_data_index( self , data_index )
            else:
                index_list = IntVector.active_list( data_index )
                GenObservation.cNamespace().add_data_index( self , index_list )
예제 #7
0
    def __init__(self,
                 obs_key,
                 data_config,
                 scalar_value=None,
                 obs_file=None,
                 data_index=None):
        c_ptr = self._alloc(data_config, obs_key)
        if c_ptr:
            super(GenObservation, self).__init__(c_ptr)
        else:
            raise ValueError(
                'Unable to construct GenObservation with given obs_key and data_config!'
            )

        if scalar_value is None and obs_file is None:
            raise ValueError(
                "Exactly one the scalar_value and obs_file arguments must be present"
            )

        if scalar_value is not None and obs_file is not None:
            raise ValueError(
                "Exactly one the scalar_value and obs_file arguments must be present"
            )

        if obs_file is not None:
            if not os.path.isfile(obs_file):
                raise IOError(
                    "The file with observation data:%s does not exist" %
                    obs_file)
            else:
                self._load(obs_file)
        else:
            obs_value, obs_std = scalar_value
            self._scalar_set(obs_value, obs_std)

        if not data_index is None:
            if os.path.isfile(data_index):
                self._load_data_index(data_index)
            else:
                index_list = IntVector.active_list(data_index)
                self._add_data_index(index_list)
예제 #8
0
파일: export.py 프로젝트: stefoss23/ert
    def exportFIELD(self, line):
        arguments = splitArguments(line)

        if len(arguments) >= 1:
            ens_config = self.ert().ensembleConfig()
            key = arguments[0]
            if key in self.supportedFIELDKeys():
                config_node = ens_config[key]
                if len(arguments) >= 2:
                    path_fmt = arguments[1]
                else:
                    path_fmt = Export.DEFAULT_EXPORT_PATH % (key,
                                                             key) + ".grdecl"

                if len(arguments) >= 3:
                    range_string = "".join(arguments[2:])
                    iens_list = IntVector.active_list(range_string)
                else:
                    ens_size = self.ert().getEnsembleSize()
                    iens_list = IntVector.createRange(0, ens_size, 1)

                fs_manager = self.ert().getEnkfFsManager()
                fs = fs_manager.getCurrentFileSystem()
                mc = self.ert().getModelConfig()
                init_file = config_node.getInitFile(mc.getRunpathFormat())
                if init_file:
                    print('Using init file: %s' % init_file)

                EnkfNode.exportMany(config_node,
                                    path_fmt,
                                    fs,
                                    iens_list,
                                    arg=init_file)
            else:
                self.lastCommandFailed("No such FIELD node: %s" % key)
        else:
            self.lastCommandFailed(
                "Expected at least one argument: <keyword> received: '%s'" %
                line)