コード例 #1
0
ファイル: ecl_sum.py プロジェクト: akva2/ResInsight
    def get_interp( self , key , days = None , date = None):
        """
        Will lookup vector @key at time given by @days or @date.
        
        Requiers exactly one input argument @days or @date; will raise
        exception ValueError if this is not satisfied. 

        The method will check that the time argument is within the
        time limits of the simulation; if else the method will raise
        exception ValueError.

        Also available as method get_interp() on the EclSumVector
        class.
        """
        if days:
            if date:
                raise ValueError("Must supply either days or date")
            else:
                if cfunc.check_sim_days( self , days ):
                    return cfunc.get_general_var_from_sim_days( self , days , key )
                else:
                    raise ValueError("days:%s is outside range of simulation: [%g,%g]" % (days , self.first_day , self.sim_length))
        elif date:
            if cfunc.check_sim_time( self , ctime(date) ):
                return cfunc.get_general_var_from_sim_time( self , ctime(date) , key )
            else:
                raise ValueError("date:%s is outside range of simulation data" % date)
        else:
            raise ValueError("Must supply either days or date")
コード例 #2
0
ファイル: ecl_file.py プロジェクト: joelmheim/ResInsight
    def restart_get_kw( self , kw_name , dtime , copy = False):
        """
        Will return EclKW @kw_name from restart file at time @dtime.

        This function assumes that the current EclFile instance
        represents a restart file. It will then look for keyword
        @kw_name exactly at the time @dtime; @dtime is a datetime
        instance:

            file = EclFile( "ECLIPSE.UNRST" )
            swat2010 = file.restart_get_kw( "SWAT" , datetime.datetime( 2000 , 1 , 1 ))

        By default the returned kw instance is a reference to the
        ecl_kw still contained in the EclFile instance; i.e. the kw
        will become a dangling reference if the EclFile instance goes
        out of scope. If the optional argument @copy is True the
        returned kw will be a true copy.

        If the file does not have the keyword at the specified time the
        function will return None.
        """
        index = cfunc.get_restart_index( self , ctime( dtime ) )
        if index >= 0:
            kw = self.iget_named_kw( kw_name , index )
            if copy:
                return EclKW.copy( kw )
            else:
                return kw
        else:
            return None
コード例 #3
0
ファイル: ecl_file.py プロジェクト: joelmheim/ResInsight
    def restart_block( cls , filename , dtime = None , report_step = None):
        """
        Load one report step from unified restart file.

        Unified restart files can be prohibitively large; with this
        class method it is possible to load only one report
        step. Which report step you are interested in must be
        specified with either one of the optional arguments
        @report_step or @dtime. If present @dtime should be a normal
        python datetime instance:
        
            block1 = EclFile.restart_block( "ECLIPSE.UNRST" , dtime = datetime.datetime( year , month , day ))
            block2 = EclFile.restart_block( "ECLIPSE.UNRST" , report_step = 67 )

        If the block you are asking for can not be found the method
        will return None.
        """
        obj = EclFile( filename )
        
        if dtime:
            OK = cfunc.restart_block_time( obj , ctime( dtime ))
        elif not report_step == None:
            OK = cfunc.restart_block_step( obj , report_step )
        else:
            raise TypeError("restart_block() requires either dtime or report_step argument - none given.")
        
        if not OK:
            if dtime:
                raise ValueError("Could not locate date:%02d/%02d/%4d in restart file: %s." % (dtime.day , dtime.month , dtime.year , filename))
            else:
                raise ValueError("Could not locate report step:%d in restart file: %s." % (report_step , filename))
            
            
        return obj
コード例 #4
0
ファイル: ecl_file.py プロジェクト: rolk/ert
    def restart_get_kw(self, kw_name, dtime, copy=False):
        """
        Will return EclKW @kw_name from restart file at time @dtime.

        This function assumes that the current EclFile instance
        represents a restart file. It will then look for keyword
        @kw_name exactly at the time @dtime; @dtime is a datetime
        instance:

            file = EclFile( "ECLIPSE.UNRST" )
            swat2010 = file.restart_get_kw( "SWAT" , datetime.datetime( 2000 , 1 , 1 ))

        By default the returned kw instance is a reference to the
        ecl_kw still contained in the EclFile instance; i.e. the kw
        will become a dangling reference if the EclFile instance goes
        out of scope. If the optional argument @copy is True the
        returned kw will be a true copy.

        If the file does not have the keyword at the specified time the
        function will return None.
        """
        index = cfunc.get_restart_index(self, ctime(dtime))
        if index >= 0:
            kw = self.iget_named_kw(kw_name, index)
            if copy:
                return EclKW.copy(kw)
            else:
                return kw
        else:
            return None
