Skip to content

Commit

Permalink
Add Canadian Meterological Center Model Support (#76)
Browse files Browse the repository at this point in the history
* First pass at CMC (GDPS/GEPS) client

* Fix typo

* Add regex

* Update tests and add examples

* Fix model name

* Fix renaming and order of regex

* Update Readme

* Fix tests

* Fix mapping

* Fix name splitting

* Update for name

* Add integration tests and address comments

* Add basic options

* Add basic options

* Fix which Client is being used

* Readd init file

* Add space
  • Loading branch information
jacobbieker authored Dec 15, 2023
1 parent 91888e9 commit 8fef095
Show file tree
Hide file tree
Showing 12 changed files with 575 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ currently packaged with adapters for pulling and converting `.grib` data from:
- [CEDA Atmospheric Archive](https://catalogue.ceda.ac.uk)
- [ECMWF MARS API](https://apps.ecmwf.int/mars-catalogue)
- [DWD's ICON Model from the Opendata API](https://opendata.dwd.de)
- [CMC's GDPS Model from the Opendata API](https://dd.weather.gc.ca/)

Similarly, the service can write to multiple sinks:

Expand Down
7 changes: 7 additions & 0 deletions src/nwp_consumer/internal/config/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ class ICONEnv(EnvParser):
ICON_PARAMETER_GROUP: str = "default"


class CMCEnv(EnvParser):
"""Config for CMC API."""

CMC_MODEL: str = "gdps"
CMC_HOURS: int = 240
CMC_PARAMETER_GROUP: str = "full"

# --- Outputs environment variables --- #


Expand Down
5 changes: 3 additions & 2 deletions src/nwp_consumer/internal/inputs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__all__ = ["ceda", "metoffice", "ecmwf", "icon"]
__all__ = ["ceda", "metoffice", "ecmwf", "icon", "cmc"]

from . import (
ceda,
metoffice,
ecmwf,
icon
icon,
cmc,
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions src/nwp_consumer/internal/inputs/cmc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__all__ = ["Client"]

from .client import Client

62 changes: 62 additions & 0 deletions src/nwp_consumer/internal/inputs/cmc/_consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Defines all parameters available from GDPS."""


GDPS_VARIABLES = [
"ALBDO",
"ABSV",
"CWAT",
"TSOIL",
"SOILVIC",
"SOILM",
"SFCWRO",
"CAPE",
"CIN",
"ACPCP",
"DLWRF",
"DSWRF",
"HGT",
"FPRATE",
"IPRATE",
"PCPNTYPE",
"LHTFL",
"NLWRS",
"NSWRS",
"PRATE",
"PRES",
"RH",
"SKINT",
"SDEN",
"SNOD",
"SPRATE",
"SPFH",
"TMP",
"TCDC",
"APCP",
"ULWRF",
"VVEL",
"GUST",
"UGRD",
"VGRD",
]

GEPS_VARIABLES = [
"CAPE",
"CIN",
"HGT",
"ICETK",
"PRES",
"PRMSL",
"PWAT",
"RH",
"SCWRO",
"SNOD",
"SPFH",
"TCDC",
"TMP",
"TSOIL",
"UGRD",
"VGRD",
"WEASD",
"WIND",
"VVEL"
]
22 changes: 22 additions & 0 deletions src/nwp_consumer/internal/inputs/cmc/_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import datetime as dt

from nwp_consumer import internal


class CMCFileInfo(internal.FileInfoModel):
def __init__(
self, it: dt.datetime, filename: str, currentURL: str, step: int,
) -> "CMCFileInfo":
self._it = it
self._filename = filename
self._url = currentURL
self.step = step

def filename(self) -> str:
return self._filename

def filepath(self) -> str:
return self._url + "/" + self._filename

def it(self) -> dt.datetime:
return self._it
Loading

0 comments on commit 8fef095

Please sign in to comment.