Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update(self , index , time):
if self._try_update(index , CTime(time)):
return True
else:
if self.isStrict():
raise Exception("Tried to update with inconsistent value")
else:
return False
def update(self , index , time):
if TimeMap.cNamespace().try_update(self , index , CTime(time)):
return True
else:
if self.isStrict():
raise Exception("Tried to update with inconsistent value")
else:
return False
def check_sim_time( self , date):
"""
Will check if the input date is in the time span [sim_start , sim_end].
"""
if not isinstance(date, CTime):
date = CTime(date)
return EclSum.cNamespace().check_sim_time( self , date )
def iget_restart_sim_time( self , index ):
"""
Will locate restart block nr @index and return the true time
as a datetime instance.
"""
ct = CTime(self._iget_restart_time( index ))
return ct.datetime()
def getStartTime(self):
"""
A Python datetime instance with the start time.
See start_date() for further details.
"""
return CTime( self._get_start_date( ) ).datetime()
def iget_date(self , time_index):
"""
Returns the simulation date for element nr @time_index.
"""
long_time = self._iget_sim_time( time_index )
ct = CTime(long_time)
return ct.datetime()
def getDataStartTime(self):
"""The first date we have data for.
Thiw will mostly be equal to getStartTime(), but in the case
of restarts, where the case we have restarted from is not
found, this time will be later than the true start of the
field.
"""
return CTime( self._get_data_start( ) ).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 raise IndexError(); if the file does not
have the keyword at all - KeyError will be raised.
"""
index = self._get_restart_index( CTime( dtime ) )
if index >= 0:
if self.num_named_kw(kw_name) > index:
kw = self.iget_named_kw( kw_name , index )
if copy:
return EclKW.copy( kw )
else:
return kw
else:
if self.has_kw(kw_name):
raise IndexError("Does not have keyword:%s at time:%s" % (kw_name , dtime))
else:
raise KeyError("Key:%s not recognized" % kw_name)
else:
raise IndexError("Does not have keyword:%s at time:%s" % (kw_name , dtime))
time argument, which satisfies the tolerance criteria.
With the call:
lookupTime( datetime.date(2010,1,10) , 3600*24 , 3600*7)
We will find the report step in the date interval 2010,1,9 -
2010,1,17 which is closest to 2010,1,10. The tolerance limits
are inclusive.
If no report step satisfying the criteria is found a
ValueError exception will be raised.
"""
if tolerance_seconds_before == 0 and tolerance_seconds_after == 0:
index = TimeMap.cNamespace().lookup_time(self , CTime(time))
else:
index = TimeMap.cNamespace().lookup_time_with_tolerance(self , CTime(time) , tolerance_seconds_before , tolerance_seconds_after)
if index >= 0:
return index
else:
raise ValueError("The time:%s was not found in the time_map instance" % time)
def getEndTime(self):
"""
A Python datetime instance with the last loaded time.
"""
return CTime(self._get_end_date( )).datetime()