Example #1
0
    def test_set_timeseries(self, all_winds):
        """
        get_timeseries with default output format
        """

        # check get_time_value()

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

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

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

    wind = Wind(filename=file_)
    wm = WindMover(wind)
    wind_ts = wind.get_timeseries(format='uv', units='meter per second')
    _defaults(wm)  # check defaults set correctly
    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_timeseries(format=ts_format.uv)
    cpp_timeseries['value'] = unit_conversion.convert('Velocity',
                                                      'meter per second',
                                                      wind.units,
                                                      cpp_timeseries['value'])

    _assert_timeseries_equivalence(cpp_timeseries, wind_ts)