gnome.movers.c_wind_movers

Movers using wind as the forcing function

Module Contents

Classes

WindMoversBase

Base class from which all Python movers/weatherers can inherit

PointWindMover

Python wrapper around the Cython wind_mover module.

c_GridWindMover

Base class from which all Python movers/weatherers can inherit

IceWindMover

Base class from which all Python movers/weatherers can inherit

Functions

point_wind_mover_from_file(filename, **kwargs)

Creates a wind mover from a wind time-series file (OSM long wind format)

constant_point_wind_mover(speed, direction[, units])

utility function to create a point wind mover with a constant wind

Attributes

WindMoverSchema

WindMover

class gnome.movers.c_wind_movers.WindMoversBase(uncertain_duration=3, uncertain_time_delay=0, uncertain_speed_scale=2.0, uncertain_angle_scale=0.4, **kwargs)

Bases: gnome.movers.CyMover

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.

This is simply a base class for WindMover and c_GridWindMover for the common properties.

The classes that inherit from this should define the self.mover object correctly so it has the required attributes.

Input args with defaults:

Parameters:
  • uncertain_duration – (seconds) the randomly generated uncertainty array gets recomputed based on ‘uncertain_duration’

  • uncertain_time_delay – when does the uncertainly kick in.

  • uncertain_speed_scale – Scale for uncertainty in wind speed non-dimensional number

  • uncertain_angle_scale – Scale for uncertainty in wind direction. Assumes this is in radians

It calls super in the __init__ method and passes in the optional parameters (kwargs)

property uncertain_duration
property uncertain_time_delay
_schema
uncertain_speed_scale
uncertain_angle_scale
_seconds_to_hours(seconds)
_hours_to_seconds(hours)
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

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

_state_as_str()

Returns a string containing properties of object. This can be called by __repr__ or __str__ to display props

gnome.movers.c_wind_movers.WindMoverSchema
class gnome.movers.c_wind_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.

property wind
property data_start
property data_stop
_schema
_ref_as = 'wind_mover'
_req_refs
__repr__()

Return repr(self).

__str__()

Return str(self).

prepare_for_model_run()

if wind attribute is not set, raise ReferencedObjectNotSet excpetion

gnome.movers.c_wind_movers.WindMover
gnome.movers.c_wind_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

gnome.movers.c_wind_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.

class gnome.movers.c_wind_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)

property data_start
property data_stop
_schema
wind_scale
extrapolate
time_offset
__repr__()
__str__()

Return str(self).

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.c_wind_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)

_schema
__repr__()

Return repr(self).

__str__()

Return str(self).

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