gnome.movers.movers

Module Contents

Classes

Process

Base class from which all Python movers/weatherers can inherit

Mover

Base class from which all Python movers/weatherers can inherit

PyMover

Base class from which all Python movers/weatherers can inherit

CyMover

Base class from which all Python movers/weatherers can inherit

class gnome.movers.movers.Process(on=True, make_default_refs=True, active_range=(InfDateTime('-inf'), InfDateTime('inf')), _automanaged=True, **kwargs)

Bases: 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)

Parameters:
  • on – boolean as to whether the object is on or not. Default is on

  • active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active

property active
property active_range
property data_start
property data_stop
_check_active_startstop(active_start, active_stop)
datetime_to_seconds(model_time)

Put the time conversion call here - in case we decide to change it, it only updates here

prepare_for_model_run()

Override this method if a derived mover class needs to perform any actions prior to a model run

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.

Parameters:
  • sc – an instance of gnome.spill_container.SpillContainer class

  • time_step – time step in seconds

  • model_time_datetime – current model time as datetime object

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.

post_model_run()

Override this method if a derived class needs to perform any actions after a model run is complete (StopIteration triggered)

class gnome.movers.movers.Mover(on=True, make_default_refs=True, active_range=(InfDateTime('-inf'), InfDateTime('inf')), _automanaged=True, **kwargs)

Bases: 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)

Parameters:
  • on – boolean as to whether the object is on or not. Default is on

  • active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active

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

Parameters:
  • sc – an instance of gnome.spill_container.SpillContainer class

  • time_step – time step in seconds

  • model_time_datetime – current model time as datetime object

All movers must implement get_move() since that’s what the model calls

get_bounds()

Return a bounding box surrounding the grid data.

class gnome.movers.movers.PyMover(default_num_method='RK2', **kwargs)

Bases: 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)

Parameters:
  • on – boolean as to whether the object is on or not. Default is on

  • active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active

_schema
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.

get_delta_Euler(sc, time_step, model_time, pos, vel_field)
get_delta_RK2(sc, time_step, model_time, pos, vel_field)
get_delta_RK4(sc, time_step, model_time, pos, vel_field)
class gnome.movers.movers.CyMover(**kwargs)

Bases: 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

prepare_for_model_run()

Calls the contained cython mover’s prepare_for_model_run()

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

Parameters:
  • sc – an instance of gnome.spill_container.SpillContainer class

  • time_step – time step in seconds

  • 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.

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

Parameters:
  • sc – spill_container.SpillContainer object

  • time_step – time step in seconds

  • model_time_datetime – current model time as datetime object

prepare_data_for_get_move(sc, model_time_datetime)

organizes the spill object into inputs for calling with Cython wrapper’s get_move(…)

Parameters:
  • sc – an instance of gnome.spill_container.SpillContainer class

  • model_time_datetime – current model time as datetime object

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.