コード例 #5
0
ファイル: ecl_sum.py プロジェクト: rolk/ert
    def get_interp(self, key, days=None, date=None):
        """
        Will lookup vector @key at time given by @days or @date.
        
        Requiers exactly one input argument @days or @date; will raise
        exception ValueError if this is not satisfied. 

        The method will check that the time argument is within the
        time limits of the simulation; if else the method will raise
        exception ValueError.

        Also available as method get_interp() on the EclSumVector
        class.
        """
        if days:
            if date:
                raise ValueError("Must supply either days or date")
            else:
                if cfunc.check_sim_days(self, days):
                    return cfunc.get_general_var_from_sim_days(self, days, key)
                else:
                    raise ValueError(
                        "days:%s is outside range of simulation: [%g,%g]" %
                        (days, self.first_day, self.sim_length))
        elif date:
            if self.check_sim_time(date):
                return cfunc.get_general_var_from_sim_time(
                    self, ctime(date), key)
            else:
                raise ValueError(
                    "date:%s is outside range of simulation data" % date)
        else:
            raise ValueError("Must supply either days or date")
コード例 #6
0
ファイル: ecl_file.py プロジェクト: rolk/ert
    def has_sim_time(self, dtime):
        """
        Checks if the current EclFile has data for time @dtime.

        The implementation goes through all the INTEHEAD headers in
        the EclFile, i.e. it can be fooled (and probably crash and
        burn) if the EclFile instance in question is has INTEHEAD
        keyword(s), but is still not a restart file. The @dtime
        argument should be a normal python datetime instance.
        """
        return cfunc.has_sim_time(self, ctime(dtime))
コード例 #7
0
ファイル: ecl_file.py プロジェクト: joelmheim/ResInsight
    def has_sim_time( self , dtime ):
        """
        Checks if the current EclFile has data for time @dtime.

        The implementation goes through all the INTEHEAD headers in
        the EclFile, i.e. it can be fooled (and probably crash and
        burn) if the EclFile instance in question is has INTEHEAD
        keyword(s), but is still not a restart file. The @dtime
        argument should be a normal python datetime instance.
        """
        return cfunc.has_sim_time( self , ctime(dtime) )    
コード例 #8
0
ファイル: ecl_rft.py プロジェクト: moiw/ert
    def get(self , well_name , date ):
        """
        Will look up the RFT object corresponding to @well and @date.

        Returns None if no matching RFT can be found.
        """
        c_ptr = cfunc_file.get_rft( self , well_name , ctime( date )) 
        if c_ptr:
            return EclRFT( c_ptr , self)
        else:
            return None
コード例 #9
0
ファイル: ecl_sum.py プロジェクト: rolk/ert
    def get_report(self, date=None, days=None):
        """
        Will return the report step corresponding to input @date or @days.

        If the input argument does not correspond to any report steps
        the function will return -1. Observe that the function
        requires strict equality.
        """
        if date:
            if days:
                raise ValueError("Must supply either days or date")
            step = cfunc.get_report_step_from_time(self, ctime(date))
        elif days:
            step = cfunc.get_report_step_from_days(self, days)

        return step
コード例 #10
0
ファイル: ecl_sum.py プロジェクト: joelmheim/ResInsight
    def get_report( self , date = None , days = None):
        """
        Will return the report step corresponding to input @date or @days.

        If the input argument does not correspond to any report steps
        the function will return -1. Observe that the function
        requires strict equality.
        """
        if date:
            if days:
                raise ValueError("Must supply either days or date")
            step = cfunc.get_report_step_from_time( self , ctime(date))
        elif days:
            step = cfunc.get_report_step_from_days( self , days)
            
        return step
