:py:mod:`gnome.movers.movers` ============================= .. py:module:: gnome.movers.movers Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.movers.movers.Process gnome.movers.movers.Mover gnome.movers.movers.PyMover gnome.movers.movers.CyMover .. 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:property:: active .. py:property:: active_range .. py:property:: data_start .. py:property:: data_stop .. py:method:: _check_active_startstop(active_start, active_stop) .. 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 following hold and 'on' is True: 1. active start <= (model_time + time_step/2) so object is on for more than half the timestep 2. (model_time + time_step/2) <= active_stop so again the object is on for at least half the time step flag to true. :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 when after everything else is done in a time step. Put any code need 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: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/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: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 it's 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 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:: _schema .. 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 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. 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 assumes 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: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.