示例#1
0
    def test_run_context(self):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)
            main = EnKFMain("simple_config/minimum_config")
            fs_manager = main.getEnkfFsManager()
            fs = fs_manager.getCurrentFileSystem()
            iactive = BoolVector(initial_size=10, default_value=True)
            iactive[0] = False
            iactive[1] = False
            run_context = main.getRunContextENSEMPLE_EXPERIMENT(fs, iactive)

            self.assertEqual(len(run_context), 8)

            with self.assertRaises(IndexError):
                run_context[8]

            with self.assertRaises(TypeError):
                run_context["String"]

            run_arg = run_context[0]
            self.assertTrue(isinstance(run_arg, RunArg))

            with self.assertRaises(ValueError):
                run_context.iensGet(0)

            with self.assertRaises(ValueError):
                run_context.iensGet(1)

            arg0 = run_context[0]
            arg2 = run_context.iensGet(2)
示例#2
0
 def test_repr( self ):
     with TestAreaContext("enkf_test", store_area=True) as work_area:
         work_area.copy_directory(self.case_directory)
         main = EnKFMain("simple_config/minimum_config")
         pfx = 'EnKFMain(ensemble_size'
         self.assertEqual(pfx, repr(main)[:len(pfx)])
         main.free()
示例#3
0
 def test_repr(self):
     with TestAreaContext("enkf_test", store_area=True) as work_area:
         work_area.copy_directory(self.case_directory)
         main = EnKFMain("simple_config/minimum_config")
         pfx = 'EnKFMain(ensemble_size'
         self.assertEqual(pfx, repr(main)[:len(pfx)])
         main.free()
示例#4
0
    def test_run_context(self):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)
            main = EnKFMain("simple_config/minimum_config")
            fs_manager = main.getEnkfFsManager()
            fs = fs_manager.getCurrentFileSystem( )
            iactive = BoolVector(initial_size = 10 , default_value = True)
            iactive[0] = False
            iactive[1] = False
            run_context = main.getRunContextENSEMPLE_EXPERIMENT( fs , iactive )
            
            self.assertEqual( len(run_context) , 8 )
            
            with self.assertRaises(IndexError):
                run_context[8]

            with self.assertRaises(TypeError):
                run_context["String"]

            run_arg = run_context[0]
            self.assertTrue( isinstance( run_arg , RunArg ))
            
            with self.assertRaises(ValueError):
                run_context.iensGet(0)


            with self.assertRaises(ValueError):
                run_context.iensGet(1)
                
            arg0 = run_context[0]
            arg2 = run_context.iensGet( 2 )
示例#5
0
 def test_bootstrap(self):
     with TestAreaContext("enkf_test", store_area=True) as work_area:
         work_area.copy_directory(self.case_directory)
         main = EnKFMain("simple_config/minimum_config",
                         self.site_config_file)
         self.assertTrue(main, "Load failed")
         main.free()
示例#6
0
    def test_with_enkf_fs(self):
        config_file = self.createTestPath("Statoil/config/with_data/config")

        with TestAreaContext("enkf/summary_key_set/enkf_fs", store_area=True) as context:
            context.copy_parent_content(config_file)

            fs = EnkfFs("storage/default")
            summary_key_set = fs.getSummaryKeySet()
            summary_key_set.addSummaryKey("FOPT")
            summary_key_set.addSummaryKey("WWCT")
            summary_key_set.addSummaryKey("WOPR")
            fs.umount()

            ert = EnKFMain("config", site_config=None)
            fs = ert.getEnkfFsManager().getCurrentFileSystem()
            summary_key_set = fs.getSummaryKeySet()
            self.assertTrue("FOPT" in summary_key_set)
            self.assertTrue("WWCT" in summary_key_set)
            self.assertTrue("WOPR" in summary_key_set)

            ensemble_config = ert.ensembleConfig()

            self.assertTrue("FOPT" in ensemble_config)
            self.assertTrue("WWCT" in ensemble_config)
            self.assertTrue("WOPR" in ensemble_config)
            self.assertFalse("TCPU" in ensemble_config)