コード例 #11
0
ファイル: ecl_sum.py プロジェクト: rolk/ert
    def get_interp_vector(self, key, days_list=None, date_list=None):
        """
        Will return numpy vector with interpolated values.

        Requiers exactly one input argument @days or @date; will raise
        exception ValueError if this is not satisfied. 

        The method will check that the time arguments are within the
        time limits of the simulation; if else the method will raise
        exception ValueError.

        Also available as method get_interp_vector() on the
        EclSumVector class.
        """
        if days_list:
            if date_list:
                raise ValueError("Must supply either days_list or date_list")
            else:
                vector = numpy.zeros(len(days_list))
                sim_length = self.sim_length
                sim_start = self.first_day
                index = 0
                for days in days_list:
                    if days >= sim_start and days < sim_length:
                        vector[index] = cfunc.get_general_var_from_sim_days(
                            self, days, key)
                    else:
                        raise ValueError("Invalid days value")
                    index += 1
        elif date_list:
            start_time = self.data_start
            end_time = self.end_date
            vector = numpy.zeros(len(date_list))
            index = 0
            for date in date_list:
                if date >= start_time and date <= end_time:
                    vector[index] = cfunc.get_general_var_from_sim_time(
                        self, ctime(date), key)
                else:
                    raise ValueError("Invalid date value")
                index += 1
        else:
            raise ValueError("Must supply either days_list or date_list")
        return vector
コード例 #12
0
ファイル: ecl_sum.py プロジェクト: joelmheim/ResInsight
    def get_interp_vector( self , key , days_list = None , date_list = None):
        """
        Will return numpy vector with interpolated values.

        Requiers exactly one input argument @days or @date; will raise
        exception ValueError if this is not satisfied. 

        The method will check that the time arguments are within the
        time limits of the simulation; if else the method will raise
        exception ValueError.

        Also available as method get_interp_vector() on the
        EclSumVector class.
        """
        if days_list:
            if date_list:
                raise ValueError("Must supply either days_list or date_list")
            else:
                vector = numpy.zeros( len(days_list ))
                sim_length = self.sim_length
                sim_start  = self.first_day
                index = 0
                for days in days_list:
                    if days >= sim_start and days < sim_length:
                        vector[index] = cfunc.get_general_var_from_sim_days( self , days , key)
                    else:
                        raise ValueError("Invalid days value")
                    index += 1
        elif date_list:
            start_time = self.data_start
            end_time   = self.end_date
            vector = numpy.zeros( len(date_list ))
            index = 0
            for date in date_list:
                if date >= start_time and date <= end_time:
                    vector[index] =  cfunc.get_general_var_from_sim_time( self , ctime(date) , key) 
                else:
                    raise ValueError("Invalid date value")
                index += 1
        else:
            raise ValueError("Must supply either days_list or date_list")
        return vector
コード例 #13
0
ファイル: ecl_file.py プロジェクト: rolk/ert
    def select_restart_section(self,
                               index=None,
                               report_step=None,
                               sim_time=None):
        """
        Will select a restart section as the active section.
        
        You must specify a report step with the @report_step argument,
        a true time with the @sim_time argument or a plain index to
        select restart block. If none of arguments are given exception
        TypeError will be raised. If present the @sim_time argument
        should be a datetime instance.
        
        If the restart section you ask for can not be found the method
        will raise a ValueError exeception. To protect against this
        you can query first with the has_report_step(), 
        has_sim_time() or num_report_steps() methods.

        This method should be used when you have already loaded the
        complete file; if you only want to load a section from the
        file you can use the classmethod restart_block().

        The method will return 'self' which can be used to aid
        readability.
        """

        OK = False
        if report_step:
            OK = cfunc.restart_block_step(self, report_step)
        elif sim_time:
            OK = cfunc.restart_block_time(self, ctime(sim_time))
        elif index:
            OK = cfunc.restart_block_iselect(self, index)
        else:
            raise TypeError(
                "select_restart_section() requires either dtime or report_step argument - none given"
            )

        if not OK:
            raise TypeError(
                "select_restart_section() Could not locate report_step/dtime")
        return self
コード例 #14
0
ファイル: ecl_file.py プロジェクト: rolk/ert
    def restart_block(cls, filename, dtime=None, report_step=None):
        """
        Load one report step from unified restart file.

        Unified restart files can be prohibitively large; with this
        class method it is possible to load only one report
        step. Which report step you are interested in must be
        specified with either one of the optional arguments
        @report_step or @dtime. If present @dtime should be a normal
        python datetime instance:
        
            block1 = EclFile.restart_block( "ECLIPSE.UNRST" , dtime = datetime.datetime( year , month , day ))
            block2 = EclFile.restart_block( "ECLIPSE.UNRST" , report_step = 67 )

        If the block you are asking for can not be found the method
        will return None.
        """
        obj = EclFile(filename)

        if dtime:
            OK = cfunc.restart_block_time(obj, ctime(dtime))
        elif not report_step == None:
            OK = cfunc.restart_block_step(obj, report_step)
        else:
            raise TypeError(
                "restart_block() requires either dtime or report_step argument - none given."
            )

        if not OK:
            if dtime:
                raise ValueError(
                    "Could not locate date:%02d/%02d/%4d in restart file: %s."
                    % (dtime.day, dtime.month, dtime.year, filename))
            else:
                raise ValueError(
                    "Could not locate report step:%d in restart file: %s." %
                    (report_step, filename))

        return obj
