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

Description
Detailed Description
This was ripped out of test_datamodule.py before it was deleted in PR #307
@pytest.fixture
def nowcasting_datamodule(sat_filename: Path):
return datamodule.NowcastingDataModule(sat_filename=sat_filename)
def test_get_daylight_datetime_index(
nowcasting_datamodule: datamodule.NowcastingDataModule, use_cloud_data: bool
):
nowcasting_datamodule.prepare_data()
nowcasting_datamodule.t0_datetime_freq = "5T"
t0_datetimes = nowcasting_datamodule._get_t0_datetimes_across_all_data_sources()
assert isinstance(t0_datetimes, pd.DatetimeIndex)
if not use_cloud_data:
# The testing sat_data.zarr has contiguous data from 12:05 to 18:00.
# nowcasting_datamodule.history_minutes = 30
# nowcasting_datamodule.forecast_minutes = 60
# Daylight ends at 16:20.
# So the expected t0_datetimes start at 12:35 (12:05 + 30 minutes)
# and end at 15:20 (16:20 - 60 minutes)
print(t0_datetimes)
correct_t0_datetimes = pd.date_range("2019-01-01 12:35", "2019-01-01 15:20", freq="5 min")
np.testing.assert_array_equal(t0_datetimes, correct_t0_datetimes)