From 3c1f4725c11946aea0edc7e10aa9bbc1b1f83a4e Mon Sep 17 00:00:00 2001 From: Calum Meikle Date: Fri, 11 Oct 2024 16:39:45 +0200 Subject: [PATCH 1/2] Introduced a new kwarg for config_file so the user can pass their own config file --- .gitignore | 1 + mapies/tropomi.py | 12 +++++++++--- mapies/viirs.py | 12 ++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c4a11ce9..9f304173 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .obsidian *.orig +out-logs __pycache__ grids/__pycache__ util/__pycache__ diff --git a/mapies/tropomi.py b/mapies/tropomi.py index acba956b..888a1396 100644 --- a/mapies/tropomi.py +++ b/mapies/tropomi.py @@ -28,7 +28,7 @@ class TROPOMI(MAPIES): self.time_orig = np.datetime64("1993-01-01T00:00:00") self.lat=lat self.lon=lon - self.quality_flag_limit + #self.quality_flag_limit # Add quality value filter number @@ -49,8 +49,14 @@ class TROPOMI(MAPIES): Read yaml config file """ module_dir = os.path.dirname(__file__) - config = yaml.safe_load(open(os.path.join(module_dir, "config/satellite_config.yaml"))) - print(config) + if config_file: + try: + config = yaml.safe_load(open(config_file)) + except FileNotFoundError: + logging.error("This is not a config file") + else: + config = yaml.safe_load(open(os.path.join(module_dir, "config/satellite_config.yaml"))) + variable_dict = config[self.datatype]["variables"] self.time_var = variable_dict["time_variable"] self.lon_var = variable_dict["lon_variable"] diff --git a/mapies/viirs.py b/mapies/viirs.py index 72275ce7..5c0db334 100644 --- a/mapies/viirs.py +++ b/mapies/viirs.py @@ -65,7 +65,15 @@ class VIIRS(MAPIES): Read yaml config file """ module_dir = os.path.dirname(__file__) - config = yaml.safe_load(open(os.path.join(module_dir, "config/satellite_config.yaml"))) + # Let the user read in their own config + config_file = kwargs.get("config_file") + if config_file: + try: + config = yaml.safe_load(open(config_file)) + except FileNotFoundError: + logging.error("This is not a config file") + else: + config = yaml.safe_load(open(os.path.join(module_dir, "config/satellite_config.yaml"))) variable_dict = config[self.datatype]["variables"] self.time_var = variable_dict["time_variable"] @@ -88,7 +96,7 @@ class VIIRS(MAPIES): self.unc_const = unc_const else: self.unc_const = da_dict["uncertainty_constants"] #float, int, list, dict - print(self.unc_const) + grid_repr = kwargs.get("grid_repr") if grid_repr: -- GitLab From ffc8f11c65611aa71edd3156e6b1ac0ab031efee Mon Sep 17 00:00:00 2001 From: Calum Meikle Date: Mon, 14 Oct 2024 16:03:49 +0200 Subject: [PATCH 2/2] Comments and version --- mapies/config/satellite_config.yaml | 5 +++-- setup.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mapies/config/satellite_config.yaml b/mapies/config/satellite_config.yaml index 0e6b54b5..fed6c4fc 100644 --- a/mapies/config/satellite_config.yaml +++ b/mapies/config/satellite_config.yaml @@ -1,11 +1,12 @@ version: 1 +# Default config, but the user can take this template and create their own or just pass individual variables viirs: variables: time_variable: "Scan_Start_Time" lon_variable: "Longitude" lat_variable: "Latitude" - obs_variable: "Aerosol_Optical_Thickness_550_Land_Ocean_Best_Estimate" # Should be able to update this if needed + obs_variable: "Aerosol_Optical_Thickness_550_Land_Ocean_Best_Estimate" da: obsid: 34 uncertainty_constants: [0.2, 0.05, 0.02] @@ -16,7 +17,7 @@ tropomi: time_variable: "delta_time" lon_variable: "longitude" lat_variable: "latitude" - obs_variable: "nitrogendioxide_tropospheric_column" # Should be able to update this if needed + obs_variable: "nitrogendioxide_tropospheric_column" diff --git a/setup.py b/setup.py index beb6d1ae..8784c08d 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages from setuptools import setup # Could update this using versioneer -version="0.0.1" +version="0.0.2" setup( name="mapies", -- GitLab