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

Fix 1246: var_list not being applied appropriately to obs_vars from networks #1249

Merged
merged 6 commits into from
Jul 8, 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
7 changes: 0 additions & 7 deletions .github/ISSUE_TEMPLATE/general_issue.md

This file was deleted.

14 changes: 12 additions & 2 deletions pyaerocom/aeroval/experiment_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def _run_single_entry(self, model_name, obs_name, var_list):
engine.run(files_to_convert)

else:
# 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"]
var_list = list(set(obs_vars) & set(var_list))
if not var_list:
logger.warning(
"var_list %s and obs_vars %s mismatch.", var_list_asked, obs_vars
)
return

col = self.get_colocator(model_name, obs_name)
if self.cfg.processing_opts.only_json:
files_to_convert = col.get_available_coldata_files(var_list)
Expand Down Expand Up @@ -100,7 +111,7 @@ def run(self, model_name=None, obs_name=None, var_list=None, update_interface=Tr
var_list : list, optional
list variables supposed to be analysed. If None, then all
variables available are used. Defaults to None. Can also be
`str` type.
`str` type. Must match at least some of the variables provided by a observation network.
update_interface : bool
if true, relevant json files that determine what is displayed
online are updated after the run, including the the menu.json file
Expand Down Expand Up @@ -144,7 +155,6 @@ def run(self, model_name=None, obs_name=None, var_list=None, update_interface=Tr
for obs_name in obs_list:
for model_name in model_list:
self._run_single_entry(model_name, obs_name, var_list)

if update_interface:
self.update_interface()
if use_dummy_model:
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/colocation/colocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def _print_processing_status(self):
def _filter_var_matches_var_name(self, var_matches, var_name):
filtered = {}
for mvar, ovar in var_matches.items():
if mvar in var_name or ovar in var_name:
if mvar == var_name or ovar == var_name:
filtered[mvar] = ovar
if len(filtered) == 0:
raise DataCoverageError(var_name)
Expand Down
14 changes: 14 additions & 0 deletions tests/aeroval/test_experiment_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ def test_ExperimentProcessor_run_error(processor: ExperimentProcessor, kwargs: d
with pytest.raises(KeyError) as e:
processor.run(**kwargs)
assert str(e.value) == error


@geojson_unavail
@pytest.mark.parametrize(
"cfg,kwargs,error",
[
("cfgexp2", dict(var_list="BLUB"), "var_list %s and obs_vars %s mismatch."),
],
)
def test_ExperimentProcessor_catch_wrong_var_list(
processor: ExperimentProcessor, kwargs: dict, error: str, caplog
):
processor.run(**kwargs)
assert any([error in str(record) for record in caplog.records])