gnome.environment.running_average

running average time series for a given wind, tide, or generic time series

Module Contents

Classes

UVTuple

Tide object schema

TimeSeriesTuple

Tide object schema

RunningAverage

Defines a running average time series for a wind or tide

class gnome.environment.running_average.UVTuple(*arg, **kw)

Bases: gnome.persist.extend_colander.DefaultTupleSchema

Tide object schema

u
v
class gnome.environment.running_average.TimeSeriesTuple(*arg, **kw)

Bases: gnome.persist.extend_colander.DefaultTupleSchema

Tide object schema

datetime
uv
class gnome.environment.running_average.RunningAverage(wind=None, timeseries=None, past_hours_to_average=3, **kwargs)

Bases: gnome.environment.environment.Environment

Defines a running average time series for a wind or tide

Initializes a running average object from a wind and past hours to average

If no wind is given, timeseries gets initialized as:

timeseries = np.zeros((1,), dtype=basic_types.datetime_value_2d)

(note: probably should be an error)

All other keywords are optional. Optional parameters (kwargs):

Parameters:

past_hours_to_average=3 – duration of time average window

Units are always ‘mps’

property past_hours_to_average
property timeseries
_schema
__repr__()

Return repr(self).

__str__()

Return str(self).

_convert_to_time_value_pair(datetime_value_2d)

fmt datetime_value_2d so it is a numpy array with dtype=basic_types.time_value_pair as the C++ code expects

get_timeseries(datetime=None)

Returns the timeseries in the requested format. If datetime=None, then the original timeseries that was entered is returned. If datetime is a list containing datetime objects, then the wind value for each of those date times is determined by the underlying CyOSSMTime object and the timeseries is returned.

The output format is defined by the strings ‘r-theta’, ‘uv’

Parameters:

datetime (datetime object) – [optional] datetime object or list of datetime objects for which the value is desired

Returns:

numpy array containing dtype=basic_types.datetime_value_2d. Contains user specified datetime and the corresponding values in ‘m/s’ and ‘uv’ format

prepare_for_model_run(model_time)

Make sure we are up to date with the referenced time series

prepare_for_model_step(model_time)

Make sure we are up to date with the referenced time series

create_running_average_timeseries(past_hours_to_average, model_time=0)

Creates the timeseries of the RunningAverage object

Parameters:

past_hours_to_average – amount of data to use in the averaging

get_value(time)

Return the value at specified time and location. Timeseries are independent of location; however, a gridded datafile may require location so this interface may get refactored if it needs to support different types of data. It assumes the data in SI units (m/s) and ‘uv’ format

Note

It invokes get_timeseries(..) function