Example #1
0
def constant_wind_mover(speed, direction, units='m/s'):
    """
    utility function to create a 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.   
    """

    series = np.zeros((1, ), dtype=datetime_value_2d)

    # note: if there is ony one entry, the time is arbitrary
    dt = datetime.now().replace(microsecond=0, second=0, minute=0)
    series[0] = (dt, (speed, direction))
    wind = environment.Wind(timeseries=series, units=units)
    w_mover = WindMover(wind)
    return w_mover
Example #2
0
def 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
    """
    w = environment.Wind(filename=filename, format='r-theta')

    return WindMover(w, **kwargs)
Example #3
0
def wind_circ(wind_timeseries):
    """
    Create Wind object using the time series given by test fixture 'rq_wind'
    'wind' object where timeseries is defined as:
         - 'time' defined by: [datetime(2012,11,06,20,10+i,0)
            for i in range(len(dtv_rq))]
         - 'value' defined by: (r,theta) values ferom rq_wind fixtures, units
            are 'm/s'

    :returns: a dict containing following three keys: 'wind', 'rq', 'uv'
              'wind' object, timeseries in (r,theta) format 'rq', timeseries in
              (u,v) format 'uv'.
    """

    from gnome import environment
    dtv_rq = wind_timeseries['rq']
    wm = environment.Wind(timeseries=dtv_rq, format='r-theta',
                          units='meter per second')

    return {'wind': wm, 'rq': dtv_rq, 'uv': wind_timeseries['uv']}
Example #4
0
    assert unknown not in refs  # check __contains__


'''
Run the following save/load test on multiple pygnome objects so collect tests
here and parametrize it by the objects
'''

base_dir = os.path.dirname(__file__)

# For WindMover test_save_load in test_wind_mover
g_objects = (
    environment.environment_objects.GridCurrent.from_netCDF(
        testdata['GridCurrentMover']['curr_tri']),
    environment.Tide(testdata['CatsMover']['tide']),
    environment.Wind(filename=testdata['ComponentMover']['wind']),
    environment.Wind(timeseries=(sec_to_date(24 * 60 * 60), (0, 0)),
                     units='mps'),
    environment.Water(temperature=273),
    movers.random_movers.RandomMover(),
    movers.CatsMover(testdata['CatsMover']['curr']),
    movers.CatsMover(testdata['CatsMover']['curr'],
                     tide=environment.Tide(testdata['CatsMover']['tide'])),
    movers.ComponentMover(testdata['ComponentMover']['curr']),
    movers.ComponentMover(
        testdata['ComponentMover']['curr'],
        wind=environment.Wind(filename=testdata['ComponentMover']['wind'])),
    movers.RandomVerticalMover(),
    movers.SimpleMover(velocity=(10.0, 10.0, 0.0)),
    map.MapFromBNA(testdata['MapFromBNA']['testmap'], 6),
    outputters.NetCDFOutput(os.path.join(base_dir, u'xtemp.nc')),