diff --git a/pyaerocom/aeroval/coldatatojson_helpers.py b/pyaerocom/aeroval/coldatatojson_helpers.py index a5d2bde1f..7c1be61f4 100644 --- a/pyaerocom/aeroval/coldatatojson_helpers.py +++ b/pyaerocom/aeroval/coldatatojson_helpers.py @@ -1457,7 +1457,7 @@ def _process_statistics_timeseries( return output -def _get_jsdate(nparr): +def _get_jsdate(nparr: np.ndarray): dt = nparr.astype("datetime64[s]") offs = np.datetime64("1970", "s") return (dt - offs).astype(int) * 1000 diff --git a/pyaerocom/aeroval/modelmaps_engine.py b/pyaerocom/aeroval/modelmaps_engine.py index c90b05a74..d384397f8 100644 --- a/pyaerocom/aeroval/modelmaps_engine.py +++ b/pyaerocom/aeroval/modelmaps_engine.py @@ -224,13 +224,15 @@ def _process_contour_map_var(self, model_name, var, reanalyse_existing): # prag contourjson = calc_contour_json(data, cmap=varinfo.cmap, cmap_bins=varinfo.cmap_bins) with self.avdb.lock(): - self.avdb.put_contour( - contourjson, - self.exp_output.proj_id, - self.exp_output.exp_id, - var, - model_name, - ) + for time, contour in contourjson.items(): + self.avdb.put_contour( + contour, + self.exp_output.proj_id, + self.exp_output.exp_id, + var, + model_name, + timestep=time, + ) return fp_geojson diff --git a/pyaerocom/aeroval/modelmaps_helpers.py b/pyaerocom/aeroval/modelmaps_helpers.py index 4e6b294ab..65591d718 100644 --- a/pyaerocom/aeroval/modelmaps_helpers.py +++ b/pyaerocom/aeroval/modelmaps_helpers.py @@ -25,7 +25,7 @@ OVERLAY = "overlay" -def _jsdate_list(data): +def _jsdate_list(data: GriddedData | xarray.DataArray): tst = TsType(data.ts_type) if isinstance(data, GriddedData): start_yr = data.start @@ -34,7 +34,7 @@ def _jsdate_list(data): start_yr = pd.Timestamp(data.time.min().values).year stop_yr = pd.Timestamp(data.time.max().values).year else: - raise ValueError("data not correct type") + raise ValueError(f"data is of type {type(data)}, expected GriddedData or DataArray.") idx = make_datetime_index(start_yr, stop_yr, tst.to_pandas_freq()) return _get_jsdate(idx.values).tolist() @@ -140,13 +140,6 @@ def calc_contour_json(data: GriddedData, cmap: str, cmap_bins: list[float]): ) geojsons[str(date)] = geojson - geojsons["legend"] = { - "colors": colors_hex, - "levels": list(cmap_bins), - "var_name": data.var_name, - "units": str(data.units), - } - return geojsons diff --git a/pyaerocom_env.yml b/pyaerocom_env.yml index 956ffb5c2..93ae88e41 100644 --- a/pyaerocom_env.yml +++ b/pyaerocom_env.yml @@ -33,7 +33,7 @@ dependencies: - pip: - geocoder_reverse_natural_earth >= 0.0.2 - pyaro >= 0.1.1 - - aerovaldb >= 0.1.1 + - aerovaldb >= 0.2.1 ## testing - pytest >=7.4 - pytest-dependency diff --git a/pyproject.toml b/pyproject.toml index ff588b410..e3456f146 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -222,6 +222,7 @@ deps = # Will only run on lowest supported Python version CI test # (currently 3.10). # Should be incremented when changing dependencies above. + aerovaldb ==0.2.1; python_version < "3.11" scitools-iris ==3.11.0; python_version < "3.11" cartopy ==0.21.1; python_version < "3.11" matplotlib ==3.7.1; python_version < "3.11"