From 8bf21df2de0474ecfe3ab5be2bcd359f06e50076 Mon Sep 17 00:00:00 2001 From: Rishi Kumar Ray Date: Thu, 27 Jan 2022 15:01:15 +0530 Subject: [PATCH 1/2] changed-sample_period_minutes --- nowcasting_dataset/config/model.py | 4 ++-- .../data_sources/optical_flow/optical_flow_data_source.py | 6 +++--- .../data_sources/satellite/satellite_data_source.py | 4 ++-- tests/config/test_config.py | 2 +- tests/data_sources/satellite/test_satellite_data_source.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nowcasting_dataset/config/model.py b/nowcasting_dataset/config/model.py index 680e89ce..fcab6651 100644 --- a/nowcasting_dataset/config/model.py +++ b/nowcasting_dataset/config/model.py @@ -126,13 +126,13 @@ def history_seq_length_60_minutes(self): class TimeResolutionMixin(Base): """Time resolution mix in""" - time_resolution_minutes: int = Field( + sample_period_minutes: int = Field( 15, 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 209bc93a..ef2fbad7 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 = 15 + sample_period_minutes: int = 15 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 6ae57f62..1a1dbb1c 100644 --- a/nowcasting_dataset/data_sources/satellite/satellite_data_source.py +++ b/nowcasting_dataset/data_sources/satellite/satellite_data_source.py @@ -28,7 +28,7 @@ class SatelliteDataSource(ZarrDataSource): image_size_pixels: InitVar[int] = 128 meters_per_pixel: InitVar[int] = 2_000 logger = _LOG - time_resolution_minutes: int = 15 + sample_period_minutes: int = 15 def __post_init__(self, image_size_pixels: int, meters_per_pixel: int): """Post Init""" @@ -47,7 +47,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 d1dcf479..b9f9afd8 100644 --- a/tests/data_sources/satellite/test_satellite_data_source.py +++ b/tests/data_sources/satellite/test_satellite_data_source.py @@ -133,7 +133,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, @@ -142,5 +142,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, ) From b51abb4ea8435109320345f6e82f621caa9e4e1b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 27 Jan 2022 12:13:40 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../data_sources/optical_flow/optical_flow_data_source.py | 1 - .../data_sources/satellite/satellite_data_source.py | 1 - 2 files changed, 2 deletions(-) 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 522ebb93..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 @@ -67,7 +67,6 @@ class OpticalFlowDataSource(DataSource): source_data_source_class_name: str = "SatelliteDataSource" sample_period_minutes: int = 5 - def __post_init__(self): # noqa assert self.output_image_size_pixels <= self.input_image_size_pixels, ( "output_image_size_pixels must be equal to or smaller than input_image_size_pixels" diff --git a/nowcasting_dataset/data_sources/satellite/satellite_data_source.py b/nowcasting_dataset/data_sources/satellite/satellite_data_source.py index 8c774443..c7a0a521 100644 --- a/nowcasting_dataset/data_sources/satellite/satellite_data_source.py +++ b/nowcasting_dataset/data_sources/satellite/satellite_data_source.py @@ -34,7 +34,6 @@ class SatelliteDataSource(ZarrDataSource): logger = _LOG sample_period_minutes: int = 5 - def __post_init__(self, image_size_pixels: int, meters_per_pixel: int): """Post Init""" assert len(self.channels) > 0, "channels cannot be empty!"