示例#7
0
    def test_with_enkf_fs(self):
        config_file = self.createTestPath("Statoil/config/with_data/config")

        with TestAreaContext("enkf/summary_key_set/enkf_fs",
                             store_area=True) as context:
            context.copy_parent_content(config_file)

            fs = EnkfFs("storage/default")
            summary_key_set = fs.getSummaryKeySet()
            summary_key_set.addSummaryKey("FOPT")
            summary_key_set.addSummaryKey("WWCT")
            summary_key_set.addSummaryKey("WOPR")
            fs.umount()

            ert = EnKFMain("config")
            fs = ert.getEnkfFsManager().getCurrentFileSystem()
            summary_key_set = fs.getSummaryKeySet()
            self.assertTrue("FOPT" in summary_key_set)
            self.assertTrue("WWCT" in summary_key_set)
            self.assertTrue("WOPR" in summary_key_set)

            ensemble_config = ert.ensembleConfig()

            self.assertTrue("FOPT" in ensemble_config)
            self.assertTrue("WWCT" in ensemble_config)
            self.assertTrue("WOPR" in ensemble_config)
            self.assertFalse("TCPU" in ensemble_config)
示例#8
0
 def test_enkf_create_config_file(self):
     config_file      = "test_new_config"
     dbase_type       = "BLOCK_FS"
     num_realizations = 42
     
     with TestAreaContext("python/ens_condif/create_config" , store_area = True) as ta:
         EnKFMain.createNewConfig(config_file, "storage" , dbase_type, num_realizations)
         main = EnKFMain(config_file)
         self.assertEqual(main.getEnsembleSize(), num_realizations)
示例#9
0
    def test_enkf_state(self):
        with TestAreaContext("enkf_library_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config")
            state = main.getRealisation( 0 )
            
            with self.assertRaises(TypeError):
                state.addSubstKeyword( "GEO_ID" , 45)
            
            state.addSubstKeyword("GEO_ID" , "45")
示例#10
0
    def test_enkf_create_config_file(self):
        config_file = "test_new_config"
        dbase_type = "BLOCK_FS"
        num_realizations = 42

        with TestAreaContext("python/ens_condif/create_config",
                             store_area=True) as ta:
            EnKFMain.createNewConfig(config_file, "storage", dbase_type,
                                     num_realizations)
            main = EnKFMain(config_file)
            self.assertEqual(main.getEnsembleSize(), num_realizations)
示例#11
0
    def test_enkf_state(self):
        with TestAreaContext("enkf_library_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config", self.site_config)
            state = main.getRealisation(0)

            with self.assertRaises(TypeError):
                state.addSubstKeyword("GEO_ID", 45)

            state.addSubstKeyword("GEO_ID", "45")
示例#12
0
    def test_ecl_config_creation(self):
        with self.assertRaises(NotImplementedError):
            ecl_config = EclConfig()

        with TestAreaContext("enkf_library_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config", self.site_config)

            self.assertIsInstance(main.analysis_config(), AnalysisConfig)
            self.assertIsInstance(main.ecl_config(), EclConfig)

            with self.assertRaises(AttributeError):
                self.assertIsInstance(main.ecl_config().get_refcase(), EclSum)

            time_map = main.get_fs().get_time_map()
            self.assertIsInstance(time_map, TimeMap)

            del main
示例#13
0
    def test_observations(self):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config")

            count = 10
            summary_key = "test_key"
            observation_key = "test_obs_key"
            summary_observation_node = EnkfConfigNode.createSummaryConfigNode(
                summary_key, LoadFailTypeEnum.LOAD_FAIL_EXIT)
            observation_vector = ObsVector(
                EnkfObservationImplementationType.SUMMARY_OBS, observation_key,
                summary_observation_node, count)

            main.getObservations().addObservationVector(observation_vector)

            values = []
            for index in range(0, count):
                value = index * 10.5
                std = index / 10.0
                summary_observation_node = SummaryObservation(
                    summary_key, observation_key, value, std)
                observation_vector.installNode(index, summary_observation_node)
                self.assertEqual(observation_vector.getNode(index),
                                 summary_observation_node)
                self.assertEqual(value, summary_observation_node.getValue())
                values.append((index, value, std))

            observations = main.getObservations()
            test_vector = observations[observation_key]
            index = 0
            for node in test_vector:
                self.assertTrue(isinstance(node, SummaryObservation))
                self.assertEqual(node.getValue(), index * 10.5)
                index += 1

            self.assertEqual(observation_vector, test_vector)
            for index, value, std in values:
                self.assertTrue(test_vector.isActive(index))

                summary_observation_node = test_vector.getNode(index)
                """@type: SummaryObservation"""

                self.assertEqual(value, summary_observation_node.getValue())
                self.assertEqual(
                    std, summary_observation_node.getStandardDeviation())
                self.assertEqual(summary_key,
                                 summary_observation_node.getSummaryKey())

            main.free()
