Exemple #1
0
    def test_arg_loader(self):

        with self.assertRaises(IOError):
            arg = ArgLoader.load("arg1X")

        arg_file = self.createTestPath("Statoil/config/with_GEN_DATA_RFT/wellpath/WI_1.txt")
            
        with self.assertRaises(ValueError):
            arg = ArgLoader.load(arg_file , column_names = ["Col1" , "Col2"])

        arg = ArgLoader.load(arg_file , column_names = ["utm_x" , "utm_y" , "md" , "tvd"])
        self.assertFloatEqual( arg["utm_x"][0] , 461317.620646)
Exemple #2
0
    def test_arg_loader(self):

        with self.assertRaises(IOError):
            arg = ArgLoader.load("arg1X")

        arg_file = self.createTestPath(
            "Statoil/config/with_GEN_DATA_RFT/wellpath/WI_1.txt")

        with self.assertRaises(ValueError):
            arg = ArgLoader.load(
                arg_file,
                column_names=["Col1", "Col2", "Col3", "COl5", "Col6"])

        arg = ArgLoader.load(arg_file,
                             column_names=["utm_x", "utm_y", "md", "tvd"])
        self.assertFloatEqual(arg["utm_x"][0], 461317.620646)
    def run(self, output_file, trajectory_path , case_list=None, infer_iteration=True):
        """The run method will export the RFT's for all wells and all cases.

        The successfull operation of this method hinges on two naming
        conventions:
        
          1. All the GEN_DATA RFT observations have key RFT_$WELL
          2. The trajectory files are in $trajectory_path/$WELL.txt
        
        """


        wells = set()
        obs_pattern = "RFT_*"
        enkf_obs = self.ert().getObservations()
        obs_keys = enkf_obs.getMatchingKeys(obs_pattern , obs_type = EnkfObservationImplementationType.GEN_OBS)
        
        cases = []
        if case_list is not None:
            cases = case_list.split(",")

        if case_list is None or len(cases) == 0:
            cases = [self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName()]

        data_frame = pandas.DataFrame()
        for index, case in enumerate(cases):
            case = case.strip()
            case_frame = pandas.DataFrame()
            
            if not self.ert().getEnkfFsManager().caseExists(case):
                raise UserWarning("The case '%s' does not exist!" % case)

            if not self.ert().getEnkfFsManager().caseHasData(case):
                raise UserWarning("The case '%s' does not have any data!" % case)

            if infer_iteration:
                iteration_number = self.inferIterationNumber(case)
            else:
                iteration_number = index
                
            for obs_key in obs_keys:
                well = obs_key.replace("RFT_","")
                wells.add( well )
                obs_vector = enkf_obs[obs_key]
                data_key = obs_vector.getDataKey()
                report_step = obs_vector.activeStep()
                obs_node = obs_vector.getNode( report_step )
                
                rft_data = GenDataCollector.loadGenData( self.ert() , case , data_key , report_step )
                fs = self.ert().getEnkfFsManager().getFileSystem( case )
                realizations = fs.realizationList( RealizationStateEnum.STATE_HAS_DATA )
                
                # Trajectory
                trajectory_file = os.path.join( trajectory_path , "%s.txt" % well)
                trajectory = WellTrajectory( trajectory_file )
                arg = ArgLoader.load( trajectory_file , column_names = ["utm_x" , "utm_y" , "md" , "tvd"])
                tvd_arg = arg["tvd"]
                data_size = len(tvd_arg)

                
                # Observations
                obs = numpy.empty(shape = (data_size , 2 ) , dtype=numpy.float64)
                obs.fill( numpy.nan )
                for (value,std,data_index) in obs_node:
                    obs[data_index,0] = value
                    obs[data_index,1] = std
                    

                real_data = pandas.DataFrame( index = ["Realization","Well"])
                for iens in realizations:
                    realization_frame = pandas.DataFrame( data = {"TVD" : tvd_arg , 
                                                                  "Pressure" : rft_data[iens],
                                                                  "ObsValue" : obs[:,0],
                                                                  "ObsStd"   : obs[:,1]},
                                                          columns = ["TVD" , "Pressure" , "ObsValue" , "ObsStd"])
                    
                    realization_frame["Realization"] = iens
                    realization_frame["Well"] = well
                    realization_frame["Case"] = case
                    realization_frame["Iteration"] = iteration_number

                    case_frame = pandas.concat( [case_frame , realization_frame] )
                    
                data_frame = pandas.concat([data_frame, case_frame])

        data_frame.set_index(["Realization" , "Well" , "Case" , "Iteration"] , inplace = True)
        data_frame.to_csv(output_file)
        export_info = "Exported RFT information for wells: %s to: %s " % (", ".join(list(wells)) , output_file)
        return export_info
Exemple #4
0
                obs_vector = enkf_obs[obs_key]
                data_key = obs_vector.getDataKey()
                report_step = obs_vector.activeStep()
                obs_node = obs_vector.getNode(report_step)

                rft_data = GenDataCollector.loadGenData(self.ert(), case, data_key, report_step)
                fs = self.ert().getEnkfFsManager().getFileSystem(case)
                realizations = fs.realizationList(RealizationStateEnum.STATE_HAS_DATA)

                # Trajectory
                trajectory_file = os.path.join(trajectory_path, "%s.txt" % well)
                if not os.path.isfile(trajectory_file):
                    trajectory_file = os.path.join(trajectory_path, "%s_R.txt" % well)

                trajectory = WellTrajectory(trajectory_file)
                arg = ArgLoader.load(trajectory_file, column_names=["utm_x", "utm_y", "md", "tvd"])
                tvd_arg = arg["tvd"]
                data_size = len(tvd_arg)

                # Observations
                obs = numpy.empty(shape=(data_size, 2), dtype=numpy.float64)
                obs.fill(numpy.nan)
                for obs_index in range(len(obs_node)):
                    data_index = obs_node.getDataIndex(obs_index)
                    value = obs_node.getValue(obs_index)
                    std = obs_node.getStandardDeviation(obs_index)
                    obs[data_index, 0] = value
                    obs[data_index, 1] = std

                for iens in realizations:
                    realization_frame = pandas.DataFrame(data={"TVD": tvd_arg,