Пример #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'])
Пример #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'])
Пример #3
0
    Test TypeError thrown if units are not given - so they are None
    """
    # valid timeseries for testing

    dtv = np.zeros((4, ), dtype=datetime_value_2d).view(dtype=np.recarray)
    dtv.time = [datetime(2012, 11, 06, 20, 10 + i, 30,) for i in range(4)]
    dtv.value = (1, 0)

    # exception raised since no units given for timeseries during init
    with raises(TypeError):
        Wind(timeseries=dtv)

    # no units during set_timeseries
    with raises(TypeError):
        wind = Wind(timeseries=dtv, units='meter per second')
        wind.set_wind_data(dtv)

    # invalid units
    with raises(unit_conversion.InvalidUnitError):
        Wind(timeseries=dtv, units='met per second')


def test_read_file_init():
    """
    initialize from a long wind file
    """
    wm = Wind(filename=wind_file)
    print
    print '----------------------------------'
    print 'Units: ' + str(wm.units)
    assert True
Пример #4
0
        11,
        06,
        20,
        10 + i,
        30,
    ) for i in range(4)]
    dtv.value = (1, 0)

    # exception raised since no units given for timeseries during init
    with raises(TypeError):
        Wind(timeseries=dtv)

    # no units during set_timeseries
    with raises(TypeError):
        wind = Wind(timeseries=dtv, units='meter per second')
        wind.set_wind_data(dtv)

    # invalid units
    with raises(unit_conversion.InvalidUnitError):
        Wind(timeseries=dtv, units='met per second')


def test_read_file_init():
    """
    initialize from a long wind file
    """
    wm = Wind(filename=wind_file)

    # have to test something:
    assert wm.units == 'knots'