From 5f053d9d02205ad180446acaecb8d5400f8cf930 Mon Sep 17 00:00:00 2001 From: wvenialbo Date: Fri, 25 Oct 2024 05:42:49 -0300 Subject: [PATCH] refactor(dataset): get rid of magic values --- src/GOES_DL/dataset/goes/locator.py | 14 ++++++++++---- src/GOES_DL/dataset/goes/locator_abi.py | 12 +++++++----- src/GOES_DL/dataset/goes/locator_dc.py | 13 ++++++++----- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/GOES_DL/dataset/goes/locator.py b/src/GOES_DL/dataset/goes/locator.py index ab317b0..d0ac6a3 100644 --- a/src/GOES_DL/dataset/goes/locator.py +++ b/src/GOES_DL/dataset/goes/locator.py @@ -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__( diff --git a/src/GOES_DL/dataset/goes/locator_abi.py b/src/GOES_DL/dataset/goes/locator_abi.py index 92eebf5..c22dc11 100644 --- a/src/GOES_DL/dataset/goes/locator_abi.py +++ b/src/GOES_DL/dataset/goes/locator_abi.py @@ -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). @@ -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, diff --git a/src/GOES_DL/dataset/goes/locator_dc.py b/src/GOES_DL/dataset/goes/locator_dc.py index 85b3cbb..63fc86e 100644 --- a/src/GOES_DL/dataset/goes/locator_dc.py +++ b/src/GOES_DL/dataset/goes/locator_dc.py @@ -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"} @@ -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 @@ -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 @@ -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: """