Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obs name big fix #1427

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading