Ejemplo n.º 1
0
def test_observations_parser_handles_ignored_values(data_dir):
    p = WindObservationsParser(path=data_dir /
                               'observations_recent_FF_akt.zip')
    p.ignored_values = {'wind_direction': ['80']}
    records = list(p.parse())
    assert records[0]['wind_direction'] is None
    assert records[0]['wind_speed'] == 1.6
Ejemplo n.º 2
0
def test_observations_parser_handles_location_changes(data_dir):
    p = WindObservationsParser(
        path=data_dir / 'observations_recent_FF_location_change_akt.zip')
    records = list(p.parse())
    assert is_subset(
        {'lat': 48.8275, 'lon': 12.5597, 'height': 350.5}, records[0])
    assert is_subset(
        {'lat': 50.0, 'lon': 13.0, 'height': 345.0}, records[-1])
Ejemplo n.º 3
0
def test_observations_parser_skips_rows_if_before_cutoff(data_dir):
    p = WindObservationsParser(
        path=data_dir / 'observations_recent_FF_akt.zip')
    with settings(
        MIN_DATE=datetime.datetime(2019, 1, 1, tzinfo=tzutc()),
    ):
        records = list(p.parse())
        assert len(records) == 5
        assert records[0]['timestamp'] == datetime.datetime(
            2019, 4, 20, 21, tzinfo=tzutc())
    with settings(
        MAX_DATE=datetime.datetime(2019, 1, 1, tzinfo=tzutc()),
    ):
        records = list(p.parse())
        assert len(records) == 5
        assert records[-1]['timestamp'] == datetime.datetime(
            2018, 9, 15, 4, tzinfo=tzutc())
Ejemplo n.º 4
0
def test_observations_parser_parses_metadata(data_dir):
    p = WindObservationsParser(
        path=data_dir / 'observations_recent_FF_akt.zip')
    metadata = {
        'observation_type': 'historical',
        'source': (
            'Observations:Recent:produkt_ff_stunde_20180915_20200317_04911.txt'
        ),
        'lat': 48.8275,
        'lon': 12.5597,
        'height': 350.5,
        'dwd_station_id': '04911',
        'wmo_station_id': '10788',
        'station_name': 'Straubing',
    }
    for record in p.parse():
        assert is_subset(metadata, record)
Ejemplo n.º 5
0
def test_observations_parser_handles_missing_values(data_dir):
    p = WindObservationsParser(path=data_dir /
                               'observations_recent_FF_akt.zip')
    records = list(p.parse())
    assert records[5]['wind_direction'] == 90
    assert records[5]['wind_speed'] is None