:py:mod:`gnome.movers.c_wind_movers` ==================================== .. py:module:: gnome.movers.c_wind_movers .. autoapi-nested-parse:: Movers using wind as the forcing function Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: gnome.movers.c_wind_movers.WindMoversBase gnome.movers.c_wind_movers.PointWindMover gnome.movers.c_wind_movers.c_GridWindMover gnome.movers.c_wind_movers.IceWindMover Functions ~~~~~~~~~ .. autoapisummary:: gnome.movers.c_wind_movers.point_wind_mover_from_file gnome.movers.c_wind_movers.constant_point_wind_mover Attributes ~~~~~~~~~~ .. autoapisummary:: gnome.movers.c_wind_movers.WindMoverSchema gnome.movers.c_wind_movers.WindMover .. py:class:: WindMoversBase(uncertain_duration=3, uncertain_time_delay=0, uncertain_speed_scale=2.0, uncertain_angle_scale=0.4, **kwargs) Bases: :py:obj:`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: :param uncertain_duration: (seconds) the randomly generated uncertainty array gets recomputed based on 'uncertain_duration' :param uncertain_time_delay: when does the uncertainly kick in. :param uncertain_speed_scale: Scale for uncertainty in wind speed non-dimensional number :param 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) .. py:property:: uncertain_duration .. py:property:: uncertain_time_delay .. py:attribute:: _schema .. py:attribute:: uncertain_speed_scale .. py:attribute:: uncertain_angle_scale .. py:method:: _seconds_to_hours(seconds) .. py:method:: _hours_to_seconds(hours) .. py:method:: prepare_for_model_step(sc, time_step, model_time_datetime) Call base class method using super Also updates windage for this timestep :param sc: an instance of gnome.spill_container.SpillContainer class :param time_step: time step in seconds :param model_time_datetime: current time of model as a date time object .. py:method:: get_move(sc, time_step, model_time_datetime) Override base class functionality because mover has a different get_move signature :param sc: an instance of the gnome.SpillContainer class :param time_step: time step in seconds :param model_time_datetime: current time of the model as a date time object .. py:method:: _state_as_str() Returns a string containing properties of object. This can be called by __repr__ or __str__ to display props .. py:data:: WindMoverSchema .. py:class:: PointWindMover(wind=None, **kwargs) Bases: :py:obj:`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__ :param 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. .. py:property:: wind .. py:property:: data_start .. py:property:: data_stop .. py:attribute:: _schema .. py:attribute:: _ref_as :value: 'wind_mover' .. py:attribute:: _req_refs .. py:method:: __repr__() Return repr(self). .. py:method:: __str__() Return str(self). .. py:method:: prepare_for_model_run() if wind attribute is not set, raise ReferencedObjectNotSet excpetion .. py:data:: WindMover .. py:function:: point_wind_mover_from_file(filename, **kwargs) Creates a wind mover from a wind time-series file (OSM long wind format) :param filename: The full path to the data file :param kwargs: All keyword arguments are passed on to the WindMover constructor :returns mover: returns a wind mover, built from the file .. py:function:: constant_point_wind_mover(speed, direction, units='m/s') utility function to create a point wind mover with a constant wind :param speed: wind speed :param direction: wind direction in degrees true (direction from, following the meteorological convention) :param units='m/s': the units that the input wind speed is in. options: 'm/s', 'knot', 'mph', others... :return: 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. .. py:class:: c_GridWindMover(filename=None, topology_file=None, extrapolate=False, time_offset=0, **kwargs) Bases: :py:obj:`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. :param wind_file: file containing wind data on a grid :param filename: file containing wind data on a grid :param topology_file: Default is None. When exporting topology, it is stored in this file :param wind_scale: Value to scale wind data :param extrapolate: Allow current data to be extrapolated before and after file data :param time_offset: Time zone shift if data is in GMT Pass optional arguments to base class uses super: ``super(c_GridWindMover,self).__init__(**kwargs)`` .. py:property:: data_start .. py:property:: data_stop .. py:attribute:: _schema .. py:attribute:: wind_scale .. py:attribute:: extrapolate .. py:attribute:: time_offset .. py:method:: __repr__() .. todo:: We probably want to include more information. .. py:method:: __str__() Return str(self). .. py:method:: get_grid_data() .. py:method:: get_cells() Invokes the GetCellDataHdl method of TimeGridWind_c object. Cross-references point data to get cell coordinates. .. py:method:: get_points() .. py:method:: 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.)) .. py:method:: get_center_points() .. py:method:: get_scaled_velocities(time) :param model_time=0: .. py:method:: export_topology(topology_file) :param topology_file=None: absolute or relative path where topology file will be written. .. py:method:: extrapolate_in_time(extrapolate) :param extrapolate=false: Allow current data to be extrapolated before and after file data. .. py:method:: offset_time(time_offset) :param offset_time=0: Allow data to be in GMT with a time zone offset (hours). .. py:class:: IceWindMover(filename=None, topology_file=None, extrapolate=False, time_offset=0, **kwargs) Bases: :py:obj:`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 :param filename: absolute or relative path to the data file: could be netcdf or filelist :param topology_file=None: absolute or relative path to topology file. If not given, the IceMover will compute the topology from the data file. :param active_range: Range of datetimes for when the mover should be active :type active_range: 2-tuple of datetimes :param wind_scale: Value to scale wind data :param extrapolate: Allow current data to be extrapolated before and after file data :param time_offset: Time zone shift if data is in GMT uses super, ``super(IceWindMover,self).__init__(**kwargs)`` .. py:attribute:: _schema .. py:method:: __repr__() Return repr(self). .. py:method:: __str__() Return str(self). .. py:method:: get_grid_data() .. py:method:: get_center_points() .. py:method:: get_scaled_velocities(model_time) :param model_time=0: .. py:method:: get_ice_velocities(model_time) :param model_time=0: .. py:method:: get_movement_velocities(model_time) :param model_time=0: .. py:method:: get_ice_fields(model_time) :param model_time=0: .. py:method:: export_topology(topology_file) :param topology_file=None: absolute or relative path where topology file will be written. .. py:method:: extrapolate_in_time(extrapolate) :param extrapolate=false: allow current data to be extrapolated before and after file data. .. py:method:: offset_time(time_offset) :param offset_time=0: allow data to be in GMT with a time zone offset (hours). .. py:method:: get_offset_time() :param offset_time=0: allow data to be in GMT with a time zone offset (hours).