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

Write timestep split contour files #1484

Open
wants to merge 4 commits into
base: main-dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion pyaerocom/aeroval/coldatatojson_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions pyaerocom/aeroval/modelmaps_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 2 additions & 9 deletions pyaerocom/aeroval/modelmaps_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@
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.")

Check warning on line 37 in pyaerocom/aeroval/modelmaps_helpers.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/aeroval/modelmaps_helpers.py#L37

Added line #L37 was not covered by tests
idx = make_datetime_index(start_yr, stop_yr, tst.to_pandas_freq())
return _get_jsdate(idx.values).tolist()

Expand Down Expand Up @@ -140,13 +140,6 @@
)
geojsons[str(date)] = geojson

geojsons["legend"] = {
"colors": colors_hex,
"levels": list(cmap_bins),
"var_name": data.var_name,
"units": str(data.units),
}

return geojsons


Expand Down
2 changes: 1 addition & 1 deletion pyaerocom_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading