diff --git a/nowcasting_dataset/config/model.py b/nowcasting_dataset/config/model.py index 93803c7f..5d4b456f 100644 --- a/nowcasting_dataset/config/model.py +++ b/nowcasting_dataset/config/model.py @@ -126,14 +126,13 @@ def history_seq_length_60_minutes(self): class TimeResolutionMixin(Base): """Time resolution mix in""" - # TODO: Issue #584: Rename to `sample_period_minutes` - time_resolution_minutes: int = Field( + sample_period_minutes: int = Field( 5, description="The temporal resolution (in minutes) of the satellite images." "Note that this needs to be divisible by 5.", ) - @validator("time_resolution_minutes") + @validator("sample_period_minutes") def forecast_minutes_divide_by_5(cls, v): """Validate 'forecast_minutes'""" assert v % 5 == 0, f"The time resolution ({v}) is not divisible by 5" diff --git a/nowcasting_dataset/data_sources/optical_flow/optical_flow_data_source.py b/nowcasting_dataset/data_sources/optical_flow/optical_flow_data_source.py index 1b0dae0b..c023c9fd 100644 --- a/nowcasting_dataset/data_sources/optical_flow/optical_flow_data_source.py +++ b/nowcasting_dataset/data_sources/optical_flow/optical_flow_data_source.py @@ -55,7 +55,7 @@ class OpticalFlowDataSource(DataSource): the input image after it has been "flowed". source_data_source_class_name: Either HRVSatelliteDataSource or SatelliteDataSource. channels: The satellite channels to compute optical flow for. - time_resolution_minutes: time resolution of optical flow images. + sample_period_minutes: time resolution of optical flow images. Needs to be the same as the satellite images used to make the flow fields. """ @@ -65,7 +65,7 @@ class OpticalFlowDataSource(DataSource): meters_per_pixel: int = 2000 output_image_size_pixels: int = 32 source_data_source_class_name: str = "SatelliteDataSource" - time_resolution_minutes: int = 5 + sample_period_minutes: int = 5 def __post_init__(self): # noqa assert self.output_image_size_pixels <= self.input_image_size_pixels, ( @@ -98,7 +98,7 @@ def __post_init__(self): # noqa @property def sample_period_minutes(self) -> int: """Override the default sample minutes""" - return self.time_resolution_minutes + return self.sample_period_minutes def open(self): """Open the underlying self.source_data_source.""" diff --git a/nowcasting_dataset/data_sources/satellite/satellite_data_source.py b/nowcasting_dataset/data_sources/satellite/satellite_data_source.py index 05423213..c7a0a521 100644 --- a/nowcasting_dataset/data_sources/satellite/satellite_data_source.py +++ b/nowcasting_dataset/data_sources/satellite/satellite_data_source.py @@ -32,7 +32,7 @@ class SatelliteDataSource(ZarrDataSource): image_size_pixels: InitVar[int] = 128 meters_per_pixel: InitVar[int] = 2_000 logger = _LOG - time_resolution_minutes: int = 5 + sample_period_minutes: int = 5 def __post_init__(self, image_size_pixels: int, meters_per_pixel: int): """Post Init""" @@ -52,7 +52,7 @@ def __post_init__(self, image_size_pixels: int, meters_per_pixel: int): @property def sample_period_minutes(self) -> int: """Override the default sample minutes""" - return self.time_resolution_minutes + return self.sample_period_minutes def open(self) -> None: """ diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 6aa47c25..12e6f627 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -74,7 +74,7 @@ def test_incorrect_time_resolution(): configuration = Configuration() configuration.input_data = configuration.input_data.set_all_to_defaults() - configuration.input_data.satellite.time_resolution_minutes = 27 + configuration.input_data.satellite.sample_period_minutes = 27 with pytest.raises(Exception): _ = Configuration(**configuration.dict()) diff --git a/tests/data_sources/satellite/test_satellite_data_source.py b/tests/data_sources/satellite/test_satellite_data_source.py index 76965949..28aecd1e 100644 --- a/tests/data_sources/satellite/test_satellite_data_source.py +++ b/tests/data_sources/satellite/test_satellite_data_source.py @@ -145,7 +145,7 @@ def test_geospatial_border(sat_data_source): # noqa: D103 def test_wrong_sample_period(sat_filename): - """Test that a error is raise when the time_resolution_minutes is not divisible by 5""" + """Test that a error is raise when the sample_period_minutes is not divisible by 5""" with pytest.raises(Exception): _ = SatelliteDataSource( image_size_pixels=pytest.IMAGE_SIZE_PIXELS, @@ -154,5 +154,5 @@ def test_wrong_sample_period(sat_filename): forecast_minutes=15, channels=("IR_016",), meters_per_pixel=6000, - time_resolution_minutes=27, + sample_period_minutes=27, )