示例#14
0
    def test_ecl_config_creation(self):
        with TestAreaContext("enkf_library_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config", self.site_config)

            self.assertIsInstance(main.analysisConfig(), AnalysisConfig)
            self.assertIsInstance(main.eclConfig(), EclConfig)

            with self.assertRaises(AssertionError):  # Null pointer!
                self.assertIsInstance(main.eclConfig().getRefcase(), EclSum)

            file_system = main.getEnkfFsManager().getCurrentFileSystem()
            self.assertEqual(file_system.getCaseName(), "default")
            time_map = file_system.getTimeMap()
            self.assertIsInstance(time_map, TimeMap)

            main.free()
示例#15
0
    def test_ecl_config_creation(self):
        with TestAreaContext("enkf_library_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config", self.site_config)

            self.assertIsInstance(main.analysisConfig(), AnalysisConfig)
            self.assertIsInstance(main.eclConfig(), EclConfig)

            with self.assertRaises(ValueError): # Null pointer!
                self.assertIsInstance(main.eclConfig().getRefcase(), EclSum)

            file_system = main.getEnkfFsManager().getCurrentFileSystem()
            self.assertEqual(file_system.getCaseName(), "default")
            time_map = file_system.getTimeMap()
            self.assertIsInstance(time_map, TimeMap)

            main.free()
示例#16
0
    def test_observations(self):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config")

            count = 10
            summary_key = "test_key"
            observation_key = "test_obs_key"
            summary_observation_node = EnkfConfigNode.createSummaryConfigNode(summary_key, LoadFailTypeEnum.LOAD_FAIL_EXIT)
            observation_vector = ObsVector(EnkfObservationImplementationType.SUMMARY_OBS, observation_key, summary_observation_node, count)

            main.getObservations().addObservationVector(observation_vector)

            values = []
            for index in range(0, count):
                value = index * 10.5
                std = index / 10.0
                summary_observation_node = SummaryObservation(summary_key, observation_key, value, std)
                observation_vector.installNode(index, summary_observation_node)
                self.assertEqual(observation_vector.getNode(index), summary_observation_node)
                self.assertEqual(value, summary_observation_node.getValue())
                values.append((index, value, std))
            


            observations = main.getObservations()
            test_vector = observations[observation_key]
            index = 0
            for node in test_vector:
                self.assertTrue( isinstance( node , SummaryObservation ))
                self.assertEqual( node.getValue( ) , index * 10.5 )
                index += 1

                
            self.assertEqual(observation_vector, test_vector)
            for index, value, std in values:
                self.assertTrue(test_vector.isActive(index))

                summary_observation_node = test_vector.getNode(index)
                """@type: SummaryObservation"""

                self.assertEqual(value, summary_observation_node.getValue())
                self.assertEqual(std, summary_observation_node.getStandardDeviation())
                self.assertEqual(summary_key, summary_observation_node.getSummaryKey())


            main.free()
示例#17
0
 def test_site_bootstrap(self):
     with TestAreaContext("enkf_test", store_area=True) as work_area:
         EnKFMain.loadSiteConfig()
示例#18
0
 def test_site_bootstrap( self ):
     with TestAreaContext("enkf_test", store_area=True) as work_area:
         EnKFMain.loadSiteConfig()
