HWRF  trunk@4391
Public Member Functions | Public Attributes | List of all members
hwrf.numerics.TimeArray Class Reference

A time-indexed array that can only handle equally spaced times. More...

Detailed Description

A time-indexed array that can only handle equally spaced times.

This implements an array-like object that uses time as an index. It recognizes only discrete times as specified by a start, an end and a timestep. The end is only used as a guideline: if it does not lie exactly on a timestep, the next timestep end is used. Note that all methods in this class have the same meaning as the built-in list class, but accept times as input, except if specified otherwise. In all cases, the time "index" is anything accepted by to_datetime_rel(...,self.start).

Definition at line 689 of file numerics.py.

Inheritance diagram for hwrf.numerics.TimeArray:
hwrf.numerics.TimeContainer

Public Member Functions

def __init__
 TimeArray constructor. More...
 
def index_of (self, when)
 Returns the index of the specified time in the internal storage arrays or raises NotInTimespan if the time is not in the timespan. More...
 
- Public Member Functions inherited from hwrf.numerics.TimeContainer
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...
 

Public Attributes

 start
 Start time. More...
 
 end
 End time. More...
 
 timestep
 Timestep between times. More...
 

Constructor & Destructor Documentation

def hwrf.numerics.TimeArray.__init__ (   self,
  start,
  end,
  timestep,
  init = None 
)

TimeArray constructor.

Parameters
start,end,timestepSpecifies the equally-spaced times.
initThe initializer for data values. This is typically a constructor (dict, list, etc.) or a function that calls a constructor.

Definition at line 700 of file numerics.py.

Member Function Documentation

def hwrf.numerics.TimeArray.index_of (   self,
  when 
)

Returns the index of the specified time in the internal storage arrays or raises NotInTimespan if the time is not in the timespan.

Parameters
whenAnything accepted by to_datetime_rel(when,self._start)

Definition at line 726 of file numerics.py.

Member Data Documentation

hwrf.numerics.TimeArray.end

End time.

Do not modify.

Definition at line 715 of file numerics.py.

hwrf.numerics.TimeArray.start

Start time.

Do not modify.

Definition at line 714 of file numerics.py.

hwrf.numerics.TimeArray.timestep

Timestep between times.

Do not modify.

Definition at line 716 of file numerics.py.


The documentation for this class was generated from the following file: