Repository: metno/pyaerocom

Issue:
onlymap runs seem to fail with latest code
will run some more tests but it looks like with code  @cams2-83_2025-02
the onlymap runs fail at the end with a variable error, e.g. 

```
2025-02-08 11:54:47:pyaerocom.variable:1.1/1.3G:INFO:Unknown input variable CHIMERE
2025-02-08 11:54:47:pyaerocom.aeroval.experiment_output:1.1/1.3G:WARNING:Failed to infer cmap and variable ranges for CHIMERE, using default settings which are {'scale': [0.0, 1.25, 2.5, 3.75, 5.0, 6.25, 7.5, 8.75, 10.0], 'colmap': 'coolwarm'}
2025-02-08 11:54:47:pyaerocom.variable:1.1/1.3G:INFO:Unknown input variable CHIMERE
```

Discussion:
@charlienegri: it seems like it's because of this https://github.com/metno/pyaerocom/blob/main-dev/pyaerocom/aeroval/experiment_output.py#L849  
the output in the `contour` folder has now changed and this if https://github.com/metno/pyaerocom/blob/main-dev/pyaerocom/aeroval/experiment_output.py#L344 does not work anymore because `len(spl) == 3` for geojsons too now

I will make a PR


Solution patch:
diff --git a/pyaerocom/aeroval/experiment_output.py b/pyaerocom/aeroval/experiment_output.py
index 3c9a8b65..081d5410 100644
--- a/pyaerocom/aeroval/experiment_output.py
+++ b/pyaerocom/aeroval/experiment_output.py
@@ -15,6 +15,7 @@ from pyaerocom._lowlevel_helpers import (
     TypeValidator,
     sort_dict_by_name,
 )
+from pyaerocom.aeroval import EvalSetup
 from pyaerocom.aeroval.collections import ObsCollection
 from pyaerocom.aeroval.glob_defaults import (
     VariableInfo,
@@ -28,7 +29,6 @@ from pyaerocom.aeroval.glob_defaults import (
 )
 from pyaerocom.aeroval.json_utils import round_floats
 from pyaerocom.aeroval.modelentry import ModelEntry
-from pyaerocom.aeroval import EvalSetup
 from pyaerocom.aeroval.varinfo_web import VarinfoWeb
 from pyaerocom.colocation.colocated_data import ColocatedData
 from pyaerocom.exceptions import EntryNotAvailable, VariableDefinitionError
@@ -339,18 +339,17 @@ class ExperimentOutput(ProjectOutput):
         str
             Time period
         """
-        spl = os.path.basename(file.name).split(file.suffix)[0].split("_")
-
-        if len(spl) == 3:  # png, webp
-            name = spl[0]
-            var_name = spl[1]
-            per = spl[2]
-            return (name, var_name, per)
-        elif len(spl) == 2:  # geojson
-            name = spl[1]
-            var_name = spl[0]
-            per = None
-            return (name, var_name, per)
+        suffix = file.suffix
+        spl = os.path.basename(file.name).split(suffix)[0].split("_")
+
+        if len(spl) == 3:
+            if suffix == ".png" or suffix == ".webp" or suffix == ".geojson":
+                name = spl[1]
+                var_name = spl[0]
+                per = spl[2]
+                return (name, var_name, per)
+            else:
+                raise NotImplementedError(f"{suffix} file format not supported")
         else:
             raise ValueError(f"invalid contour filename: {file}")
 


Test patch:
diff --git a/tests/aeroval/test_experiment_output.py b/tests/aeroval/test_experiment_output.py
index 50679fbf..f711493f 100644
--- a/tests/aeroval/test_experiment_output.py
+++ b/tests/aeroval/test_experiment_output.py
@@ -1,16 +1,15 @@
 from __future__ import annotations
 
+import pathlib
 from pathlib import Path
 
 import aerovaldb
 import pytest
 
 from pyaerocom import const
-from pyaerocom.aeroval import ExperimentProcessor
+from pyaerocom.aeroval import EvalSetup, ExperimentProcessor
 from pyaerocom.aeroval.experiment_output import ExperimentOutput, ProjectOutput
 from pyaerocom.aeroval.json_utils import read_json, write_json
-from pyaerocom.aeroval import EvalSetup
-import pathlib
 
 BASEDIR_DEFAULT = Path(const.OUTPUTDIR) / "aeroval" / "data"
 
@@ -174,20 +173,32 @@ def test_ExperimentOutput__info_from_map_file_error(filename: str):
     )
 
 
-def test_ExperimentOutput__info_from_contour_dir_file():
-    file = pathlib.PosixPath("path/to/name_vertical_period.txt")
+def test_ExperimentOutput__info_from_contour_dir_file_webp():
+    file = pathlib.PosixPath("path/to/var_name_period.webp")
     output = ExperimentOutput._info_from_contour_dir_file(file)
+    assert output == ("name", "var", "period")
 
-    assert output == ("name", "vertical", "period")
+
+def test_ExperimentOutput__info_from_contour_dir_file_geojson():
+    file = pathlib.PosixPath("path/to/var_model_period.geojson")
+    output = ExperimentOutput._info_from_contour_dir_file(file)
+    assert output == ("model", "var", "period")
 
 
 def test_ExperimentOutput__info_from_contour_dir_file_error():
-    file = pathlib.PosixPath("path/to/obs_vertical_model_period.txt")
+    file = pathlib.PosixPath("path/to/obs_vertical_model_period.geojson")
     with pytest.raises(ValueError) as e:
         ExperimentOutput._info_from_contour_dir_file(file)
     assert "invalid contour filename" in str(e.value)
 
 
+def test_ExperimentOutput__info_from_contour_dir_file_error_extension():
+    file = pathlib.PosixPath("path/to/name_vertical_period.txt")
+    with pytest.raises(NotImplementedError) as e:
+        ExperimentOutput._info_from_contour_dir_file(file)
+    assert ".txt file format not supported" in str(e.value)
+
+
 def test_ExperimentOutput__results_summary_EMPTY(dummy_expout: ExperimentOutput):
     assert dummy_expout._results_summary() == dict(obs=[], ovar=[], vc=[], mod=[], mvar=[], per=[])