예제 #1
0
def test_multipoint_weather():
    """Test multipoint coverage parser for weather station data."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse("fmi::observations::weather::multipointcoverage",
                             args=ARGS)
    latest = max(res.data.keys())
    assert isinstance(latest, dt.datetime)
    data = res.data[latest]

    # Take the first location by alphabetic name
    loc = min(data.keys())
    assert isinstance(loc, str)
    loc_data = data[loc]

    # Every measurement should have a value and unit
    for measurement in loc_data.keys():
        assert "value" in loc_data[measurement]
        assert "units" in loc_data[measurement]

    # Check that location metadata are available
    meta = res.location_metadata[loc]
    assert isinstance(meta["fmisid"], int)
    assert isinstance(meta["latitude"], float)
    assert isinstance(meta["longitude"], float)

    # Make sure the times are within the specified time frame
    start_time = min(res.data.keys())
    end_time = max(res.data.keys())
    assert start_time >= START_TIME
    assert end_time <= END_TIME
예제 #2
0
def test_multipoint_radionuclide():
    """Test multipoint coverage parser for radionuclide data."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse(
        "stuk::observations::air::radionuclide-activity-concentration::latest::multipointcoverage",
        args=ARGS)

    latest = max(res.data.keys())
    assert isinstance(latest, dt.datetime)
    data = res.data[latest]

    # Take the first location by alphabetic name
    loc = min(data.keys())
    assert isinstance(loc, str)
    loc_data = data[loc]

    # Every measurement should have a value and unit
    for measurement in loc_data.keys():
        assert "value" in loc_data[measurement]
        assert "units" in loc_data[measurement]

    # Check that location metadata are available
    meta = res.location_metadata[loc]
    assert isinstance(meta["fmisid"], int)
    assert isinstance(meta["latitude"], float)
    assert isinstance(meta["longitude"], float)
예제 #3
0
def test_multipoint_mareograph_default():
    """Test multipoint coverage parser for default query of mareograph data."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse(
        "fmi::observations::mareograph::multipointcoverage")
    _verify_multipoint_common(res)
예제 #4
0
def test_multipoint_radionuclide():
    """Test multipoint coverage parser for radionuclide data."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse(
        "stuk::observations::air::radionuclide-activity-concentration::latest::multipointcoverage",
        args=ARGS)
    _verify_multipoint_common(res)
예제 #5
0
def test_old_multipoint_daily_weather():
    """Test multipoint coverage parser for daily weather station data for pre-1970s."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse(
        "fmi::observations::weather::daily::multipointcoverage", args=ARGS_OLD)
    # Make sure the times are within the specified time frame
    start_time = min(res.data.keys())
    end_time = max(res.data.keys())
    assert start_time >= START_TIME_OLD
    assert end_time <= END_TIME_OLD
예제 #6
0
def test_multipoint_weather():
    """Test multipoint coverage parser for weather station data."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse("fmi::observations::weather::multipointcoverage",
                             args=ARGS)
    _verify_multipoint_common(res)

    # Make sure the times are within the specified time frame
    start_time = min(res.data.keys())
    end_time = max(res.data.keys())
    assert start_time >= START_TIME
    assert end_time <= END_TIME
예제 #7
0
def test_multipoint_weather_timeseries():
    """Test multipoint coverage parser for weather station data in timeseries mode."""
    from fmiopendata.multipoint import download_and_parse

    res = download_and_parse("fmi::observations::weather::multipointcoverage",
                             args=ARGS_TIMESERIES)

    for loc in res.location_metadata:
        assert "fmisid" in res.location_metadata[loc]
        assert "latitude" in res.location_metadata[loc]
        assert "longitude" in res.location_metadata[loc]

    for loc in res.data:
        len_times = len(res.data[loc]["times"])
        for measurement in res.data[loc]:
            if measurement == "times":
                continue
            assert len(res.data[loc][measurement]["values"]) == len_times
            assert "unit" in res.data[loc][measurement]