gnome.movers.movers =================== .. py:module:: gnome.movers.movers Classes ------- .. autoapisummary:: gnome.movers.movers.Process gnome.movers.movers.Mover gnome.movers.movers.PyMover gnome.movers.movers.CyMover Module Contents --------------- .. py:class:: Process(on=True, make_default_refs=True, active_range=(InfDateTime('-inf'), InfDateTime('inf')), _automanaged=True, **kwargs) Bases: :py:obj:`gnome.GnomeId` Base class from which all Python movers/weatherers can inherit It defines the base functionality for mover/weatherer. NOTE: Since base class is not Serializable, it does not need a class level _schema attribute. Initialize default Mover/Weatherer parameters All parameters are optional (kwargs) :param on: boolean as to whether the object is on or not. Default is on :param active_range: Range of datetimes for when the mover should be active :type active_range: 2-tuple of datetimes .. py:attribute:: on :value: True .. py:attribute:: make_default_refs :value: True .. py:property:: active .. py:property:: active_range .. py:method:: datetime_to_seconds(model_time) Put the time conversion call here - in case we decide to change it, it only updates here .. py:method:: prepare_for_model_run() Override this method if a derived mover class needs to perform any actions prior to a model run .. py:method:: prepare_for_model_step(sc, time_step, model_time_datetime) Sets active flag based on time_span and on flag. Object is active if the following hold and 'on' is True: 1. active start <= (model_time + time_step/2) so object is on for more than half the time step 2. (model_time + time_step/2) <= active_stop so the object is on for at least half the time step :param sc: an instance of gnome.spill_container.SpillContainer class :param time_step: time step in seconds :param model_time_datetime: current model time as datetime object .. py:method:: model_step_is_done(sc=None) This method gets called by the model after everything else is done in a time step. Put any code needed for clean-up, etc in here in subclassed movers. .. py:method:: post_model_run() Override this method if a derived class needs to perform any actions after a model run is complete (StopIteration triggered) .. py:property:: data_start .. py:property:: data_stop .. py:class:: Mover(on=True, make_default_refs=True, active_range=(InfDateTime('-inf'), InfDateTime('inf')), _automanaged=True, **kwargs) Bases: :py:obj:`Process` Base class from which all Python movers can inherit It defines the base functionality for a mover. Initialize default Mover/Weatherer parameters All parameters are optional (kwargs) :param on: boolean as to whether the object is on or not. Default is on :param active_range: Range of datetimes for when the mover should be active :type active_range: 2-tuple of datetimes .. py:method:: get_move(sc, time_step, model_time_datetime) Compute the move in (long,lat,z) space. It returns the delta move for each element of the spill as a numpy array of size (number_elements X 3) and dtype = gnome.basic_types.world_point_type Base class returns an array of numpy.nan for delta to indicate the get_move is not implemented yet. Each class derived from Mover object must implement its own get_move :param sc: an instance of gnome.spill_container.SpillContainer class :param time_step: time step in seconds :param model_time_datetime: current model time as datetime object All movers must implement get_move() since that's what the model calls .. py:method:: get_bounds() Return a bounding box surrounding the grid data. .. py:class:: PyMover(default_num_method='RK2', **kwargs) Bases: :py:obj:`Mover` Base class for pure Python movers Uses ``super(PyMover, self).__init__(**kwargs)`` to call Mover class __init__ method We assume any derived class will instantiate a 'mover' object that has methods like: prepare_for_model_run, prepare_for_model_step, All kwargs passed on to super class .. py:attribute:: num_methods .. py:attribute:: default_num_method :value: 'RK2' .. py:method:: delta_method(method_name=None) Returns a delta function based on its registered name Usage: ``delta = self.delta_method('RK2')(**kwargs)`` Note: We do not handle any key errors resulting from passing in a bad registered name. .. py:method:: get_delta_Euler(sc, time_step, model_time, pos, vel_field) .. py:method:: get_delta_RK2(sc, time_step, model_time, pos, vel_field) .. py:method:: get_delta_RK4(sc, time_step, model_time, pos, vel_field) .. py:class:: CyMover(**kwargs) Bases: :py:obj:`Mover` Base class for all Cython/C based movers Base class for python wrappers around cython movers. Uses ``super(CyMover, self).__init__(**kwargs)`` to call Mover class __init__ method All cython movers (CyWindMover, CyRandomMover) are instantiated by a derived class, and then contained by this class in the member 'movers'. They will need to extract info from spill object. We assume any derived class will instantiate a 'mover' object that has methods like: prepare_for_model_run, prepare_for_model_step, All kwargs passed on to super class .. py:attribute:: model_time :value: 0 .. py:attribute:: positions .. py:attribute:: delta .. py:attribute:: status_codes .. py:attribute:: spill_type :value: 0 .. py:method:: prepare_for_model_run() Calls the contained cython mover's prepare_for_model_run() .. py:method:: prepare_for_model_step(sc, time_step, model_time_datetime) Default implementation of prepare_for_model_step(...) - Sets the mover's active flag if time is within specified timespan (done in base class Mover) - Invokes the cython mover's prepare_for_model_step :param sc: an instance of gnome.spill_container.SpillContainer class :param time_step: time step in seconds :param model_time_datetime: current model time as datetime object Uses super to invoke Mover class prepare_for_model_step and does a couple more things specific to CyMover. .. py:method:: get_move(sc, time_step, model_time_datetime) Base implementation of Cython wrapped C++ movers. Override for things like the PointWindMover since it has a different implementation :param sc: spill_container.SpillContainer object :param time_step: time step in seconds :param model_time_datetime: current model time as datetime object .. py:method:: prepare_data_for_get_move(sc, model_time_datetime) organizes the spill object into inputs for calling with Cython wrapper's get_move(...) :param sc: an instance of gnome.spill_container.SpillContainer class :param model_time_datetime: current model time as datetime object .. py:method:: model_step_is_done(sc=None) This method gets called by the model after everything else is done in a time step, and is intended to perform any necessary clean-up operations. Subclassed movers can override this method.