Skip to content

Commit

Permalink
get_obs_entry returns ObsEntry instance, not a dict
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisblake committed Oct 6, 2024
1 parent aee0fdb commit 88a7c45
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pyaerocom/aeroval/_processing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _get_diurnal_only(self, obs_name):
-------
diurnal_only : bool
"""
return self.cfg.get_obs_entry(obs_name).get("diurnal_only", False)
return self.cfg.get_obs_entry(obs_name).diurnal_only

def get_colocator(self, model_name: str = None, obs_name: str = None) -> Colocator:
"""
Expand Down Expand Up @@ -132,7 +132,7 @@ def get_colocator(self, model_name: str = None, obs_name: str = None) -> Colocat
col_cfg["obs_config"] = pyaro_config

# Hack and at what lowlevel_helpers's import_from was doing
for key, val in obs_cfg.items():
for key, val in obs_cfg.model_dump().items():
if key in ColocationSetup.model_fields:
col_cfg[key] = val

Expand Down
12 changes: 6 additions & 6 deletions pyaerocom/aeroval/experiment_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _run_single_entry(self, model_name, obs_name, var_list):
logger.info(msg)
return
ocfg = self.cfg.get_obs_entry(obs_name)
if ocfg["is_superobs"]:
if ocfg.is_superobs:
try:
engine = SuperObsEngine(self.cfg)
engine.run(
Expand All @@ -47,19 +47,19 @@ def _run_single_entry(self, model_name, obs_name, var_list):
if self.raise_exceptions:
raise
logger.warning("failed to process superobs...")
elif ocfg["only_superobs"]:
elif ocfg.only_superobs:
logger.info(
f"Skipping json processing of {obs_name}, as this is "
f"marked to be used only as part of a superobs "
f"network"
)
elif ocfg["only_json"]:
if not ocfg["coldata_dir"]:
elif ocfg.only_json:
if not ocfg.coldata_dir:
raise Exception(
"No coldata_dir provided for an obs network for which only_json=True. The assumption of setting only_json=True is that colocated files already exist, and so a directory for these files must be provided."
)
else:
preprocessed_coldata_dir = ocfg["coldata_dir"]
preprocessed_coldata_dir = ocfg.coldata_dir
mask = f"{preprocessed_coldata_dir}/{model_name}/*.nc"
files_to_convert = glob.glob(mask)
engine = ColdataToJsonEngine(self.cfg)
Expand All @@ -69,7 +69,7 @@ def _run_single_entry(self, model_name, obs_name, var_list):
# If a var_list is given, only run on the obs networks which contain that variable
if var_list:
var_list_asked = var_list
obs_vars = ocfg["obs_vars"]
obs_vars = ocfg.obs_vars
var_list = list(set(obs_vars) & set(var_list))
if not var_list:
logger.warning(
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/aeroval/obsentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class ObsEntry(BaseModel):
######################
## Optional attributes
######################
# obs_id: str | tuple[str, ...] = ""
obs_ts_type_read: str | dict | None = None
obs_vert_type: Literal["Column", "Profile", "Surface"] = "Surface"
obs_aux_requires: dict[str, dict] = {}
Expand All @@ -115,6 +114,7 @@ class ObsEntry(BaseModel):
colocation_layer_limts: tuple[LayerLimits, ...] | None = None
profile_layer_limits: tuple[LayerLimits, ...] | None = None
web_interface_name: str | None = None
diurnal_only: bool = False

read_opts_ungridded: dict = {}
# attributes for reading colocated data files made outside of pyaerocom
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/aeroval/setup_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def serialize_model_cfg(self, model_cfg: ModelCollection):
###########################

def get_obs_entry(self, obs_name) -> dict:
return self.obs_cfg.get_entry(obs_name).model_dump()
return self.obs_cfg.get_entry(obs_name)

def get_model_entry(self, model_name) -> dict:
"""Get model entry configuration
Expand Down

0 comments on commit 88a7c45

Please sign in to comment.