:py:mod:`gnome.environment.running_average` =========================================== .. py:module:: gnome.environment.running_average .. autoapi-nested-parse:: running average time series for a given wind, tide, or generic time series Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.environment.running_average.UVTuple gnome.environment.running_average.TimeSeriesTuple gnome.environment.running_average.RunningAverage .. py:class:: UVTuple(*arg, **kw) Bases: :py:obj:`gnome.persist.extend_colander.DefaultTupleSchema` Tide object schema .. py:attribute:: u .. py:attribute:: v .. py:class:: TimeSeriesTuple(*arg, **kw) Bases: :py:obj:`gnome.persist.extend_colander.DefaultTupleSchema` Tide object schema .. py:attribute:: datetime .. py:attribute:: uv .. py:class:: RunningAverage(wind=None, timeseries=None, past_hours_to_average=3, **kwargs) Bases: :py:obj:`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): :param past_hours_to_average=3: duration of time average window Units are always 'mps' .. py:property:: past_hours_to_average .. py:property:: timeseries .. py:attribute:: _schema .. py:method:: __repr__() Return repr(self). .. py:method:: __str__() Return str(self). .. py:method:: _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 .. py:method:: 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' :param datetime: [optional] datetime object or list of datetime objects for which the value is desired :type datetime: datetime object :returns: numpy array containing dtype=basic_types.datetime_value_2d. Contains user specified datetime and the corresponding values in 'm/s' and 'uv' format .. py:method:: prepare_for_model_run(model_time) Make sure we are up to date with the referenced time series .. py:method:: prepare_for_model_step(model_time) Make sure we are up to date with the referenced time series .. py:method:: create_running_average_timeseries(past_hours_to_average, model_time=0) Creates the timeseries of the RunningAverage object :param past_hours_to_average: amount of data to use in the averaging .. py:method:: 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