示例#19
0
def main():
    app = QtGui.QApplication(sys.argv) #Early so that QT is initialized before other imports
    from ert_gui.pages.config.configpages import ConfigPages
    from ert_gui.pages.plot.plotpanel import PlotPanel

    splash = QtGui.QSplashScreen(resourceImage("newsplash") , QtCore.Qt.WindowStaysOnTopHint)
    splash.show()
    splash.showMessage("Starting up...", QtCore.Qt.AlignLeft, QtCore.Qt.white)
    app.processEvents()

    window = Application()

    splash.showMessage("Bootstrapping...", QtCore.Qt.AlignLeft, QtCore.Qt.white)
    app.processEvents()
    
    ert         = ErtWrapper( )
    strict      = True
    site_config = os.getenv("ERT_SITE_CONFIG")
    if len(sys.argv) == 1:
        print "-----------------------------------------------------------------"
        print "-- You must supply the name of configuration file as the first --"
        print "-- commandline argument:                                       --"
        print "--                                                             --"
        print "-- bash%  gert <config_file>                                   --"
        print "--                                                             --"
        print "-- If the configuration file does not exist, gert will create  --"
        print "-- create a new configuration file.                            --"
        print "-----------------------------------------------------------------"
    #sys.exit(0)
    else:
        enkf_config = sys.argv[1]
        if not os.path.exists(enkf_config):
            print "Trying to start new config"
            new_configuration_dialog = NewConfigurationDialog(enkf_config)
            success = new_configuration_dialog.exec_()
            if not success:
                print "Can not run without a configuration file."
                sys.exit(1)
            else:
                enkf_config      = new_configuration_dialog.getConfigurationPath()
                firste_case_name = new_configuration_dialog.getCaseName()
                dbase_type       = new_configuration_dialog.getDBaseType()
                num_realizations = new_configuration_dialog.getNumberOfRealizations()
                storage_path     = new_configuration_dialog.getStoragePath()

                EnKFMain.create_new_config(enkf_config, storage_path , firste_case_name, dbase_type, num_realizations)
                strict = False

        ert.bootstrap(enkf_config, site_config = site_config, strict = strict)
        window.setSaveFunction(ert.save)

        splash.showMessage("Creating GUI...", QtCore.Qt.AlignLeft, QtCore.Qt.white)
        app.processEvents()

        window.addPage("Configuration", resourceIcon("config"), ConfigPages(window))
        window.addPage("Init" , resourceIcon("db"), InitPanel(window))
        window.addPage("Run"  , resourceIcon("run"), RunPanel(window))
        window.addPage("Plots", resourceIcon("plot"), PlotPanel())

        splash.showMessage("Communicating with ERT...", QtCore.Qt.AlignLeft, QtCore.Qt.white)
        app.processEvents()

        ContentModel.contentModel = ert
        ContentModel.updateObservers()

        window.show()
        splash.finish(window)

        sys.exit(app.exec_())
示例#20
0
文件: test_enkf.py 项目: blattms/ert
 def test_bootstrap( self ):
     with TestAreaContext("enkf_test", store_area=True) as work_area:
         work_area.copy_directory(self.case_directory)
         main = EnKFMain("simple_config/minimum_config", self.site_config_file)
         self.assertTrue(main, "Load failed")
         main.free()
示例#21
0
文件: test_enkf.py 项目: blattms/ert
    def test_config( self ):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config", self.site_config_file)

            self.assertIsInstance(main.ensembleConfig(), EnsConfig)
            self.assertIsInstance(main.analysisConfig(), AnalysisConfig)
            self.assertIsInstance(main.getModelConfig(), ModelConfig)
            #self.assertIsInstance(main.local_config(), LocalConfig) #warn: Should this be None?
            self.assertIsInstance(main.siteConfig(), SiteConfig)
            self.assertIsInstance(main.eclConfig(), EclConfig)
            self.assertIsInstance(main.plot_config(), PlotConfig)

            # self.main.load_obs(obs_config_file)
            self.assertIsInstance(main.getObservations(), EnkfObs)
            self.assertIsInstance(main.get_templates(), ErtTemplates)
            self.assertIsInstance(main.getEnkfFsManager().getFileSystem(), EnkfFs)
            # self.assertIsInstance(main.iget_member_config(0), MemberConfig)
            self.assertIsInstance(main.getMemberRunningState(0), EnKFState)

            main.free()
示例#22
0
    def test_config(self):
        with TestAreaContext("enkf_test") as work_area:
            work_area.copy_directory(self.case_directory)

            main = EnKFMain("simple_config/minimum_config")

            self.assertIsInstance(main.ensembleConfig(), EnsembleConfig)
            self.assertIsInstance(main.analysisConfig(), AnalysisConfig)
            self.assertIsInstance(main.getModelConfig(), ModelConfig)
            #self.assertIsInstance(main.local_config(), LocalConfig) #warn: Should this be None?
            self.assertIsInstance(main.siteConfig(), SiteConfig)
            self.assertIsInstance(main.eclConfig(), EclConfig)
            self.assertIsInstance(main.plotConfig(), PlotConfig)

            # self.main.load_obs(obs_config_file)
            self.assertIsInstance(main.getObservations(), EnkfObs)
            self.assertIsInstance(main.get_templates(), ErtTemplates)
            self.assertIsInstance(
                main.getEnkfFsManager().getCurrentFileSystem(), EnkfFs)
            # self.assertIsInstance(main.iget_member_config(0), MemberConfig)
            self.assertIsInstance(main.getMemberRunningState(0), EnKFState)

            self.assertEqual("Ensemble", main.getMountPoint())

            main.free()