From 5e1b98f1e2eb0289ebdc8cb6a18e68f4dd44b211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?thorbjoernl=20=28Thorbj=C3=B8rn=29?= <51087536+thorbjoernl@users.noreply.github.com> Date: Mon, 19 Aug 2024 08:43:31 +0000 Subject: [PATCH] First attempt at fix --- pyaerocom/aeroval/coldatatojson_engine.py | 26 ++++++++++++++++++++--- pyaerocom/aeroval/experiment_output.py | 15 ++++++++++--- pyproject.toml | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/pyaerocom/aeroval/coldatatojson_engine.py b/pyaerocom/aeroval/coldatatojson_engine.py index 803020957..f7253cd16 100644 --- a/pyaerocom/aeroval/coldatatojson_engine.py +++ b/pyaerocom/aeroval/coldatatojson_engine.py @@ -234,6 +234,8 @@ def process_coldata(self, coldata: ColocatedData): station_names=coldata.data.station_name.values, periods=periods, seasons=seasons, + obs_name=obs_name, + var_name_web=var_name_web, ) logger.info( @@ -276,6 +278,8 @@ def _process_profile_data_for_visualization( station_names: ArrayLike = None, periods: tuple[str, ...] = None, seasons: tuple[str, ...] = None, + obs_name: str = None, + var_name_web: str = None, ): if region_names is None and station_names is None: raise ValueError("Both region_id and station_name can not both be None") @@ -289,8 +293,16 @@ def _process_profile_data_for_visualization( periods=periods, seasons=seasons, ) - - self.exp_output.add_profile_entry(data, profile_viz, periods, seasons) + location = region_names[regid] + self.exp_output.add_profile_entry( + data, + profile_viz, + periods, + seasons, + location=location, + network=obs_name, + obsvar=var_name_web, + ) # Loop through stations for station_name in station_names: @@ -302,7 +314,15 @@ def _process_profile_data_for_visualization( seasons=seasons, ) - self.exp_output.add_profile_entry(data, profile_viz, periods, seasons) + self.exp_output.add_profile_entry( + data, + profile_viz, + periods, + seasons, + location=station_name, + network=obs_name, + obsvar=var_name_web, + ) def _process_stats_timeseries_for_all_regions( self, diff --git a/pyaerocom/aeroval/experiment_output.py b/pyaerocom/aeroval/experiment_output.py index d00b0db4a..a32c785e4 100644 --- a/pyaerocom/aeroval/experiment_output.py +++ b/pyaerocom/aeroval/experiment_output.py @@ -1030,7 +1030,14 @@ def write_timeseries(self, data): ) def add_profile_entry( - self, data: ColocatedData, profile_viz: dict, periods: list[str], seasons: list[str] + self, + data: ColocatedData, + profile_viz: dict, + periods: list[str], + seasons: list[str], + location, + network, + obsvar, ): """Adds an entry for the colocated data to profiles.json. @@ -1041,7 +1048,9 @@ def add_profile_entry( seasons (list[str]): seasons to compute over (e.g., All, DJF, etc.) """ with self.avdb.lock(): - current = self.avdb.get_profiles(self.proj_id, self.exp_id, default={}) + current = self.avdb.get_profiles( + self.proj_id, self.exp_id, location, network, obsvar, default={} + ) current = recursive_defaultdict(current) for freq, coldata in data.items(): @@ -1084,4 +1093,4 @@ def add_profile_entry( } current[model_name] = round_floats(current[model_name]) - self.avdb.put_profiles(current, self.proj_id, self.exp_id) + self.avdb.put_profiles(current, self.proj_id, self.exp_id, location, network, obsvar) diff --git a/pyproject.toml b/pyproject.toml index 6543d0733..d2d346a82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ ] requires-python = ">=3.10" dependencies = [ - "aerovaldb == 0.0.15", + "aerovaldb==0.0.17", "scitools-iris>=3.8.1", "xarray>=2022.12.0", "cartopy>=0.21.1",