Skip to content

Commit

Permalink
refactor(dataset): get rid of magic values
Browse files Browse the repository at this point in the history
  • Loading branch information
wvenialbo committed Oct 25, 2024
1 parent 8fc5319 commit 5f053d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
14 changes: 10 additions & 4 deletions src/GOES_DL/dataset/goes/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,17 @@ class GOESProductLocator(ProductLocatorGG):
# reflectance/brightness [Kelvin] units)
AVAILABLE_LEVELS: set[str] = {"L1b", "L2"}

FULL_DISK = "F"
CONUS = "C"
MESO = "M"
MESO_1 = "M1"
MESO_2 = "M2"

AVAILABLE_SCENES: dict[str, str] = {
"F": "F",
"C": "C",
"M1": "M",
"M2": "M",
FULL_DISK: FULL_DISK,
CONUS: CONUS,
MESO_1: MESO,
MESO_2: MESO,
}

def __init__(
Expand Down
12 changes: 7 additions & 5 deletions src/GOES_DL/dataset/goes/locator_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class GOESProductLocatorABI(GOESProductLocator):
# of Columbia), and “Continental United States” refers to 49 states
# (including Alaska and the District of Columbia).
AVAILABLE_SCENES: dict[str, str] = {
"F": "Full Disk",
"C": "CONUS (Continental United States)",
"M1": "Mesoscale (Domain 1)",
"M2": "Mesoscale (Domain 2)",
GOESProductLocator.FULL_DISK: "Full Disk",
GOESProductLocator.CONUS: "CONUS (Continental United States)",
GOESProductLocator.MESO_1: "Mesoscale (Domain 1)",
GOESProductLocator.MESO_2: "Mesoscale (Domain 2)",
}

# Instrument: Advanced Baseline Imager (ABI).
Expand Down Expand Up @@ -90,7 +90,9 @@ def __init__(
f"Invalid scene ID: '{scene}'. "
f"Available scene IDs: {available_scenes}"
)
scan_modes: list[str] = self.F_MODES if scene == "F" else self.CM_MODES
scan_modes: list[str] = (
self.F_MODES if scene == self.FULL_DISK else self.CM_MODES
)

super().__init__(
name=name,
Expand Down
13 changes: 8 additions & 5 deletions src/GOES_DL/dataset/goes/locator_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ class GOESProductLocatorABIDC(GOESProductLocatorABI):
Product: All derived ABI products supporting channels.
"""

DMW_PRODUCT: str = "DMW"
DMWV_PRODUCT: str = "DMWV"

AVAILABLE_PRODUCTS: dict[str, str] = {
"DMW": "Derived Motion Winds",
"DMWV": "Derived Motion WV Winds",
DMW_PRODUCT: "Derived Motion Winds",
DMWV_PRODUCT: "Derived Motion WV Winds",
}

M_CHANNELS: set[str] = {"C02", "C07", "C08", "C09", "C10"}
Expand Down Expand Up @@ -78,7 +81,7 @@ def __init__(
)

supported_channels: set[str]
if name == "DMW":
if name == self.DMW_PRODUCT:
supported_channels = (
self.CF_CHANNELS
if scene in self.CF_SCENES
Expand Down Expand Up @@ -113,7 +116,7 @@ class GOESProductLocatorDMW(GOESProductLocatorABIDC):
Product: Derived Motion Winds (DMW).
"""

PRODUCT_NAME: str = "DMW"
PRODUCT_NAME: str = GOESProductLocatorABIDC.DMW_PRODUCT

def __init__(
self, scene: str, channels: str | list[str], origin: str
Expand Down Expand Up @@ -168,7 +171,7 @@ class GOESProductLocatorDMWV(GOESProductLocatorABIDC):
Product: Derived Motion WV Winds (DMWV).
"""

PRODUCT_NAME: str = "DMWV"
PRODUCT_NAME: str = GOESProductLocatorABIDC.DMWV_PRODUCT

def __init__(self, scene: str, origin: str) -> None:
"""
Expand Down

0 comments on commit 5f053d9

Please sign in to comment.