Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit df4ae7f

Browse files
committed
Merge branch 'main' into issue/135-remove-nwp-temporary
2 parents 92b81f2 + dcba705 commit df4ae7f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
default_language_version:
22
python: python3.9
33

4+
ci:
5+
skip: [pydocstyle, flake8]
6+
47
repos:
58
- repo: https://github.com/pre-commit/pre-commit-hooks
69
rev: v3.4.0

tests/test_manager.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
from datetime import datetime
33
from pathlib import Path
44

5+
import numpy as np
6+
import pandas as pd
7+
58
import nowcasting_dataset
69
from nowcasting_dataset.data_sources.gsp.gsp_data_source import GSPDataSource
10+
from nowcasting_dataset.data_sources.satellite.satellite_data_source import SatelliteDataSource
711
from nowcasting_dataset.manager import Manager
812

913

@@ -44,4 +48,32 @@ def test_load_yaml_configuration(): # noqa: D103
4448
assert isinstance(manager.data_source_which_defines_geospatial_locations, GSPDataSource)
4549

4650

51+
def test_get_daylight_datetime_index():
52+
""" Check that 'manager' gets the correct t0 datetime over nighttime"""
53+
filename = Path(nowcasting_dataset.__file__).parent.parent / "tests" / "data" / "sat_data.zarr"
54+
55+
sat = SatelliteDataSource(
56+
zarr_path=filename,
57+
history_minutes=30,
58+
forecast_minutes=60,
59+
image_size_pixels=64,
60+
meters_per_pixel=2000,
61+
)
62+
63+
manager = Manager()
64+
manager.data_sources = {"sat": sat}
65+
manager.data_source_which_defines_geospatial_locations = sat
66+
t0_datetimes = manager.get_t0_datetimes_across_all_data_sources(freq="5T")
67+
68+
# The testing sat_data.zarr has contiguous data from 12:05 to 18:00.
69+
# nowcasting_datamodule.history_minutes = 30
70+
# nowcasting_datamodule.forecast_minutes = 60
71+
# Daylight ends at 16:20.
72+
# So the expected t0_datetimes start at 12:35 (12:05 + 30 minutes)
73+
# and end at 15:20 (16:20 - 60 minutes)
74+
75+
correct_t0_datetimes = pd.date_range("2019-01-01 12:35", "2019-01-01 15:20", freq="5 min")
76+
np.testing.assert_array_equal(t0_datetimes, correct_t0_datetimes)
77+
78+
4779
# TODO: Issue #322: Test the other Manager methods!

0 commit comments

Comments
 (0)