gnome.movers¶
__init__.py for the gnome.movers package
Submodules¶
Attributes¶
Classes¶
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
simple_mover |
|
Python wrapper around the Cython wind_mover module. |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
"Random Walk" diffusion mover |
|
"Random Walk" diffusion mover |
|
This mover class inherits from CyMover and contains CyRandomMover3D |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
Base class from which all Python movers/weatherers can inherit |
|
This mover class inherits from CyMover and contains CyRiseVelocityMover |
|
The only thing this adds (so far) |
|
WindMover implemented in Python. Uses the .wind attribute to move particles. |
|
CurrentMover implemented in Python. Uses the .current attribute to move particles. |
Functions¶
|
utility function to create a point wind mover with a constant wind |
|
Creates a wind mover from a wind time-series file (OSM long wind format) |
Package Contents¶
- class gnome.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.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
- on = True¶
- make_default_refs = True¶
- property active¶
- property active_range¶
- 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:
active start <= (model_time + time_step/2) so object is on for more than half the timestep
(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)
- property data_start¶
- property data_stop¶
- class gnome.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__ methodAll 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
- model_time = 0¶
- positions¶
- delta¶
- status_codes¶
- spill_type = 0¶
- 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.
- class gnome.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
- num_methods¶
- default_num_method = 'RK2'¶
- 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.SimpleMover(velocity=0, uncertainty_scale=0.5, **kwargs)¶
Bases:
gnome.movers.Mover
simple_mover
a really simple mover – moves all LEs a constant speed and direction
- (not all that different than a constant wind mover, now that I
think about it)
simple_mover (velocity)
create a simple_mover instance
- Parameters:
velocity – a (u, v, w) triple – in meters per second
uncertainty_scale=0.5 – the scale of the uncertainty of the velocity
Remaining kwargs are passed onto Mover’s __init__ using super. See Mover documentation for remaining valid kwargs.
- velocity¶
- uncertainty_scale = 0.5¶
- get_move(spill, time_step, model_time)¶
moves the particles defined in the spill object
- Parameters:
spill – spill is an instance of the gnome.spills.Spill class
time_step – time_step in seconds
model_time – current model time as a datetime object
In this case, it uses the positions and status_code data arrays.
- Returns delta:
Nx3 numpy array of movement – in (long, lat, meters) units
- class gnome.movers.PointWindMover(wind=None, **kwargs)¶
Bases:
WindMoversBase
Python wrapper around the Cython wind_mover module. This class inherits from CyMover and contains CyWindMover
The real work is done by the CyWindMover object. CyMover sets everything up that is common to all movers.
Uses super to call CyMover base class __init__
- Parameters:
wind – wind object – provides the wind time series for the mover
Remaining kwargs are passed onto WindMoversBase __init__ using super. See Mover documentation for remaining valid kwargs.
Note
Can be initialized with wind=None; however, wind must be set before running. If wind is not None, toggle make_default_refs to False since user provided a valid Wind and does not wish to use the default from the Model.
- mover¶
- property wind¶
- property data_start¶
- property data_stop¶
- prepare_for_model_run()¶
if wind attribute is not set, raise ReferencedObjectNotSet excpetion
- gnome.movers.constant_point_wind_mover(speed, direction, units='m/s')¶
utility function to create a point wind mover with a constant wind
- Parameters:
speed – wind speed
direction – wind direction in degrees true (direction from, following the meteorological convention)
units='m/s' – the units that the input wind speed is in. options: ‘m/s’, ‘knot’, ‘mph’, others…
- Returns:
returns a gnome.movers.WindMover object all set up.
Note
The time for a constant wind timeseries is irrelevant. This function simply sets it to datetime.now() accurate to hours.
- gnome.movers.point_wind_mover_from_file(filename, **kwargs)¶
Creates a wind mover from a wind time-series file (OSM long wind format)
- Parameters:
filename – The full path to the data file
kwargs – All keyword arguments are passed on to the WindMover constructor
- Returns mover:
returns a wind mover, built from the file
- class gnome.movers.c_GridWindMover(filename=None, topology_file=None, extrapolate=False, time_offset=0, **kwargs)¶
Bases:
WindMoversBase
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.
- Parameters:
wind_file – file containing wind data on a grid
filename – file containing wind data on a grid
topology_file – Default is None. When exporting topology, it is stored in this file
wind_scale – Value to scale wind data
extrapolate – Allow current data to be extrapolated before and after file data
time_offset – Time zone shift if data is in GMT
Pass optional arguments to base class uses super:
super(c_GridWindMover,self).__init__(**kwargs)
- mover¶
- name¶
define as property in base class so all objects will have a name by default
- filename = None¶
- topology_file = None¶
- property data_start¶
- property data_stop¶
- wind_scale¶
- extrapolate¶
- time_offset¶
- get_grid_data()¶
- get_cells()¶
Invokes the GetCellDataHdl method of TimeGridWind_c object. Cross-references point data to get cell coordinates.
- get_points()¶
- get_cell_center_points()¶
Right now the cython mover only gets the triangular center points, so we need to calculate centers based on the cells themselves.
Cells will have the format (tl, tr, bl, br) We need to get the rectangular centers Center will be: (tl + ((br - tl) / 2.))
- get_center_points()¶
- get_scaled_velocities(time)¶
- Parameters:
model_time=0
- export_topology(topology_file)¶
- Parameters:
topology_file=None – absolute or relative path where topology file will be written.
- extrapolate_in_time(extrapolate)¶
- Parameters:
extrapolate=false – Allow current data to be extrapolated before and after file data.
- offset_time(time_offset)¶
- Parameters:
offset_time=0 – Allow data to be in GMT with a time zone offset (hours).
- class gnome.movers.IceWindMover(filename=None, topology_file=None, extrapolate=False, time_offset=0, **kwargs)¶
Bases:
WindMoversBase
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 an IceWindMover
- Parameters:
filename – absolute or relative path to the data file: could be netcdf or filelist
topology_file=None – absolute or relative path to topology file. If not given, the IceMover will compute the topology from the data file.
active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active
wind_scale – Value to scale wind data
extrapolate – Allow current data to be extrapolated before and after file data
time_offset – Time zone shift if data is in GMT
uses super,
super(IceWindMover,self).__init__(**kwargs)
- name¶
define as property in base class so all objects will have a name by default
- filename = None¶
- topology_file = None¶
- extrapolate = False¶
- get_grid_data()¶
- get_center_points()¶
- get_scaled_velocities(model_time)¶
- Parameters:
model_time=0
- get_ice_velocities(model_time)¶
- Parameters:
model_time=0
- get_movement_velocities(model_time)¶
- Parameters:
model_time=0
- get_ice_fields(model_time)¶
- Parameters:
model_time=0
- export_topology(topology_file)¶
- Parameters:
topology_file=None – absolute or relative path where topology file will be written.
- extrapolate_in_time(extrapolate)¶
- Parameters:
extrapolate=false – allow current data to be extrapolated before and after file data.
- offset_time(time_offset)¶
- Parameters:
offset_time=0 – allow data to be in GMT with a time zone offset (hours).
- get_offset_time()¶
- Parameters:
offset_time=0 – allow data to be in GMT with a time zone offset (hours).
- class gnome.movers.ShipDriftMover(wind_file=None, topology_file=None, grid_type=1, drift_angle=0, time_offset=0, **kwargs)¶
Bases:
gnome.movers.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.
- Parameters:
wind_file – file containing wind data on a grid
topology_file – Default is None. When exporting topology, it is stored in this file
wind_scale – Value to scale wind data
extrapolate – Allow current data to be extrapolated before and after file data
time_offset – Time zone shift if data is in GMT
Pass optional arguments to base class uses super:
super(ShipDriftMover,self).__init__(**kwargs)
- wind_file = None¶
- topology_file = None¶
- name¶
define as property in base class so all objects will have a name by default
- drift_angle = 0¶
- grid_type = 1¶
- grid¶
- mover¶
- model_time = 0¶
- positions¶
- delta¶
- status_codes¶
- wind_scale¶
- extrapolate¶
- time_offset¶
- export_topology(topology_file)¶
- Parameters:
topology_file=None – absolute or relative path where topology file will be written.
- 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)¶
Call base class method using super Also updates windage for this timestep
- Parameters:
sc – an instance of gnome.spill_container.SpillContainer class
time_step – time step in seconds
model_time_datetime – current time of model as a date time 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
- get_move(sc, time_step, model_time_datetime)¶
Override base class functionality because mover has a different get_move signature
- Parameters:
sc – an instance of the gnome.SpillContainer class
time_step – time step in seconds
model_time_datetime – current time of the model as a date time 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.
- class gnome.movers.RandomMover(diffusion_coef=100000.0, uncertain_factor=2.0, **kwargs)¶
Bases:
gnome.movers.CyMover
“Random Walk” diffusion mover
Moves the elements each time step in a random direction, according to the specified diffusion coefficient.
- Parameters:
diffusion_coef (float or integer in units of cm^2/s) – Diffusion coefficient for random diffusion. Default is 100,000 cm2/sec
uncertain_factor – Uncertainty factor. Default is 2.0
Remaining kwargs are passed onto
gnome.movers.Mover
__init__See Mover documentation for remaining valid kwargs.
- mover¶
- property data_start¶
- property data_stop¶
- property diffusion_coef¶
- property uncertain_factor¶
- class gnome.movers.IceAwareRandomMover(ice_concentration=None, **kwargs)¶
Bases:
RandomMover
“Random Walk” diffusion mover
Moves the elements each time step in a random direction, according to the specified diffusion coefficient.
- Parameters:
diffusion_coef (float or integer in units of cm^2/s) – Diffusion coefficient for random diffusion. Default is 100,000 cm2/sec
uncertain_factor – Uncertainty factor. Default is 2.0
Remaining kwargs are passed onto
gnome.movers.Mover
__init__See Mover documentation for remaining valid kwargs.
- ice_concentration = None¶
- classmethod from_netCDF(filename=None, dataset=None, grid_topology=None, units=None, time=None, ice_concentration=None, grid=None, grid_file=None, data_file=None, **kwargs)¶
- 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
- class gnome.movers.RandomMover3D(vertical_diffusion_coef_above_ml=5, vertical_diffusion_coef_below_ml=0.11, horizontal_diffusion_coef_above_ml=100000, horizontal_diffusion_coef_below_ml=126, mixed_layer_depth=10.0, surface_is_allowed=False, **kwargs)¶
Bases:
gnome.movers.CyMover
This mover class inherits from CyMover and contains CyRandomMover3D
The real work is done by CyRandomMover3D. CyMover sets everything up that is common to all movers.
- Parameters:
vertical_diffusion_coef_above_ml – Vertical diffusion coefficient for random diffusion above the mixed layer. Default is 5 cm2/s
vertical_diffusion_coef_below_ml – Vertical diffusion coefficient for random diffusion below the mixed layer. Default is .11 cm2/s
mixed_layer_depth – Mixed layer depth. Default is 10 meters
horizontal_diffusion_coef_above_ml – Horizontal diffusion coefficient for random diffusion above the mixed layer. Default is 100000 cm2/s
horizontal_diffusion_coef_below_ml – Horizontal diffusion coefficient for random diffusion below the mixed layer. Default is 126 cm2/s
surface_is_allowed – Vertical diffusion will ignore surface particles if this is True. Default is False.
Remaining kwargs are passed onto Mover’s __init__ using super.
See Mover documentation for remaining valid kwargs.
- mover¶
- property horizontal_diffusion_coef_above_ml¶
- property horizontal_diffusion_coef_below_ml¶
- property vertical_diffusion_coef_above_ml¶
- property vertical_diffusion_coef_below_ml¶
- property mixed_layer_depth¶
- property surface_is_allowed¶
- class gnome.movers.CatsMover(filename=None, tide=None, uncertain_duration=48, **kwargs)¶
Bases:
CurrentMoversBase
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.
Uses super to invoke base class __init__ method.
- Parameters:
filename – file containing currents patterns for Cats
Optional parameters (kwargs). Defaults are defined by CyCatsMover object.
- Parameters:
tide – a gnome.environment.Tide object to be attached to CatsMover
scale – a boolean to indicate whether to scale value at reference point or not
scale_value – value used for scaling at reference point
scale_refpoint – reference location (long, lat, z). The scaling applied to all data is determined by scaling the raw value at this location.
uncertain_duration – how often does a given uncertain element gets reset
uncertain_time_delay – when does the uncertainly kick in.
up_cur_uncertain – Scale for uncertainty along the flow
down_cur_uncertain – Scale for uncertainty along the flow
right_cur_uncertain – Scale for uncertainty across the flow
left_cur_uncertain – Scale for uncertainty across the flow
uncertain_eddy_diffusion – Diffusion coefficient for eddy diffusion. Default is 0.
uncertain_eddy_v0 – Default is .1 (Check that this is still used)
Remaining kwargs are passed onto Mover’s __init__ using super. See Mover documentation for remaining valid kwargs.
- mover¶
- up_cur_uncertain¶
- down_cur_uncertain¶
- right_cur_uncertain¶
- left_cur_uncertain¶
- uncertain_eddy_diffusion¶
- uncertain_eddy_v0¶
- scale¶
- scale_value¶
- filename¶
- property ref_scale¶
- property scale_refpoint¶
- property tide¶
- property data_start¶
- property data_stop¶
- get_grid_data()¶
Invokes the GetToplogyHdl method of TriGridVel_c object
- get_center_points()¶
- get_scaled_velocities(model_time)¶
Get file values scaled to ref pt value, with tide applied (if any)
- class gnome.movers.ComponentMover(filename1=None, filename2=None, wind=None, scale_refpoint=None, pat1_angle=0, pat1_speed=10, pat1_speed_units=2, pat1_scale_to_value=0.1, pat2_angle=90, pat2_scale_to_value=0.1, pat2_speed=10, pat2_speed_units=2, scale_by=0, **kwargs)¶
Bases:
CurrentMoversBase
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.
Uses super to invoke base class __init__ method.
- Parameters:
filename – file containing currents for first Cats pattern
Optional parameters (kwargs). Defaults are defined by CyCatsMover object.
- Parameters:
filename – file containing currents for second Cats pattern
wind – A gnome.environment.Wind object to be used to drive the CatsMovers. Will want a warning that mover will not be active without a wind
scale – A boolean to indicate whether to scale value at reference point or not
scale_value – Value used for scaling at reference point
scale_refpoint – Reference location (long, lat, z). The scaling applied to all data is determined by scaling the raw value at this location.
Remaining kwargs are passed onto Mover’s __init__ using super. See Mover documentation for remaining valid kwargs.
- filename1 = None¶
- filename2 = None¶
- mover¶
- scale_by = 0¶
- property scale_refpoint¶
- pat1_angle = 0¶
- pat1_speed = 10¶
- pat1_speed_units = 2¶
- pat1_scale_to_value = 0.1¶
- pat2_angle = 90¶
- pat2_scale_to_value = 0.1¶
- pat2_speed = 10¶
- pat2_speed_units = 2¶
- extrapolate¶
- use_averaged_winds¶
- wind_power_factor¶
- past_hours_to_average¶
- scale_factor_averaged_winds¶
- use_original_scale_factor¶
- property data_start¶
- property data_stop¶
- property wind¶
- get_grid_data()¶
Invokes the GetToplogyHdl method of TriGridVel_c object
- get_center_points()¶
- get_optimize_values(model_time)¶
- get_scaled_velocities(model_time)¶
Get file values scaled to optimized check if pat2 exists
- class gnome.movers.c_GridCurrentMover(filename, topology_file=None, extrapolate=False, time_offset=0, current_scale=1, uncertain_along=0.5, uncertain_across=0.25, uncertain_cross=0.25, num_method='Euler', **kwargs)¶
Bases:
CurrentMoversBase
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 a c_GridCurrentMover
- Parameters:
filename – absolute or relative path to the data file: could be netcdf or filelist
topology_file=None – absolute or relative path to topology file. If not given, the c_GridCurrentMover will compute the topology from the data file.
active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active
current_scale – Value to scale current data
uncertain_duration – how often does a given uncertain element get reset
uncertain_time_delay – when does the uncertainly kick in.
uncertain_cross – Scale for uncertainty perpendicular to the flow
uncertain_along – Scale for uncertainty parallel to the flow
extrapolate – Allow current data to be extrapolated before and after file data
time_offset – Time zone shift if data is in GMT
num_method – Numerical method for calculating movement delta. Default Euler option: Runga-Kutta 4 (RK4)
uses super,
super(c_GridCurrentMover,self).__init__(**kwargs)
- filename¶
- name¶
define as property in base class so all objects will have a name by default
- topology_file = None¶
- current_scale = 1¶
- uncertain_along = 0.5¶
- uncertain_across = 0.25¶
- uncertain_cross = 0.25¶
- property num_method¶
- extrapolate¶
- time_offset¶
- property data_start¶
- property data_stop¶
- property is_data_on_cells¶
- get_grid_data()¶
The main function for getting grid data from the mover
- get_center_points()¶
- get_scaled_velocities(time)¶
- Parameters:
time=0 – model time in integer seconds
- export_topology(topology_file)¶
- Parameters:
topology_file=None – absolute or relative path where topology file will be written.
- extrapolate_in_time(extrapolate)¶
- Parameters:
extrapolate=false – allow current data to be extrapolated before and after file data.
- offset_time(time_offset)¶
- Parameters:
offset_time=0 – allow data to be in GMT with a time zone offset (hours).
- get_offset_time()¶
- Parameters:
offset_time=0 – allow data to be in GMT with a time zone offset (hours).
- get_start_time()¶
:this will be the real_data_start time (seconds).
- get_end_time()¶
:this will be the real_data_stop time (seconds).
- get_num_method()¶
- class gnome.movers.IceMover(filename=None, topology_file=None, current_scale=1, uncertain_along=0.5, uncertain_cross=0.25, extrapolate=False, time_offset=0, **kwargs)¶
Bases:
CurrentMoversBase
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 an IceMover
- Parameters:
filename – absolute or relative path to the data file: could be netcdf or filelist
topology_file=None – absolute or relative path to topology file. If not given, the IceMover will compute the topology from the data file.
active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active
current_scale – Value to scale current data
uncertain_duration – how often does a given uncertain element get reset
uncertain_time_delay – when does the uncertainly kick in.
uncertain_cross – Scale for uncertainty perpendicular to the flow
uncertain_along – Scale for uncertainty parallel to the flow
extrapolate – Allow current data to be extrapolated before and after file data
time_offset – Time zone shift if data is in GMT
uses super,
super(IceMover,self).__init__(**kwargs)
- filename = None¶
- name¶
define as property in base class so all objects will have a name by default
- topology_file = None¶
- extrapolate = False¶
- uncertain_along = 0.5¶
- uncertain_cross = 0.25¶
- current_scale = 1¶
- time_offset¶
- get_grid_data()¶
- get_grid_bounding_box(grid_data=None, box_to_merge=None)¶
Return a bounding box surrounding the grid data.
- Parameters:
grid_data (A sequence of 3-tuples or 4-tuples containing (long, lat) pairs.) – The point data of our grid.
box_to_merge – A bounding box to surround in combination with our grid data. This allows us to pad the bounding box that we generate.
- get_center_points()¶
- get_scaled_velocities(model_time)¶
- Parameters:
model_time=0 – datetime in integer seconds
- get_ice_velocities(model_time)¶
- Parameters:
model_time=0
- get_movement_velocities(model_time)¶
- Parameters:
model_time=0
- get_ice_fields(model_time)¶
- Parameters:
model_time=0
- export_topology(topology_file)¶
- Parameters:
topology_file=None – absolute or relative path where topology file will be written.
- extrapolate_in_time(extrapolate)¶
- Parameters:
extrapolate=false – allow current data to be extrapolated before and after file data.
- offset_time(time_offset)¶
- Parameters:
offset_time=0 – allow data to be in GMT with a time zone offset (hours).
- get_offset_time()¶
- Parameters:
offset_time=0 – allow data to be in GMT with a time zone offset (hours).
- class gnome.movers.CurrentCycleMover(filename=None, topology_file=None, tide=None, **kwargs)¶
Bases:
c_GridCurrentMover
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 a CurrentCycleMover
- Parameters:
filename – Absolute or relative path to the data file: could be netcdf or filelist
topology_file=None – Absolute or relative path to topology file. If not given, the c_GridCurrentMover will compute the topology from the data file.
tide – A gnome.environment.Tide object to be attached to CatsMover
active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active
current_scale – Value to scale current data
uncertain_duration – How often does a given uncertain element get reset
uncertain_time_delay – when does the uncertainly kick in.
uncertain_cross – Scale for uncertainty perpendicular to the flow
uncertain_along – Scale for uncertainty parallel to the flow
extrapolate – Allow current data to be extrapolated before and after file data
time_offset – Time zone shift if data is in GMT
uses super: super(CurrentCycleMover,self).__init__(**kwargs)
- mover¶
- property tide¶
- property data_start¶
- property data_stop¶
- property is_data_on_cells¶
- get_center_points()¶
- get_scaled_velocities(time)¶
- Parameters:
time=0 – datetime in integer seconds
- class gnome.movers.RiseVelocityMover(**kwargs)¶
Bases:
gnome.movers.CyMover
This mover class inherits from CyMover and contains CyRiseVelocityMover
The real work is done by CyRiseVelocityMover. CyMover sets everything up that is common to all movers.
Uses super to invoke base class __init__ method.
Optional parameters (kwargs) used to initialize CyRiseVelocityMover
- Parameters:
water_density – Default is 1020 kg/m3
water_viscosity – Default is 1.e-6
Remaining kwargs are passed onto Mover’s __init__ using super. See Mover documentation for remaining valid kwargs.
- mover¶
- get_move(sc, time_step, model_time_datetime)¶
Override base class functionality because mover has a different get_move signature
- Parameters:
sc – an instance of the gnome.SpillContainer class
time_step – time step in seconds
model_time_datetime – current time of the model as a date time object
- class gnome.movers.TamocRiseVelocityMover(*args, **kwargs)¶
Bases:
RiseVelocityMover
The only thing this adds (so far)
are droplet_diameter and density array types
Uses super to invoke base class __init__ method.
Optional parameters (kwargs) used to initialize CyRiseVelocityMover
- Parameters:
water_density – Default is 1020 kg/m3
water_viscosity – Default is 1.e-6
Remaining kwargs are passed onto Mover’s __init__ using super. See Mover documentation for remaining valid kwargs.
- class gnome.movers.WindMover(wind=None, uncertain_duration=3.0 * 3600, uncertain_time_delay=0, uncertain_speed_scale=2.0, uncertain_angle_scale=0.4, scale_value=1, default_num_method='RK2', filename=None, **kwargs)¶
Bases:
gnome.movers.movers.PyMover
WindMover implemented in Python. Uses the .wind attribute to move particles. The .at() interface is expected on the .wind attribute
Initialize a WindMover :param wind: Environment object representing wind to be
used.
- Parameters:
active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active
scale_value – Value to scale wind data
uncertain_duration – how often does a given uncertain element get reset
uncertain_time_delay – when does the uncertainly kick in.
uncertain_speed_scale – Scale for uncertainty of wind speed
uncertain_angle_scale – Scale for uncertainty of wind angle
num_method – Numerical method for calculating movement delta. Choices:(‘Euler’, ‘RK2’, ‘RK4’) Default: RK2
- wind = None¶
- make_default_refs = False¶
- uncertain_duration = 10800.0¶
- uncertain_time_delay = 0¶
- uncertain_speed_scale = 2.0¶
- uncertain_angle_scale = 0.4¶
- uncertain_diffusion = 0¶
- scale_value = 1¶
- sigma_theta = 0¶
- sigma2 = 0¶
- is_first_step = False¶
- time_uncertainty_was_set = 0¶
- shape = (2,)¶
- uncertainty_list¶
- classmethod from_netCDF(filename=None, scale_value=1, uncertain_duration=3 * 3600, uncertain_time_delay=0, uncertain_speed_scale=2.0, uncertain_angle_scale=0.4, default_num_method='RK2', **kwargs)¶
- property data_start¶
- property data_stop¶
- prepare_for_model_run()¶
reset uncertainty
- prepare_for_model_step(sc, time_step, model_time_datetime)¶
Call base class method using super Also updates windage for this timestep
- Parameters:
sc – an instance of gnome.spill_container.SpillContainer class
time_step – time step in seconds
model_time_datetime – current time of model as a date time object
- model_step_is_done(sc)¶
remove any off map les
- get_bounds()¶
Return a bounding box surrounding the grid data. This function exists because it is part of the top level Mover API
- update_uncertainty(num_les, elapsed_time)¶
update uncertainty
- Parameters:
num_les – the number released so far
elapsed_time – time in seconds since model run started
- update_uncertainty_values(elapsed_time)¶
update uncertainty values
- Parameters:
elapsed_time – time in seconds since model run started
- allocate_uncertainty(num_les)¶
add uncertainty
- Parameters:
num_les – the number of les released so far
- add_uncertainty(deltas, time_step)¶
add uncertainty
- Parameters:
deltas – the movement for the current time step
- get_move(sc, time_step, model_time_datetime, num_method=None)¶
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
- class gnome.movers.CurrentMover(current=None, scale_value=1, uncertain_duration=24 * 3600, uncertain_time_delay=0, uncertain_along=0.5, uncertain_cross=0.25, default_num_method='RK2', filename=None, **kwargs)¶
Bases:
gnome.movers.movers.PyMover
CurrentMover implemented in Python. Uses the .current attribute to move particles. The .at() interface is expected on the .current attribute
Initialize a CurrentMover
- Parameters:
current (Any Current or Current-like that implements the .at() function) – Environment object representing ocean currents to be used.
active_range (2-tuple of datetimes) – Range of datetimes for when the mover should be active
scale_value – Value to scale current data
uncertain_duration – how often does a given uncertain element get reset in seconds
uncertain_time_delay – when does the uncertainly kick in in seconds
uncertain_cross – Scale for uncertainty perpendicular to the flow
uncertain_along – Scale for uncertainty parallel to the flow
default_num_method – Numerical method for calculating movement delta. Choices:(‘Euler’, ‘RK2’, ‘RK4’) Default: RK2
- property filename¶
- current = None¶
- scale_value = 1¶
- uncertain_along = 0.5¶
- uncertain_cross = 0.25¶
- uncertain_duration = 86400¶
- uncertain_time_delay = 0¶
- model_time = 0¶
- spill_type = 0¶
- is_first_step = False¶
- time_uncertainty_was_set = 0¶
- shape = (2,)¶
- classmethod from_netCDF(filename=None, name=None, scale_value=1, uncertain_duration=24 * 3600, uncertain_time_delay=0, uncertain_along=0.5, uncertain_cross=0.25, **kwargs)¶
Function for specifically creating a CurrentMover from a file
- property data_start¶
- property data_stop¶
- get_bounds()¶
Return a bounding box surrounding the grid data. This function exists because it is part of the top level Mover API
- get_move(sc, time_step, model_time_datetime, num_method=None)¶
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
- prepare_for_model_run()¶
reset uncertainty
- prepare_for_model_step(sc, time_step, model_time_datetime)¶
add uncertainty
- model_step_is_done(sc)¶
remove any off map les
- gnome.movers.mover_schemas¶