Skip to content

Commit

Permalink
Merge pull request #1427 from metno/obs_name_big_fix
Browse files Browse the repository at this point in the history
Obs name big fix
  • Loading branch information
lewisblake authored Nov 26, 2024
2 parents 232a3c9 + 917d2fd commit 323fab6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyaerocom/aeroval/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def add_entry(self, key: str, entry: dict | ObsEntry):
if isinstance(entry, dict):
entry = ObsEntry(**entry)
self._entries[key] = entry
self._entries[key].obs_name = self.get_web_interface_name(key)

def remove_entry(self, key: str):
if key in self._entries:
Expand All @@ -164,7 +165,6 @@ def get_entry(self, key: str) -> ObsEntry:
"""
try:
entry = self._entries[key]
entry.obs_name = self.get_web_interface_name(key)
return entry
except (KeyError, AttributeError):
raise EntryNotAvailable(f"no such entry {key}")
Expand Down
1 change: 1 addition & 0 deletions pyaerocom/aeroval/obsentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class ObsEntry(BaseModel):
######################
## Optional attributes
######################
obs_name: str | None = None # not expected to be set directly, rather set by ObsCollection
obs_ts_type_read: str | dict | None = None
obs_vert_type: Literal["Column", "Profile", "Surface", "ModelLevel"] = "Surface"
obs_aux_requires: dict[str, dict] = {}
Expand Down
3 changes: 2 additions & 1 deletion tests/aeroval/test_experiment_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ def test_Experiment_Output_clean_json_files_CFG1_INVALIDMOD(eval_config: dict):
@pytest.mark.parametrize("cfg", ["cfgexp1"])
def test_Experiment_Output_clean_json_files_CFG1_INVALIDOBS(eval_config: dict):
cfg = EvalSetup(**eval_config)
cfg.obs_cfg.add_entry("obs1", cfg.obs_cfg.get_entry("AERONET-Sun"))
cfg.obs_cfg.add_entry("obs1", eval_config["obs_cfg"]["AERONET-Sun"])
proc = ExperimentProcessor(cfg)
proc.run()
cfg.obs_cfg.remove_entry("obs1")
modified = proc.exp_output.clean_json_files()
assert len(modified) == 13

Expand Down

0 comments on commit 323fab6

Please sign in to comment.