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

New variables #199

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Contributors
* Sébastien Biner <biner.sebastien@hydroquebec.com> `@sbiner <https://github.com/sbiner>`_
* David Huard <huard.david@ouranos.ca> `@huard <https://github.com/huard>`_
* Gabriel Rondeau-Genesse <rondeau-genesse.gabriel@ouranos.ca> `@RondeauG <https://github.com/RondeauG>`_
* Aslı Beşe <bese.asli@ouranos.ca> `@aslibese <https://github.com/aslibese>`_
9 changes: 9 additions & 0 deletions src/miranda/convert/_data_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ def _preprocess_correct(d: xr.Dataset, *, ops: list[partial]) -> xr.Dataset:
return ds


def _correct_standard_names(d: xr.Dataset, p: str, m: dict) -> xr.Dataset:
key = "_corrected_standard_name"
for var, val in _iter_entry_key(d, m, "variables", key, p):
if val:
d[var].attrs["standard_name"] = val
return d


def _correct_units_names(d: xr.Dataset, p: str, m: dict) -> xr.Dataset:
key = "_corrected_units"
for var, val in _iter_entry_key(d, m, "variables", key, p):
Expand Down Expand Up @@ -888,6 +896,7 @@ def dataset_corrections(ds: xr.Dataset, project: str) -> xr.Dataset:
metadata_definition = load_json_data_mappings(project)

ds = _correct_units_names(ds, project, metadata_definition)
ds = _correct_standard_names(ds, project, metadata_definition)
ds = _transform(ds, project, metadata_definition)
ds = _invert_sign(ds, project, metadata_definition)
ds = _units_cf_conversion(ds, metadata_definition)
Expand Down
27 changes: 27 additions & 0 deletions src/miranda/convert/data/ecmwf_cf_attrs.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"pev": {
"_cf_variable_name": "evspsblpot",
"_corrected_units": false,
"_corrected_standard_name": "lwe_thickness_of_water_evaporation_amount",
"_invert_sign": {
"era5-land": true,
"era5-single-levels": true,
Expand Down Expand Up @@ -208,6 +209,7 @@
}
},
"_corrected_units": "m",
"_corrected_standard_name": "lwe_thickness_of_precipitation_amount",
"_invert_sign": false,
"_offset_time": {
"era5-land": true,
Expand Down Expand Up @@ -449,6 +451,7 @@
}
},
"_corrected_units": false,
"_corrected_standard_name": "lwe_thickness_of_precipitation_amount",
"_invert_sign": false,
"_offset_time": true,
"_transformation": {
Expand Down Expand Up @@ -501,6 +504,30 @@
"long_name": "Geopotential",
"standard_name": "geopotential",
"units": "m2 s-2"
},
"sst": {
"_cf_variable_name": "tos",
"_corrected_units": false,
"_invert_sign": false,
"_offset_time": false,
"_transformation": false,
"cell_methods": "time: point",
"description": "This parameter (SST) is the temperature of sea water near the surface. In ERA5, this parameter is a foundation SST, which means there are no variations due to the daily cycle of the sun (diurnal variations).",
"long_name": "Sea surface temperature",
"standard_name": "sea_surface_temperature",
"units": "K"
},
"siconc": {
"_cf_variable_name": "siconc",
"_corrected_units": "1",
"_invert_sign": false,
"_offset_time": false,
"_transformation": false,
"cell_methods": "time: point",
"description": "This parameter is the fraction of a grid box which is covered by sea ice. Sea ice can only occur in a grid box which includes ocean or inland water according to the land-sea mask and lake cover, at the resolution being used.",
"long_name": "Sea ice area fraction",
"standard_name": "sea_ice_area_fraction",
"units": "1"
tlogan2000 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}