HWRF
trunk@4391
|
Abstract base class that maps from time to objects. More...
Abstract base class that maps from time to objects.
This is the abstract base class of any class that represents a mapping from a set of times to a set of data. It provides the underlying implementation of TimeArray and TimeMapping. This is not exported by "from hwrf.numerics import *" to prevent accidental use.
Definition at line 493 of file numerics.py.
Public Member Functions | |
def | __init__ |
TimeContainer constructor. More... | |
def | at_index (self, index) |
Returns the data at the given index, or raises KeyError if no data exists. More... | |
def | index_of (self, when) |
This virtual function should be implemented in a subclass. More... | |
def | lasttime (self) |
Returns the last time in the array or list of times, even if it has no data. More... | |
def | firsttime (self) |
Returns the first time in the array or list of times, even if it has no data. More... | |
def | __getitem__ (self, when) |
Returns the item at the latest time that is not later than "when". More... | |
def | neartime |
Returns a tuple containing the time nearest to "when" without going over, and the index of that time. More... | |
def | get (self, when, default) |
Returns the item at the latest time that is not later than "when.". More... | |
def | __setitem__ (self, when, val) |
Finds the latest time that is not later than "when" in self._times. More... | |
def | __iter__ (self) |
Iterates over all data. More... | |
def | itervalues (self) |
Iterates over data for all known times that have data. More... | |
def | iterkeys (self) |
Iterates over all times that have data. More... | |
def | iteritems (self) |
Iterates over all known times that have data, returning a tuple containing the time and the data at that time. More... | |
def | __reversed__ (self) |
Iterates over all known times that have data, in reverse order. More... | |
def | __delitem__ (self, when) |
Finds the latest time that is not later than "when" and removes the data it is mapped to. More... | |
def | __contains__ (self, when) |
Finds the latest time that is not later than "when" in self._times. More... | |
def | __len__ (self) |
Returns the number of times that have data. More... | |
def | times (self) |
Iterates over all times in this TimeContainer. | |
def | datatimes (self) |
Iterates over all times in this TimeContainer that map to data. More... | |
def | __str__ (self) |
Returns a string representation of this object. More... | |
def | datatimes_reversed (self) |
Iterates in reverse order over all times in this TimeContainer that map to data. More... | |
def hwrf.numerics.TimeContainer.__init__ | ( | self, | |
times, | |||
init = None |
|||
) |
TimeContainer constructor.
Initializes the internal arrays for the given list of times, which must not be empty. Note that strange, potentially bad things will happen if there are duplicate times.
Implementation notes:
where N is the length of the input times array. The _data will be filled with init() and _assigned filled with True if init is present and not None, otherwise _assigned will be False.
times | the times to map from |
init | a constructor or function that creates initial values for all uninitialized array elements |
Definition at line 502 of file numerics.py.
def hwrf.numerics.TimeContainer.__contains__ | ( | self, | |
when | |||
) |
Finds the latest time that is not later than "when" in self._times.
Returns True if there is data mapped to that time and False otherwise.
when | the time of interest |
Definition at line 645 of file numerics.py.
def hwrf.numerics.TimeContainer.__delitem__ | ( | self, | |
when | |||
) |
Finds the latest time that is not later than "when" and removes the data it is mapped to.
Later calls to getitem, get, iter and so on, will not return any data for this time.
when | the time of disinterest |
Definition at line 636 of file numerics.py.
def hwrf.numerics.TimeContainer.__getitem__ | ( | self, | |
when | |||
) |
Returns the item at the latest time that is not later than "when".
If there is no data assigned at that time, then KeyError is raised.
when | the time of interest |
Definition at line 557 of file numerics.py.
def hwrf.numerics.TimeContainer.__iter__ | ( | self | ) |
Iterates over all data.
Definition at line 607 of file numerics.py.
def hwrf.numerics.TimeContainer.__len__ | ( | self | ) |
Returns the number of times that have data.
Definition at line 655 of file numerics.py.
def hwrf.numerics.TimeContainer.__reversed__ | ( | self | ) |
Iterates over all known times that have data, in reverse order.
Definition at line 628 of file numerics.py.
def hwrf.numerics.TimeContainer.__setitem__ | ( | self, | |
when, | |||
val | |||
) |
Finds the latest time that is not later than "when" in self._times.
Assigns "val" to that time.
when | the time of interest |
val | the value to assign to that time |
Definition at line 597 of file numerics.py.
def hwrf.numerics.TimeContainer.__str__ | ( | self | ) |
Returns a string representation of this object.
Definition at line 667 of file numerics.py.
def hwrf.numerics.TimeContainer.at_index | ( | self, | |
index | |||
) |
Returns the data at the given index, or raises KeyError if no data exists.
index | the desired index |
Definition at line 534 of file numerics.py.
def hwrf.numerics.TimeContainer.datatimes | ( | self | ) |
Iterates over all times in this TimeContainer that map to data.
Definition at line 662 of file numerics.py.
def hwrf.numerics.TimeContainer.datatimes_reversed | ( | self | ) |
Iterates in reverse order over all times in this TimeContainer that map to data.
Definition at line 678 of file numerics.py.
def hwrf.numerics.TimeContainer.firsttime | ( | self | ) |
Returns the first time in the array or list of times, even if it has no data.
Definition at line 553 of file numerics.py.
def hwrf.numerics.TimeContainer.get | ( | self, | |
when, | |||
default | |||
) |
Returns the item at the latest time that is not later than "when.".
when | the time of interest |
default | If there is no data assigned at that time then the given default is returned. |
Definition at line 586 of file numerics.py.
Referenced by hwrf.wrfbase.WRFDomains.__contains__(), hwrf.wrfbase.WRFDomains.__getitem__(), hwrf.wrfbase.WRFDomains.add(), hwrf.wrf.WRFSimulation.analysis_name(), produtil.datastore.UpstreamFile.check(), hwrf.regrib.GRIB1Product.getgrib1grbindex(), hwrf.regrib.GRIB1Product.getgrib1grid(), hwrf.regrib.GRIB1Product.getgrib1index(), hwrf.regrib.GRIB2Product.getgrib2grid(), and hwrf.regrib.GRIB2Product.getgrib2index().
def hwrf.numerics.TimeContainer.index_of | ( | self, | |
when | |||
) |
This virtual function should be implemented in a subclass.
It should return the index of the time to use for the given time.
when | the time of interest |
Definition at line 540 of file numerics.py.
Referenced by hwrf.numerics.TimeContainer.__contains__(), hwrf.numerics.TimeContainer.__delitem__(), hwrf.numerics.TimeContainer.__getitem__(), hwrf.numerics.TimeContainer.__setitem__(), hwrf.numerics.TimeContainer.get(), and hwrf.numerics.TimeContainer.neartime().
def hwrf.numerics.TimeContainer.iteritems | ( | self | ) |
Iterates over all known times that have data, returning a tuple containing the time and the data at that time.
Definition at line 622 of file numerics.py.
def hwrf.numerics.TimeContainer.iterkeys | ( | self | ) |
Iterates over all times that have data.
Definition at line 617 of file numerics.py.
def hwrf.numerics.TimeContainer.itervalues | ( | self | ) |
Iterates over data for all known times that have data.
Definition at line 612 of file numerics.py.
def hwrf.numerics.TimeContainer.lasttime | ( | self | ) |
Returns the last time in the array or list of times, even if it has no data.
Definition at line 548 of file numerics.py.
def hwrf.numerics.TimeContainer.neartime | ( | self, | |
when, | |||
epsilon = None |
|||
) |
Returns a tuple containing the time nearest to "when" without going over, and the index of that time.
epsilon | If specified, raise hwrf.exceptions.NoNearbyValues if no times are near that value. |
when | the time of interest |
Definition at line 566 of file numerics.py.