Skip to content

Commit

Permalink
Merge pull request #193 from cerfacs-globc/enh/adjust-suffix
Browse files Browse the repository at this point in the history
FIX: Add {xxx}Adjust as valid variable aliases
  • Loading branch information
bzah authored Jul 6, 2022
2 parents 863153c + 3c19e91 commit 3aa62c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/source/references/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Note: We no longer strictly follow the yaml given by clix-meta.
* [enh] Make ``in_file`` accept a dictionary merging together ``var_name`` and ``in_file`` features.
* [enh] ``in_file`` dictionary can now be used to pass percentiles thresholds. These thresholds will be used instead of computing them on relevant indices.
* [maint/internal] Refactored IndexConfig and moved all the logic to input_parsing.
* [fix] Add auto detection of variables [prAdjust, tasAdjust, tasmaxAdjust, tasminAdjust]

5.2.2
-----
Expand Down
10 changes: 5 additions & 5 deletions icclim/models/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
IN_BASE_IDENTIFIER = "reference_epoch"

# Aliases of input variables names.
# Source: clix-meta
PR = ["pr", "pradjust", "prec", "rr", "precip", "PREC", "Prec", "RR", "PRECIP", "Precip"]
TAS = ["tas", "tavg", "ta", "tasadjust", "tmean", "tm", "tg", "meant", "TMEAN", "Tmean", "TM", "TG", "MEANT", "meanT", "tasmidpoint"]
TAS_MAX = ["tasmax", "tasmaxadjust", "tmax", "tx", "maxt", "TMAX", "Tmax", "TX", "MAXT", "maxT"]
TAS_MIN = ["tasmin", "tasminadjust", "tmin", "tn", "mint", "TMIN", "Tmin", "TN", "MINT", "minT"]
# Source: clix-meta (modified)
PR = ["pr", "pradjust","prAdjust", "prec", "rr", "precip", "PREC", "Prec", "RR", "PRECIP", "Precip"]
TAS = ["tas", "tavg", "ta", "tasadjust","tasAdjust", "tmean", "tm", "tg", "meant", "TMEAN", "Tmean", "TM", "TG", "MEANT", "meanT", "tasmidpoint"]
TAS_MAX = ["tasmax", "tasmaxadjust","tasmaxAdjust", "tmax", "tx", "maxt", "TMAX", "Tmax", "TX", "MAXT", "maxT"]
TAS_MIN = ["tasmin", "tasminadjust","tasminAdjust", "tmin", "tn", "mint", "TMIN", "Tmin", "TN", "MINT", "minT"]

# Aliases of input percentiles variables names
# Source icclim dev
Expand Down
8 changes: 8 additions & 0 deletions icclim/tests/test_input_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,11 @@ def test_guess_variables__from_list(self):
res = guess_var_names(ds, var_names=["pinçon"])
# THEN
assert res == ["pinçon"]

def test_guess_variables__from_alias(self):
# GIVEN
ds = xr.Dataset({"tasmaxAdjust": self.tas_da})
# WHEN
res = guess_var_names(ds, index=EcadIndex.SU.climate_index)
# THEN
assert res == ["tasmaxAdjust"]

0 comments on commit 3aa62c3

Please sign in to comment.