コード例 #15
0
ファイル: ecl_rft.py プロジェクト: moiw/ert
    def size( self , well = None , date = None):
        """
        The number of elements in EclRFTFile container. 

        By default the size() method will return the total number of
        RFTs/PLTs in the container, but by specifying the optional
        arguments date and/or well the function will only count the
        number of well measurements matching that time or well
        name. The well argument can contain wildcards.

           rftFile = ecl.EclRFTFile( "ECLIPSE.RFT" )
           print "Total number of RFTs : %d" % rftFile.size( )
           print "RFTs matching OP*    : %d" % rftFile.size( well = "OP*" )
           print "RFTs at 01/01/2010   : %d" % rftFile.size( date = datetime.date( 2010 , 1 , 1 ))

        """
        if date:
            cdate = ctime( date )
        else:
            cdate = -1

        return cfunc_file.get_size( self , well , cdate)
コード例 #16
0
ファイル: ecl_file.py プロジェクト: joelmheim/ResInsight
    def select_restart_section( self, index = None , report_step = None , sim_time = None):
        """
        Will select a restart section as the active section.
        
        You must specify a report step with the @report_step argument,
        a true time with the @sim_time argument or a plain index to
        select restart block. If none of arguments are given exception
        TypeError will be raised. If present the @sim_time argument
        should be a datetime instance.
        
        If the restart section you ask for can not be found the method
        will raise a ValueError exeception. To protect against this
        you can query first with the has_report_step(), 
        has_sim_time() or num_report_steps() methods.

        This method should be used when you have already loaded the
        complete file; if you only want to load a section from the
        file you can use the classmethod restart_block().

        The method will return 'self' which can be used to aid
        readability.
        """

        OK = False
        if report_step:
            OK = cfunc.restart_block_step( self , report_step )
        elif sim_time:
            OK = cfunc.restart_block_time( self , ctime( sim_time ) )
        elif index:
            OK = cfunc.restart_block_iselect( self, index )
        else:
            raise TypeError("select_restart_section() requires either dtime or report_step argument - none given")

        
        if not OK:
            raise TypeError("select_restart_section() Could not locate report_step/dtime")
        return self
コード例 #17
0
ファイル: ecl_rft.py プロジェクト: rolk/ert
 def get(self, well_name, date):
     c_ptr = cfunc_file.get_rft(self, well_name, ctime(date))
     if c_ptr:
         return EclRFT(c_ptr, self)
     else:
         return None
コード例 #18
0
ファイル: sched_file.py プロジェクト: akva2/ResInsight
 def __init__(self , filename , start_time):
     c_ptr = cfunc.parse( filename , ctime( start_time ))
     self.init_cobj( c_ptr , cfunc.free )
コード例 #19
0
ファイル: ecl_rft.py プロジェクト: akva2/ResInsight
 def get(self , well_name , date ):
     c_ptr = cfunc_file.get_rft( self , well_name , ctime( date )) 
     if c_ptr:
         return EclRFT( c_ptr , self)
     else:
         return None
コード例 #20
0
ファイル: ecl_sum.py プロジェクト: joelmheim/ResInsight
 def check_sim_time( self , date):
     """
     Will check if the input date is in the time span [sim_start , sim_end].
     """
     return cfunc.check_sim_time( self , ctime(date) )
コード例 #21
0
ファイル: sched_file.py プロジェクト: rolk/ert
 def __init__(self, filename, start_time):
     c_ptr = cfunc.parse(filename, ctime(start_time))
     self.init_cobj(c_ptr, cfunc.free)
コード例 #22
0
ファイル: ecl_sum.py プロジェクト: rolk/ert
 def check_sim_time(self, date):
     """
     Will check if the input date is in the time span [sim_start , sim_end].
     """
     return cfunc.check_sim_time(self, ctime(date))