Skip to content

Commit

Permalink
Merge pull request #1351 from metno/support-map-overlay
Browse files Browse the repository at this point in the history
Bump aerovaldb / Support put_map_overlay() in pyaerocom
  • Loading branch information
lewisblake authored Sep 26, 2024
2 parents 4ef307b + 1396c0a commit b1365e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions pyaerocom/aeroval/experiment_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ def _sync_heatmaps_with_menu_and_regions(self) -> None:
with self.avdb.lock():
menu = self.avdb.get_menu(self.proj_id, self.exp_id, default={})
all_regions = self.avdb.get_regions(self.proj_id, self.exp_id, default={})
for fp in self.avdb.list_glob_stats(self.proj_id, self.exp_id):
data = self.avdb.get_by_uri(fp)
for uri in self.avdb.list_glob_stats(
self.proj_id, self.exp_id, access_type=aerovaldb.AccessType.URI
):
data = self.avdb.get_by_uri(uri)
hm = {}
for vardisp, info in menu.items():
obs_dict = info["obs"]
Expand All @@ -250,7 +252,7 @@ def _sync_heatmaps_with_menu_and_regions(self) -> None:
hm_data = self._check_hm_all_regions_avail(all_regions, hm_data)
hm[vardisp][obs][vert_code][mod][modvar] = hm_data

self.avdb.put_by_uri(hm, fp)
self.avdb.put_by_uri(hm, uri)

def _check_hm_all_regions_avail(self, all_regions, hm_data) -> dict:
if all([x in hm_data for x in all_regions]):
Expand Down Expand Up @@ -413,7 +415,10 @@ def _check_clean_ts_file(self, fp) -> bool:

with self.avdb.lock():
try:
data = self.avdb.get_by_uri(fp)
# TODO: Hack to get uri. Ideally this should be rewritten to use URIs directly further
# up.
uri = self.avdb._get_uri_for_file(fp)
data = self.avdb.get_by_uri(uri)
except Exception:
logger.exception(f"FATAL: detected corrupt json file: {fp}. Removing file...")
os.remove(fp)
Expand All @@ -433,7 +438,7 @@ def _check_clean_ts_file(self, fp) -> bool:
modified = True
logger.info(f"Removing data for model {mod_name} from ts file: {fp}")

self.avdb.put_by_uri(data_new, fp)
self.avdb.put_by_uri(data_new, uri)
return modified

def _clean_modelmap_files(self) -> list[str]:
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies:
- geojsoncontour
- geocoder_reverse_natural_earth >= 0.0.2
- pyaro >= 0.0.10
- aerovaldb == 0.0.15
- aerovaldb >= 0.1.0
## testing
- pytest >=7.4
- pytest-dependency
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
]
requires-python = ">=3.10"
dependencies = [
"aerovaldb==0.0.17",
"aerovaldb>=0.1.0",
"scitools-iris>=3.8.1",
"xarray>=2022.12.0",
"cartopy>=0.21.1",
Expand Down

0 comments on commit b1365e7

Please sign in to comment.