Example #1
0
    def test_set_wind_data(self, all_winds):
        """
        get_wind_data with default output format
        """
        # check get_time_value()
        wm = Wind(timeseries=all_winds['wind'].get_wind_data(),
                  coord_sys='r-theta', units='meter per second')
        gtime_val = wm.get_wind_data()
        x = gtime_val[:2]
        x['value'] = [(1, 10), (2, 20)]

        # default format is 'r-theta'
        wm.set_wind_data(x, 'meter per second')

        # only matches to 10^-14
        assert np.allclose(wm.get_wind_data()['value'][:, 0], x['value'][:, 0],
                           rtol=rtol, atol=atol)
        assert np.all(wm.get_wind_data()['time'] == x['time'])
Example #2
0
    def test_set_wind_data(self, all_winds):
        """
        get_wind_data with default output format
        """
        # check get_time_value()

        wm = Wind(timeseries=all_winds['wind'].get_wind_data(),
                  format='r-theta',
                  units='meter per second')
        gtime_val = wm.get_wind_data()
        x = gtime_val[:2]
        x['value'] = [(1, 10), (2, 20)]

        # default format is 'r-theta'
        wm.set_wind_data(x, 'meter per second')

        # only matches to 10^-14
        assert np.allclose(wm.get_wind_data()['value'][:, 0], x['value'][:, 0],
                           atol, rtol)
        assert np.all(wm.get_wind_data()['time'] == x['time'])
Example #3
0
def test_read_file_init():
    """
    initialize from a long wind file
    """

    wind = Wind(filename=file_)
    wm = WindMover(wind)
    wind_ts = wind.get_wind_data(coord_sys='uv', units='meter per second')
    _defaults(wm)  # check defaults set correctly
    assert not wm.make_default_refs
    cpp_timeseries = _get_timeseries_from_cpp(wm)
    _assert_timeseries_equivalence(cpp_timeseries, wind_ts)

    # make sure default units is correct and correctly called
    # NOTE: Following functionality is already tested in test_wind.py,
    #       but what the heck - do it here too.

    wind_ts = wind.get_wind_data(coord_sys=ts_format.uv)
    cpp_timeseries['value'] = uc.convert('Velocity',
                                         'meter per second', wind.units,
                                         cpp_timeseries['value'])

    _assert_timeseries_equivalence(cpp_timeseries, wind_ts)
Example #4
0
def test_read_file_init():
    """
    initialize from a long wind file
    """

    wind = Wind(filename=file_)
    wm = WindMover(wind)
    wind_ts = wind.get_wind_data(coord_sys='uv', units='meter per second')
    _defaults(wm)  # check defaults set correctly
    assert not wm.make_default_refs
    cpp_timeseries = _get_timeseries_from_cpp(wm)
    _assert_timeseries_equivalence(cpp_timeseries, wind_ts)

    # make sure default units is correct and correctly called
    # NOTE: Following functionality is already tested in test_wind.py,
    #       but what the heck - do it here too.

    wind_ts = wind.get_wind_data(coord_sys=ts_format.uv)
    cpp_timeseries['value'] = uc.convert('Velocity',
                                         'meter per second', wind.units,
                                         cpp_timeseries['value'])

    _assert_timeseries_equivalence(cpp_timeseries, wind_ts)