diff --git a/src/nwp_consumer/cmd/main.py b/src/nwp_consumer/cmd/main.py index 2c63f6ee..cc8b8c50 100644 --- a/src/nwp_consumer/cmd/main.py +++ b/src/nwp_consumer/cmd/main.py @@ -19,9 +19,9 @@ def parse_env() -> Adaptors: model_repository_adaptor: type[ports.ModelRepository] match os.getenv("MODEL_REPOSITORY"): case None | "gfs": - model_repository_adaptor = repositories.NOAAGFSS3ModelRepository + model_repository_adaptor = repositories.NOAAS3ModelRepository case "ceda": - model_repository_adaptor = repositories.CedaMetOfficeGlobalModelRepository + model_repository_adaptor = repositories.CEDAFTPModelRepository case "ecmwf-realtime": model_repository_adaptor = repositories.ECMWFRealTimeS3ModelRepository case _ as model: diff --git a/src/nwp_consumer/internal/repositories/__init__.py b/src/nwp_consumer/internal/repositories/__init__.py index ae396385..7d34747b 100644 --- a/src/nwp_consumer/internal/repositories/__init__.py +++ b/src/nwp_consumer/internal/repositories/__init__.py @@ -24,9 +24,9 @@ """ from .model_repositories import ( - CedaMetOfficeGlobalModelRepository, + CEDAFTPModelRepository, ECMWFRealTimeS3ModelRepository, - NOAAGFSS3ModelRepository, + NOAAS3ModelRepository, ) from .notification_repositories import ( StdoutNotificationRepository, @@ -34,9 +34,9 @@ ) __all__ = [ - "CedaMetOfficeGlobalModelRepository", + "CEDAFTPModelRepository", "ECMWFRealTimeS3ModelRepository", - "NOAAGFSS3ModelRepository", + "NOAAS3ModelRepository", "StdoutNotificationRepository", "DagsterPipesNotificationRepository", ] diff --git a/src/nwp_consumer/internal/repositories/model_repositories/__init__.py b/src/nwp_consumer/internal/repositories/model_repositories/__init__.py index 65e6ae2a..f7e444d3 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/__init__.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/__init__.py @@ -1,10 +1,10 @@ -from .metoffice_global import CedaMetOfficeGlobalModelRepository +from .metoffice_global import CEDAFTPModelRepository from .ecmwf_realtime import ECMWFRealTimeS3ModelRepository -from .noaa_gfs import NOAAGFSS3ModelRepository +from .noaa_gfs import NOAAS3ModelRepository __all__ = [ - "CedaMetOfficeGlobalModelRepository", + "CEDAFTPModelRepository", "ECMWFRealTimeS3ModelRepository", - "NOAAGFSS3ModelRepository", + "NOAAS3ModelRepository", ] diff --git a/src/nwp_consumer/internal/repositories/model_repositories/metoffice_global.py b/src/nwp_consumer/internal/repositories/model_repositories/metoffice_global.py index 0cb63c28..f3aa1de8 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/metoffice_global.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/metoffice_global.py @@ -11,7 +11,7 @@ `this PDF `_. For further details on the repository, see the -`CedaMetOfficeGlobalModelRepository.repository` implementation. +`CEDAFTPModelRepository.repository` implementation. Data discrepancies and corrections ================================== @@ -94,7 +94,7 @@ log = logging.getLogger("nwp-consumer") -class CedaMetOfficeGlobalModelRepository(ports.ModelRepository): +class CEDAFTPModelRepository(ports.ModelRepository): """Repository implementation for the MetOffice global model data.""" url_base: str = "ftp.ceda.ac.uk/badc/ukmo-nwp/data/global-grib" @@ -202,7 +202,7 @@ def _download_and_convert(self, url: str) -> ResultE[list[xr.DataArray]]: @classmethod @override - def authenticate(cls) -> ResultE["CedaMetOfficeGlobalModelRepository"]: + def authenticate(cls) -> ResultE["CEDAFTPModelRepository"]: """Authenticate with the CEDA FTP server. Returns: @@ -283,9 +283,9 @@ def _convert(path: pathlib.Path) -> ResultE[list[xr.DataArray]]: ) try: da: xr.DataArray = ( - CedaMetOfficeGlobalModelRepository._rename_or_drop_vars( + CEDAFTPModelRepository._rename_or_drop_vars( ds=ds, - allowed_parameters=CedaMetOfficeGlobalModelRepository.model().expected_coordinates.variable, + allowed_parameters=CEDAFTPModelRepository.model().expected_coordinates.variable, ) .sel(step=[np.timedelta64(i, "h") for i in range(0, 48, 1)]) .expand_dims(dim={"init_time": [ds["time"].values]}) @@ -296,7 +296,7 @@ def _convert(path: pathlib.Path) -> ResultE[list[xr.DataArray]]: if v not in ["init_time", "step", "latitude", "longitude"] ], ) - .to_dataarray(name=CedaMetOfficeGlobalModelRepository.model().name) + .to_dataarray(name=CEDAFTPModelRepository.model().name) .transpose("init_time", "step", "variable", "latitude", "longitude") # Remove the last value of the longitude dimension as it overlaps with the next file # Reverse the latitude dimension to be in descending order diff --git a/src/nwp_consumer/internal/repositories/model_repositories/noaa_gfs.py b/src/nwp_consumer/internal/repositories/model_repositories/noaa_gfs.py index 5eea48bd..c0e63df5 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/noaa_gfs.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/noaa_gfs.py @@ -23,7 +23,7 @@ log = logging.getLogger("nwp-consumer") -class NOAAGFSS3ModelRepository(ports.ModelRepository): +class NOAAS3ModelRepository(ports.ModelRepository): """Model repository implementation for GFS data stored in S3.""" @staticmethod @@ -115,7 +115,7 @@ def fetch_init_data( @classmethod @override - def authenticate(cls) -> ResultE["NOAAGFSS3ModelRepository"]: + def authenticate(cls) -> ResultE["NOAAS3ModelRepository"]: return Success(cls()) def _download_and_convert(self, url: str) -> ResultE[list[xr.DataArray]]: @@ -226,7 +226,7 @@ def _convert(self, path: pathlib.Path) -> ResultE[list[xr.DataArray]]: processed_das: list[xr.DataArray] = [] for i, ds in enumerate(dss): try: - ds = NOAAGFSS3ModelRepository._rename_or_drop_vars( + ds = NOAAS3ModelRepository._rename_or_drop_vars( ds=ds, allowed_parameters=self.model().expected_coordinates.variable, ) @@ -243,7 +243,7 @@ def _convert(self, path: pathlib.Path) -> ResultE[list[xr.DataArray]]: .rename(name_dict={"time": "init_time"}) .expand_dims(dim="init_time") .expand_dims(dim="step") - .to_dataarray(name=NOAAGFSS3ModelRepository.model().name) + .to_dataarray(name=NOAAS3ModelRepository.model().name) ) da = ( da.drop_vars( diff --git a/src/nwp_consumer/internal/repositories/model_repositories/test_metoffice_global.py b/src/nwp_consumer/internal/repositories/model_repositories/test_metoffice_global.py index 41280637..65799504 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/test_metoffice_global.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/test_metoffice_global.py @@ -8,11 +8,11 @@ from nwp_consumer.internal import entities -from .metoffice_global import CedaMetOfficeGlobalModelRepository +from .metoffice_global import CEDAFTPModelRepository -class TestCedaMetOfficeGlobalModelRepository(unittest.TestCase): - """Test the business methods of the CedaMetOfficeGlobalModelRepository class.""" +class TestCEDAFTPModelRepository(unittest.TestCase): + """Test the business methods of the CEDAFTPModelRepository class.""" @unittest.skipIf( condition="CI" in os.environ, @@ -21,7 +21,7 @@ class TestCedaMetOfficeGlobalModelRepository(unittest.TestCase): def test__download_and_convert(self) -> None: """Test the _download_and_convert method.""" - auth_result = CedaMetOfficeGlobalModelRepository.authenticate() + auth_result = CEDAFTPModelRepository.authenticate() self.assertTrue(is_successful(auth_result), msg=f"Error: {auth_result.failure}") c = auth_result.unwrap() diff --git a/src/nwp_consumer/internal/repositories/model_repositories/test_noaa_gfs.py b/src/nwp_consumer/internal/repositories/model_repositories/test_noaa_gfs.py index bd4e6b0d..e6a23f58 100644 --- a/src/nwp_consumer/internal/repositories/model_repositories/test_noaa_gfs.py +++ b/src/nwp_consumer/internal/repositories/model_repositories/test_noaa_gfs.py @@ -8,7 +8,7 @@ from returns.pipeline import is_successful from ...entities import NWPDimensionCoordinateMap -from .noaa_gfs import NOAAGFSS3ModelRepository +from .noaa_gfs import NOAAS3ModelRepository if TYPE_CHECKING: import xarray as xr @@ -26,7 +26,7 @@ class TestECMWFRealTimeS3ModelRepository(unittest.TestCase): def test__download_and_convert(self) -> None: """Test the _download_and_convert method.""" - c: NOAAGFSS3ModelRepository = NOAAGFSS3ModelRepository.authenticate().unwrap() + c: NOAAS3ModelRepository = NOAAS3ModelRepository.authenticate().unwrap() test_it: dt.datetime = dt.datetime(2024, 10, 24, 12, tzinfo=dt.UTC) test_coordinates: entities.NWPDimensionCoordinateMap = dataclasses.replace( @@ -102,10 +102,10 @@ class TestCase: for t in tests: with self.subTest(name=t.name): - result = NOAAGFSS3ModelRepository._wanted_file( + result = NOAAS3ModelRepository._wanted_file( filename=t.filename, it=test_it, - max_step=max(NOAAGFSS3ModelRepository.model().expected_coordinates.step), + max_step=max(NOAAS3ModelRepository.model().expected_coordinates.step), ) self.assertEqual(result, t.expected) diff --git a/src/test_integration/test_integration.py b/src/test_integration/test_integration.py index fe1854a2..d2d0cae5 100644 --- a/src/test_integration/test_integration.py +++ b/src/test_integration/test_integration.py @@ -11,11 +11,11 @@ class TestIntegration(unittest.TestCase): def test_ceda_metoffice_global_model(self) -> None: c = handlers.CLIHandler( consumer_usecase=services.ConsumerService( - model_repository=repositories.CedaMetOfficeGlobalModelRepository, + model_repository=repositories.CEDAFTPModelRepository, notification_repository=repositories.StdoutNotificationRepository, ), archiver_usecase=services.ArchiverService( - model_repository=repositories.CedaMetOfficeGlobalModelRepository, + model_repository=repositories.CEDAFTPModelRepository, notification_repository=repositories.StdoutNotificationRepository, ), )