diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97e7e497..cb443f6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,6 +27,7 @@ repos: rev: v0.1.9 hooks: - id: ruff + args: [ --fix ] - id: ruff-format - repo: meta hooks: diff --git a/pyproject.toml b/pyproject.toml index 7f97fffb..64903411 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,7 @@ select = [ "W", # pycodestyle warn "C90", # mccabe "I", # isort - # "N", # pep8-naming, to add + "N", # pep8-naming, to add # "D", # pydocstyle, to add "UP", # pyupgrade "YTT", # flake8-2020 diff --git a/src/icclim/__init__.py b/src/icclim/__init__.py index 181758fb..cf98e87e 100644 --- a/src/icclim/__init__.py +++ b/src/icclim/__init__.py @@ -1,4 +1,4 @@ -"""Python library for climate indices calculation""" +"""Python library for climate indices calculation.""" from icclim._generated_api import * # noqa: F403 (add api to be in icclim module) from icclim.generic_indices.threshold import build_threshold diff --git a/src/icclim/_generated_api.py b/src/icclim/_generated_api.py index cf33247a..0f88e01f 100644 --- a/src/icclim/_generated_api.py +++ b/src/icclim/_generated_api.py @@ -1,4 +1,4 @@ -# ruff: noqa: A001, E501 +# ruff: noqa: A001, E501, N803 """ icclim's API for ECAD indices and generic indices. @@ -125,7 +125,7 @@ def count_occurrences( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """count_occurrences + """count_occurrences. Count occurrences where threshold(s) are met (e.g. SU, Tx90p, RR1). @@ -220,7 +220,7 @@ def max_consecutive_occurrence( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """max_consecutive_occurrence + """max_consecutive_occurrence. Count the maximum number of consecutive occurrences when threshold(s) are met (e.g. CDD, CSU, CWD). @@ -316,7 +316,7 @@ def sum_of_spell_lengths( date_event: bool = False, min_spell_length: int | None = 6, ) -> Dataset: - """sum_of_spell_lengths + """sum_of_spell_lengths. Sum the lengths of each consecutive occurrence spell when threshold(s) are met. The minimum spell length is controlled by `min_spell_length` (e.g. WSDI, CSDI). @@ -415,7 +415,7 @@ def excess( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """excess + """excess. Compute the excess over the given threshold. The excess is `sum(x[x>t] - t)` where x is the studied variable and t the threshold (e.g. GD4). @@ -510,7 +510,7 @@ def deficit( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """deficit + """deficit. Compute the deficit below the given threshold. The deficit is `sum(t - x[x Dataset: - """fraction_of_total + """fraction_of_total. Compute the fraction of values meeting threshold(s) over the sum of every values (e.g. R75pTOT, R95pTOT). @@ -700,7 +700,7 @@ def maximum( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """maximum + """maximum. Maximum of values that met threshold(s), if threshold(s) are given (e.g. Txx, Tnx). @@ -795,7 +795,7 @@ def minimum( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """minimum + """minimum. Minimum of values that met threshold(s), if threshold(s) are given (e.g. Txn, Tnn). @@ -890,7 +890,7 @@ def average( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """average + """average. Average of values that met threshold(s), if threshold(s) are given (e.g. Tx, Tn) @@ -985,7 +985,7 @@ def sum( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """sum + """sum. Sum of values that met threshold(s), if threshold(s) are given (e.g. PRCPTOT, RR). @@ -1080,7 +1080,7 @@ def standard_deviation( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """standard_deviation + """standard_deviation. Standard deviation of values that met threshold(s), if threshold(s) are given. @@ -1176,7 +1176,7 @@ def max_of_rolling_sum( date_event: bool = False, rolling_window_width: int | None = 5, ) -> Dataset: - """max_of_rolling_sum + """max_of_rolling_sum. Maximum of rolling sum over time dimension (e.g. RX5DAY: maximum 5 days window of precipitation accumulation). @@ -1276,7 +1276,7 @@ def min_of_rolling_sum( date_event: bool = False, rolling_window_width: int | None = 5, ) -> Dataset: - """min_of_rolling_sum + """min_of_rolling_sum. Minimum of rolling sum over time dimension. @@ -1376,7 +1376,7 @@ def max_of_rolling_average( date_event: bool = False, rolling_window_width: int | None = 5, ) -> Dataset: - """max_of_rolling_average + """max_of_rolling_average. Maximum of rolling average over time dimension. @@ -1476,7 +1476,7 @@ def min_of_rolling_average( date_event: bool = False, rolling_window_width: int | None = 5, ) -> Dataset: - """min_of_rolling_average + """min_of_rolling_average. Minimum of rolling average over time dimension. @@ -1575,7 +1575,7 @@ def mean_of_difference( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """mean_of_difference + """mean_of_difference. Average of the difference between two variables, or one variable and it's reference period values (e.g. DTR: `mean(tasmax - tasmin)`). @@ -1670,7 +1670,7 @@ def difference_of_extremes( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """difference_of_extremes + """difference_of_extremes. Difference of extremes between two variables, or one variable and it's reference period values. The extremes are always `maximum` for the first variable and `minimum` for the second variable (e.g. ETR: `max(tasmax) - min(tasmin)`). @@ -1765,7 +1765,7 @@ def mean_of_absolute_one_time_step_difference( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """mean_of_absolute_one_time_step_difference + """mean_of_absolute_one_time_step_difference. Average of the absolute one time step by one time step difference between two variables, or one variable and it's reference period values (e.g. vDTR: `mean((tasmax[i] - tasmin[i]) - (tasmax[i-1] - tasmin[i-1])` ; where i is the day of measure). @@ -1861,7 +1861,7 @@ def difference_of_means( date_event: bool = False, sampling_method: SamplingMethodLike = "resample", ) -> Dataset: - """difference_of_means + """difference_of_means. Difference of the average between two variables, or one variable and it's reference period values (e.g. anomaly: `mean(tasmax) - mean(tasmax_ref]))`. @@ -1962,9 +1962,9 @@ def tg( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TG + """TG. - Mean of daily mean temperature + Mean of daily mean temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2042,9 +2042,9 @@ def tn( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TN + """TN. - Mean of daily minimum temperature + Mean of daily minimum temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2122,9 +2122,9 @@ def tx( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TX + """TX. - Mean of daily maximum temperature + Mean of daily maximum temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2202,9 +2202,9 @@ def dtr( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """DTR + """DTR. - Mean Diurnal Temperature Range + Mean Diurnal Temperature Range. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2282,9 +2282,9 @@ def etr( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """ETR + """ETR. - Intra-period extreme temperature range + Intra-period extreme temperature range. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2362,9 +2362,9 @@ def vdtr( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """vDTR + """vDTR. - Mean day-to-day variation in Diurnal Temperature Range + Mean day-to-day variation in Diurnal Temperature Range. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2442,9 +2442,9 @@ def su( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SU + """SU. - Number of Summer Days (Tmax > 25C) + Number of Summer Days (Tmax > 25C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2525,9 +2525,9 @@ def tr( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TR + """TR. - Number of Tropical Nights (Tmin > 20C) + Number of Tropical Nights (Tmin > 20C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2612,9 +2612,9 @@ def wsdi( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """WSDI + """WSDI. - Warm-spell duration index (days) + Warm-spell duration index (days). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2731,9 +2731,9 @@ def tg90p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TG90p + """TG90p. - Days when Tmean > 90th percentile + Days when Tmean > 90th percentile. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2850,9 +2850,9 @@ def tn90p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TN90p + """TN90p. - Days when Tmin > 90th percentile + Days when Tmin > 90th percentile. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -2969,9 +2969,9 @@ def tx90p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TX90p + """TX90p. - Days when Tmax > 90th daily percentile + Days when Tmax > 90th daily percentile. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3084,9 +3084,9 @@ def txx( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TXx + """TXx. - Maximum daily maximum temperature + Maximum daily maximum temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3164,9 +3164,9 @@ def tnx( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TNx + """TNx. - Maximum daily minimum temperature + Maximum daily minimum temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3244,9 +3244,9 @@ def csu( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CSU + """CSU. - Maximum number of consecutive summer days (Tmax >25 C) + Maximum number of consecutive summer days (Tmax >25 C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3327,9 +3327,9 @@ def gd4( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """GD4 + """GD4. - Growing degree days (sum of Tmean > 4 C) + Growing degree days (sum of Tmean > 4 C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3410,9 +3410,9 @@ def fd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """FD + """FD. - Number of Frost Days (Tmin < 0C) + Number of Frost Days (Tmin < 0C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3493,9 +3493,9 @@ def cfd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CFD + """CFD. - Maximum number of consecutive frost days (Tmin < 0 C) + Maximum number of consecutive frost days (Tmin < 0 C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3576,9 +3576,9 @@ def hd17( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """HD17 + """HD17. - Heating degree days (sum of Tmean < 17 C) + Heating degree days (sum of Tmean < 17 C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3659,9 +3659,9 @@ def id( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """ID + """ID. - Number of sharp Ice Days (Tmax < 0C) + Number of sharp Ice Days (Tmax < 0C). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3746,9 +3746,9 @@ def tg10p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TG10p + """TG10p. - Days when Tmean < 10th percentile + Days when Tmean < 10th percentile. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3865,9 +3865,9 @@ def tn10p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TN10p + """TN10p. - Days when Tmin < 10th percentile + Days when Tmin < 10th percentile. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -3984,9 +3984,9 @@ def tx10p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TX10p + """TX10p. - Days when Tmax < 10th percentile + Days when Tmax < 10th percentile. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4099,9 +4099,9 @@ def txn( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TXn + """TXn. - Minimum daily maximum temperature + Minimum daily maximum temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4179,9 +4179,9 @@ def tnn( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """TNn + """TNn. - Minimum daily minimum temperature + Minimum daily minimum temperature. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4263,9 +4263,9 @@ def csdi( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CSDI + """CSDI. - Cold-spell duration index (days) + Cold-spell duration index (days). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4378,9 +4378,9 @@ def cdd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CDD + """CDD. - Maximum consecutive dry days (Precip < 1mm) + Maximum consecutive dry days (Precip < 1mm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4461,9 +4461,9 @@ def prcptot( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """PRCPTOT + """PRCPTOT. - Total precipitation during Wet Days + Total precipitation during Wet Days. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4544,9 +4544,9 @@ def rr1( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """RR1 + """RR1. - Number of Wet Days (precip >= 1 mm) + Number of Wet Days (precip >= 1 mm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4627,9 +4627,9 @@ def sdii( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SDII + """SDII. - Average precipitation during Wet Days (SDII) + Average precipitation during Wet Days (SDII). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4710,9 +4710,9 @@ def cwd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CWD + """CWD. - Maximum consecutive wet days (Precip >= 1mm) + Maximum consecutive wet days (Precip >= 1mm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4793,9 +4793,9 @@ def rr( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """RR + """RR. - Precipitation sum (mm) + Precipitation sum (mm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4873,9 +4873,9 @@ def r10mm( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R10mm + """R10mm. - Number of heavy precipitation days (Precip >=10mm) + Number of heavy precipitation days (Precip >=10mm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -4956,9 +4956,9 @@ def r20mm( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R20mm + """R20mm. - Number of very heavy precipitation days (Precip >= 20mm) + Number of very heavy precipitation days (Precip >= 20mm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5039,9 +5039,9 @@ def rx1day( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """RX1day + """RX1day. - maximum 1-day total precipitation + maximum 1-day total precipitation. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5119,9 +5119,9 @@ def rx5day( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """RX5day + """RX5day. - maximum 5-day total precipitation + maximum 5-day total precipitation. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5203,9 +5203,9 @@ def r75p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R75p + """R75p. - Days with RR > 75th percentile of daily amounts (moderate wet days) (d) + Days with RR > 75th percentile of daily amounts. (moderate wet days) (d) Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5323,9 +5323,9 @@ def r75ptot( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R75pTOT + """R75pTOT. - Precipitation fraction due to moderate wet days (> 75th percentile) + Precipitation fraction due to moderate wet days. (> 75th percentile) Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5443,9 +5443,9 @@ def r95p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R95p + """R95p. - Days with RR > 95th percentile of daily amounts (very wet days) (days) + Days with RR > 95th percentile of daily amounts. (very wet days) (days) Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5563,9 +5563,9 @@ def r95ptot( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R95pTOT + """R95pTOT. - Precipitation fraction due to very wet days (> 95th percentile) + Precipitation fraction due to very wet days (> 95th percentile). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5683,9 +5683,9 @@ def r99p( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R99p + """R99p. - Days with RR > 99th percentile of daily amounts (extremely wet days) + Days with RR > 99th percentile of daily amounts. (extremely wet days) Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5803,9 +5803,9 @@ def r99ptot( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """R99pTOT + """R99pTOT. - Precipitation fraction due to extremely wet days (> 99th percentile) + Precipitation fraction due to extremely wet days. (> 99th percentile) Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5919,9 +5919,9 @@ def sd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SD + """SD. - Mean of daily snow depth + Mean of daily snow depth. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -5999,9 +5999,9 @@ def sd1( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SD1 + """SD1. - Snow days (SD >= 1 cm) + Snow days (SD >= 1 cm). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6082,9 +6082,9 @@ def sd5cm( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SD5cm + """SD5cm. - Number of days with snow depth >= 5 cm + Number of days with snow depth >= 5 cm. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6165,9 +6165,9 @@ def sd50cm( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SD50cm + """SD50cm. - Number of days with snow depth >= 50 cm + Number of days with snow depth >= 50 cm. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6252,9 +6252,9 @@ def cd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CD + """CD. - Days with TG < 25th percentile of daily mean temperature and RR <25th percentile of daily precipitation sum (cold/dry days) + Days with TG < 25th percentile of daily mean temperature and RR <25th percentile of daily precipitation sum (cold/dry days). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6381,9 +6381,9 @@ def cw( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """CW + """CW. - Days with TG < 25th percentile of daily mean temperature and RR >75th percentile of daily precipitation sum (cold/wet days) + Days with TG < 25th percentile of daily mean temperature and RR >75th percentile of daily precipitation sum (cold/wet days). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6510,9 +6510,9 @@ def wd( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """WD + """WD. - Days with TG > 75th percentile of daily mean temperature and RR <25th percentile of daily precipitation sum (warm/dry days) + Days with TG > 75th percentile of daily mean temperature and RR <25th percentile of daily precipitation sum (warm/dry days). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6639,9 +6639,9 @@ def ww( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """WW + """WW. - Days with TG > 75th percentile of daily mean temperature and RR >75th percentile of daily precipitation sum (warm/wet days) + Days with TG > 75th percentile of daily mean temperature and RR >75th percentile of daily precipitation sum (warm/wet days). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6764,9 +6764,9 @@ def fxx( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """FXx + """FXx. - Maximum value of daily maximum wind gust + Maximum value of daily maximum wind gust. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6844,9 +6844,9 @@ def fg6bft( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """FG6Bft + """FG6Bft. - Days with daily averaged wind ≥ 6 Bft (10.8 m s-1) + Days with daily averaged wind ≥ 6 Bft (10.8 m s-1). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -6927,9 +6927,9 @@ def fgcalm( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """FGcalm + """FGcalm. - Calm days, days with daily averaged wind <= 2 m s-1 + Calm days, days with daily averaged wind <= 2 m s-1. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7010,9 +7010,9 @@ def fg( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """FG + """FG. - Mean of daily mean wind strength + Mean of daily mean wind strength. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7090,9 +7090,9 @@ def ddnorth( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """DDnorth + """DDnorth. - Days with northerly winds (DD > 315° or DD ≤ 45°) + Days with northerly winds (DD > 315° or DD ≤ 45°). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7173,9 +7173,9 @@ def ddeast( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """DDeast + """DDeast. - Days with easterly winds (45° < DD <= 135°) + Days with easterly winds (45° < DD <= 135°). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7256,9 +7256,9 @@ def ddsouth( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """DDsouth + """DDsouth. - Days with southerly winds (135° < DD <= 225°) + Days with southerly winds (135° < DD <= 225°). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7339,9 +7339,9 @@ def ddwest( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """DDwest + """DDwest. - Days with westerly winds (225° < DD <= 315°) + Days with westerly winds (225° < DD <= 315°). Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7422,9 +7422,9 @@ def gsl( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """GSL + """GSL. - Growing season length + Growing season length. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7503,9 +7503,9 @@ def spi6( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SPI6 + """SPI6. - 6-Month Standardized Precipitation Index + 6-Month Standardized Precipitation Index. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters @@ -7599,9 +7599,9 @@ def spi3( logs_verbosity: Verbosity | str = "LOW", date_event: bool = False, ) -> Dataset: - """SPI3 + """SPI3. - 3-Month Standardized Precipitation Index + 3-Month Standardized Precipitation Index. Source: ECA&D, Algorithm Theoretical Basis Document (ATBD) v11. Parameters diff --git a/src/icclim/ecad/ecad_indices.py b/src/icclim/ecad/ecad_indices.py index ed2727dd..c4c0670e 100644 --- a/src/icclim/ecad/ecad_indices.py +++ b/src/icclim/ecad/ecad_indices.py @@ -1,6 +1,6 @@ from __future__ import annotations -from icclim.ecad.xclim_binding import XCLIM_BINDING +from icclim.ecad.xclim_binding import XclimBinding from icclim.generic_indices.generic_indicators import GenericIndicatorRegistry from icclim.generic_indices.standard_variable import StandardVariableRegistry from icclim.generic_indices.threshold import build_threshold @@ -35,7 +35,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Average, output_unit="degree_Celsius", - definition="Mean of daily mean temperature", + definition="Mean of daily mean temperature.", source=ECAD_ATBD, short_name="TG", group=IndexGroupRegistry.TEMPERATURE, @@ -45,7 +45,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Average, output_unit="degree_Celsius", - definition="Mean of daily minimum temperature", + definition="Mean of daily minimum temperature.", source=ECAD_ATBD, short_name="TN", group=IndexGroupRegistry.TEMPERATURE, @@ -55,7 +55,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Average, output_unit="degree_Celsius", - definition="Mean of daily maximum temperature", + definition="Mean of daily maximum temperature.", source=ECAD_ATBD, short_name="TX", group=IndexGroupRegistry.TEMPERATURE, @@ -65,7 +65,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.MeanOfDifference, output_unit="degree_Celsius", - definition="Mean Diurnal Temperature Range", + definition="Mean Diurnal Temperature Range.", source=ECAD_ATBD, short_name="DTR", group=IndexGroupRegistry.TEMPERATURE, @@ -78,7 +78,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.DifferenceOfExtremes, output_unit="degree_Celsius", - definition="Intra-period extreme temperature range", + definition="Intra-period extreme temperature range.", source=ECAD_ATBD, short_name="ETR", group=IndexGroupRegistry.TEMPERATURE, @@ -91,7 +91,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.MeanOfAbsoluteOneTimeStepDifference, output_unit="degree_Celsius", - definition="Mean day-to-day variation in Diurnal Temperature Range", + definition="Mean day-to-day variation in Diurnal Temperature Range.", source=ECAD_ATBD, short_name="vDTR", group=IndexGroupRegistry.TEMPERATURE, @@ -105,7 +105,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.CountOccurrences, output_unit="day", - definition="Number of Summer Days (Tmax > 25C)", + definition="Number of Summer Days (Tmax > 25C).", source=ECAD_ATBD, short_name="SU", threshold="> 25 degree_Celsius", @@ -117,7 +117,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.CountOccurrences, output_unit="day", - definition="Number of Tropical Nights (Tmin > 20C)", + definition="Number of Tropical Nights (Tmin > 20C).", source=ECAD_ATBD, short_name="TR", threshold="> 20 degree_Celsius", @@ -129,7 +129,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.SumOfSpellLengths, output_unit="day", - definition="Warm-spell duration index (days)", + definition="Warm-spell duration index (days).", source=ECAD_ATBD, short_name="WSDI", threshold="> 90 doy_per", @@ -143,7 +143,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.CountOccurrences, output_unit="day", - definition="Days when Tmean > 90th percentile", + definition="Days when Tmean > 90th percentile.", threshold="> 90 doy_per", source=ECAD_ATBD, short_name="TG90p", @@ -156,7 +156,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.CountOccurrences, output_unit="day", - definition="Days when Tmin > 90th percentile", + definition="Days when Tmin > 90th percentile.", threshold="> 90 doy_per", source=ECAD_ATBD, short_name="TN90p", @@ -170,7 +170,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="> 90 doy_per", output_unit="day", - definition="Days when Tmax > 90th daily percentile", + definition="Days when Tmax > 90th daily percentile.", source=ECAD_ATBD, short_name="TX90p", group=IndexGroupRegistry.HEAT, @@ -182,7 +182,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Maximum, output_unit="degree_Celsius", - definition="Maximum daily maximum temperature", + definition="Maximum daily maximum temperature.", source=ECAD_ATBD, short_name="TXx", group=IndexGroupRegistry.HEAT, @@ -192,7 +192,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Maximum, output_unit="degree_Celsius", - definition="Maximum daily minimum temperature", + definition="Maximum daily minimum temperature.", source=ECAD_ATBD, short_name="TNx", group=IndexGroupRegistry.HEAT, @@ -203,7 +203,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.MaxConsecutiveOccurrence, threshold="> 25 degree_Celsius", output_unit="day", - definition="Maximum number of consecutive summer days (Tmax >25 C)", + definition="Maximum number of consecutive summer days (Tmax >25 C).", source=ECAD_ATBD, short_name="CSU", group=IndexGroupRegistry.HEAT, @@ -216,7 +216,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.Excess, threshold="4 degree_Celsius", output_unit="degree_Celsius day", - definition="Growing degree days (sum of Tmean > 4 C)", + definition="Growing degree days (sum of Tmean > 4 C).", source=ECAD_ATBD, short_name="GD4", group=IndexGroupRegistry.COLD, @@ -228,7 +228,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="< 0 degree_Celsius", output_unit="day", - definition="Number of Frost Days (Tmin < 0C)", + definition="Number of Frost Days (Tmin < 0C).", source=ECAD_ATBD, short_name="FD", group=IndexGroupRegistry.COLD, @@ -240,7 +240,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.MaxConsecutiveOccurrence, threshold="< 0 degree_Celsius", output_unit="day", - definition="Maximum number of consecutive frost days (Tmin < 0 C)", + definition="Maximum number of consecutive frost days (Tmin < 0 C).", source=ECAD_ATBD, short_name="CFD", group=IndexGroupRegistry.COLD, @@ -252,7 +252,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.Deficit, threshold="17 degree_Celsius", output_unit="degree_Celsius day", - definition="Heating degree days (sum of Tmean < 17 C)", + definition="Heating degree days (sum of Tmean < 17 C).", source=ECAD_ATBD, short_name="HD17", group=IndexGroupRegistry.COLD, @@ -264,7 +264,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="< 0 degree_Celsius", output_unit="day", - definition="Number of sharp Ice Days (Tmax < 0C)", + definition="Number of sharp Ice Days (Tmax < 0C).", source=ECAD_ATBD, short_name="ID", group=IndexGroupRegistry.COLD, @@ -276,7 +276,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="< 10 doy_per", output_unit="day", - definition="Days when Tmean < 10th percentile", + definition="Days when Tmean < 10th percentile.", source=ECAD_ATBD, short_name="TG10p", group=IndexGroupRegistry.COLD, @@ -289,7 +289,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="< 10 doy_per", output_unit="day", - definition="Days when Tmin < 10th percentile", + definition="Days when Tmin < 10th percentile.", source=ECAD_ATBD, short_name="TN10p", group=IndexGroupRegistry.COLD, @@ -302,7 +302,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="< 10 doy_per", output_unit="day", - definition="Days when Tmax < 10th percentile", + definition="Days when Tmax < 10th percentile.", source=ECAD_ATBD, short_name="TX10p", group=IndexGroupRegistry.COLD, @@ -314,7 +314,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Minimum, output_unit="degree_Celsius", - definition="Minimum daily maximum temperature", + definition="Minimum daily maximum temperature.", source=ECAD_ATBD, short_name="TXn", group=IndexGroupRegistry.COLD, @@ -324,7 +324,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Minimum, output_unit="degree_Celsius", - definition="Minimum daily minimum temperature", + definition="Minimum daily minimum temperature.", source=ECAD_ATBD, short_name="TNn", group=IndexGroupRegistry.COLD, @@ -335,7 +335,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.SumOfSpellLengths, threshold="< 10 doy_per", output_unit="day", - definition="Cold-spell duration index (days)", + definition="Cold-spell duration index (days).", source=ECAD_ATBD, short_name="CSDI", group=IndexGroupRegistry.COLD, @@ -350,7 +350,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.MaxConsecutiveOccurrence, threshold="< 1 mm/day", output_unit="day", - definition="Maximum consecutive dry days (Precip < 1mm)", + definition="Maximum consecutive dry days (Precip < 1mm).", source=ECAD_ATBD, short_name="CDD", group=IndexGroupRegistry.DROUGHT, @@ -362,7 +362,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.Sum, threshold=">= 1 mm/day", output_unit="mm", - definition="Total precipitation during Wet Days", + definition="Total precipitation during Wet Days.", source=ECAD_ATBD, short_name="PRCPTOT", group=IndexGroupRegistry.RAIN, @@ -373,7 +373,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=">= 1 mm/day", output_unit="day", - definition="Number of Wet Days (precip >= 1 mm)", + definition="Number of Wet Days (precip >= 1 mm).", source=ECAD_ATBD, short_name="RR1", group=IndexGroupRegistry.RAIN, @@ -384,7 +384,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.Average, threshold=">= 1 mm/day", output_unit="mm/day", - definition="Average precipitation during Wet Days (SDII)", + definition="Average precipitation during Wet Days (SDII).", source=ECAD_ATBD, short_name="SDII", group=IndexGroupRegistry.RAIN, @@ -395,7 +395,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.MaxConsecutiveOccurrence, threshold=">= 1 mm/day", output_unit="day", - definition="Maximum consecutive wet days (Precip >= 1mm)", + definition="Maximum consecutive wet days (Precip >= 1mm).", source=ECAD_ATBD, short_name="CWD", group=IndexGroupRegistry.RAIN, @@ -405,7 +405,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Sum, output_unit="mm", - definition="Precipitation sum (mm)", + definition="Precipitation sum (mm).", source=ECAD_ATBD, short_name="RR", group=IndexGroupRegistry.RAIN, @@ -416,7 +416,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=">= 10 mm/day", output_unit="day", - definition="Number of heavy precipitation days (Precip >=10mm)", + definition="Number of heavy precipitation days (Precip >=10mm).", source=ECAD_ATBD, short_name="R10mm", group=IndexGroupRegistry.RAIN, @@ -427,7 +427,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=">= 20 mm/day", output_unit="day", - definition="Number of very heavy precipitation days (Precip >= 20mm)", + definition="Number of very heavy precipitation days (Precip >= 20mm).", source=ECAD_ATBD, short_name="R20mm", group=IndexGroupRegistry.RAIN, @@ -437,7 +437,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Maximum, output_unit="mm/day", - definition="maximum 1-day total precipitation", # from xclim + definition="maximum 1-day total precipitation.", # from xclim source=ECAD_ATBD, short_name="RX1day", group=IndexGroupRegistry.RAIN, @@ -447,7 +447,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.MaxOfRollingSum, output_unit="mm", - definition="maximum 5-day total precipitation", # from xclim + definition="maximum 5-day total precipitation.", # from xclim source=ECAD_ATBD, short_name="RX5day", group=IndexGroupRegistry.RAIN, @@ -460,7 +460,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=build_threshold("> 75 period_per", threshold_min_value="1 mm/day"), output_unit="day", - definition="Days with RR > 75th percentile of daily amounts" + definition="Days with RR > 75th percentile of daily amounts." " (moderate wet days) (d)", source=ECAD_ATBD, short_name="R75p", @@ -473,7 +473,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.FractionOfTotal, threshold=build_threshold("> 75 period_per", threshold_min_value="1 mm/day"), output_unit="%", - definition="Precipitation fraction due to moderate wet days" + definition="Precipitation fraction due to moderate wet days." " (> 75th percentile)", source=ECAD_ATBD, short_name="R75pTOT", @@ -486,7 +486,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=build_threshold("> 95 period_per", threshold_min_value="1 mm/day"), output_unit="day", - definition="Days with RR > 95th percentile of daily amounts" + definition="Days with RR > 95th percentile of daily amounts." " (very wet days) (days)", source=ECAD_ATBD, short_name="R95p", @@ -499,7 +499,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.FractionOfTotal, threshold=build_threshold("> 95 period_per", threshold_min_value="1 mm/day"), output_unit="%", - definition="Precipitation fraction due to very wet days (> 95th percentile)", + definition="Precipitation fraction due to very wet days (> 95th percentile).", source=ECAD_ATBD, short_name="R95pTOT", group=IndexGroupRegistry.RAIN, @@ -511,7 +511,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=build_threshold("> 99 period_per", threshold_min_value="1 mm/day"), output_unit="day", - definition="Days with RR > 99th percentile of daily amounts" + definition="Days with RR > 99th percentile of daily amounts." " (extremely wet days)", source=ECAD_ATBD, short_name="R99p", @@ -524,7 +524,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.FractionOfTotal, threshold=build_threshold("> 99 period_per", threshold_min_value="1 mm/day"), output_unit="%", - definition="Precipitation fraction due to extremely wet days" + definition="Precipitation fraction due to extremely wet days." " (> 99th percentile)", source=ECAD_ATBD, short_name="R99pTOT", @@ -537,7 +537,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Average, output_unit="cm", - definition="Mean of daily snow depth", + definition="Mean of daily snow depth.", source=ECAD_ATBD, short_name="SD", group=IndexGroupRegistry.SNOW, @@ -548,7 +548,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=">= 1 cm", output_unit="day", - definition="Snow days (SD >= 1 cm)", + definition="Snow days (SD >= 1 cm).", source=ECAD_ATBD, short_name="SD1", group=IndexGroupRegistry.SNOW, @@ -559,7 +559,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, output_unit="day", threshold=">= 5 cm", - definition="Number of days with snow depth >= 5 cm", + definition="Number of days with snow depth >= 5 cm.", source=ECAD_ATBD, short_name="SD5cm", group=IndexGroupRegistry.SNOW, @@ -570,7 +570,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=">= 50 cm", output_unit="day", - definition="Number of days with snow depth >= 50 cm", + definition="Number of days with snow depth >= 50 cm.", source=ECAD_ATBD, short_name="SD50cm", group=IndexGroupRegistry.SNOW, @@ -586,7 +586,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ], output_unit="day", definition="Days with TG < 25th percentile of daily mean temperature and" - " RR <25th percentile of daily precipitation sum (cold/dry days)", + " RR <25th percentile of daily precipitation sum (cold/dry days).", source=ECAD_ATBD, short_name="CD", group=IndexGroupRegistry.TEMPERATURE | IndexGroupRegistry.RAIN, @@ -603,7 +603,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ], output_unit="day", definition="Days with TG < 25th percentile of daily mean temperature and" - " RR >75th percentile of daily precipitation sum (cold/wet days)", + " RR >75th percentile of daily precipitation sum (cold/wet days).", source=ECAD_ATBD, short_name="CW", group=IndexGroupRegistry.TEMPERATURE | IndexGroupRegistry.RAIN, @@ -620,7 +620,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ], output_unit="day", definition="Days with TG > 75th percentile of daily mean temperature and" - " RR <25th percentile of daily precipitation sum (warm/dry days)", + " RR <25th percentile of daily precipitation sum (warm/dry days).", source=ECAD_ATBD, short_name="WD", group=IndexGroupRegistry.TEMPERATURE | IndexGroupRegistry.RAIN, @@ -637,7 +637,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ], output_unit="day", definition="Days with TG > 75th percentile of daily mean temperature and" - " RR >75th percentile of daily precipitation sum (warm/wet days)", + " RR >75th percentile of daily precipitation sum (warm/wet days).", source=ECAD_ATBD, short_name="WW", group=IndexGroupRegistry.TEMPERATURE | IndexGroupRegistry.RAIN, @@ -650,7 +650,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Maximum, output_unit="m s-1", - definition="Maximum value of daily maximum wind gust", + definition="Maximum value of daily maximum wind gust.", source=ECAD_ATBD, short_name="FXx", group=IndexGroupRegistry.WIND, @@ -661,7 +661,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold=">= 10.8 m s-1", output_unit="day", - definition="Days with daily averaged wind ≥ 6 Bft (10.8 m s-1)", + definition="Days with daily averaged wind ≥ 6 Bft (10.8 m s-1).", source=ECAD_ATBD, short_name="FG6Bft", group=IndexGroupRegistry.WIND, @@ -672,7 +672,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="<= 2 m s-1", output_unit="day", - definition="Calm days, days with daily averaged wind <= 2 m s-1", + definition="Calm days, days with daily averaged wind <= 2 m s-1.", source=ECAD_ATBD, short_name="FGcalm", group=IndexGroupRegistry.WIND, @@ -682,7 +682,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: reference=ECAD_REFERENCE, indicator=GenericIndicatorRegistry.Average, output_unit="m s-1", - definition="Mean of daily mean wind strength", + definition="Mean of daily mean wind strength.", source=ECAD_ATBD, short_name="FG", group=IndexGroupRegistry.WIND, @@ -693,7 +693,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="> 315 degree OR <= 45 degree", output_unit="day", - definition="Days with northerly winds (DD > 315° or DD ≤ 45°)", + definition="Days with northerly winds (DD > 315° or DD ≤ 45°).", source=ECAD_ATBD, short_name="DDnorth", group=IndexGroupRegistry.WIND, @@ -704,7 +704,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="> 45 degree AND <= 135 degree", output_unit="day", - definition="Days with easterly winds (45° < DD <= 135°)", + definition="Days with easterly winds (45° < DD <= 135°).", source=ECAD_ATBD, short_name="DDeast", group=IndexGroupRegistry.WIND, @@ -715,7 +715,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="> 135 degree AND <= 225 degree", output_unit="day", - definition="Days with southerly winds (135° < DD <= 225°)", + definition="Days with southerly winds (135° < DD <= 225°).", source=ECAD_ATBD, short_name="DDsouth", group=IndexGroupRegistry.WIND, @@ -726,7 +726,7 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: indicator=GenericIndicatorRegistry.CountOccurrences, threshold="> 225 degree AND <= 315 degree", output_unit="day", - definition="Days with westerly winds (225° < DD <= 315°)", + definition="Days with westerly winds (225° < DD <= 315°).", source=ECAD_ATBD, short_name="DDwest", group=IndexGroupRegistry.WIND, @@ -734,8 +734,8 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ) GSL = StandardIndex( reference=ECAD_REFERENCE, - indicator=XCLIM_BINDING.GrowingSeasonLength(), - definition="Growing season length", + indicator=XclimBinding.GrowingSeasonLength(), + definition="Growing season length.", source=ECAD_ATBD, short_name="GSL", group=IndexGroupRegistry.COLD, @@ -744,8 +744,8 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ) SPI6 = StandardIndex( reference=ECAD_REFERENCE, - indicator=XCLIM_BINDING.StandardizedPrecipitationIndex6(), - definition="6-Month Standardized Precipitation Index", + indicator=XclimBinding.StandardizedPrecipitationIndex6(), + definition="6-Month Standardized Precipitation Index.", source=ECAD_ATBD, short_name="SPI6", group=IndexGroupRegistry.RAIN, @@ -755,8 +755,8 @@ def to_list(cls: EcadIndexRegistry) -> list[str]: ) SPI3 = StandardIndex( reference=ECAD_REFERENCE, - indicator=XCLIM_BINDING.StandardizedPrecipitationIndex3(), - definition="3-Month Standardized Precipitation Index", + indicator=XclimBinding.StandardizedPrecipitationIndex3(), + definition="3-Month Standardized Precipitation Index.", source=ECAD_ATBD, short_name="SPI3", group=IndexGroupRegistry.RAIN, diff --git a/src/icclim/ecad/xclim_binding.py b/src/icclim/ecad/xclim_binding.py index f79677a2..7fe360a2 100644 --- a/src/icclim/ecad/xclim_binding.py +++ b/src/icclim/ecad/xclim_binding.py @@ -18,9 +18,10 @@ from icclim.models.index_config import IndexConfig -class XCLIM_BINDING: +class XclimBinding: class GrowingSeasonLength(Indicator): - """ + """xclim.growing_season_length. + Fake icclim indicator that redirect to xclim `growing_season_length` indicator. """ @@ -40,11 +41,11 @@ def __call__(self, config: IndexConfig) -> xarray.DataArray: ) def preprocess(self, *args, **kwargs) -> list[xarray.DataArray]: - """Not implemented as xclim indicator already handle pre/post processing""" + """Not implemented as xclim indicator already handle pre/post processing.""" raise NotImplementedError def postprocess(self, *args, **kwargs) -> xarray.DataArray: - """Not implemented as xclim indicator already handle pre/post processing""" + """Not implemented as xclim indicator already handle pre/post processing.""" raise NotImplementedError class StandardizedPrecipitationIndex3(Indicator): @@ -73,11 +74,11 @@ def __call__(self, config: IndexConfig) -> xarray.DataArray: ) def preprocess(self, *args, **kwargs) -> list[xarray.DataArray]: - """Not implemented as xclim indicator already handle pre/post processing""" + """Not implemented as xclim indicator already handle pre/post processing.""" raise NotImplementedError def postprocess(self, *args, **kwargs) -> xarray.DataArray: - """Not implemented as xclim indicator already handle pre/post processing""" + """Not implemented as xclim indicator already handle pre/post processing.""" raise NotImplementedError class StandardizedPrecipitationIndex6(Indicator): @@ -106,9 +107,9 @@ def __call__(self, config: IndexConfig) -> xarray.DataArray: ) def preprocess(self, *args, **kwargs) -> list[xarray.DataArray]: - """Not implemented as xclim indicator already handle pre/post processing""" + """Not implemented as xclim indicator already handle pre/post processing.""" raise NotImplementedError def postprocess(self, *args, **kwargs) -> xarray.DataArray: - """Not implemented as xclim indicator already handle pre/post processing""" + """Not implemented as xclim indicator already handle pre/post processing.""" raise NotImplementedError diff --git a/src/icclim/generic_indices/generic_indicators.py b/src/icclim/generic_indices/generic_indicators.py index d815c119..ce6b6d74 100644 --- a/src/icclim/generic_indices/generic_indicators.py +++ b/src/icclim/generic_indices/generic_indicators.py @@ -58,7 +58,7 @@ class MissingMethodLike(metaclass=abc.ABCMeta): - """workaround xclim missing type""" + """workaround xclim missing type.""" # TODO @bzah: PR that to xclim # https://github.com/cerfacs-globc/icclim/issues/289 diff --git a/src/icclim/generic_indices/threshold.py b/src/icclim/generic_indices/threshold.py index 303d0546..5b9fedbc 100644 --- a/src/icclim/generic_indices/threshold.py +++ b/src/icclim/generic_indices/threshold.py @@ -65,7 +65,8 @@ class ThresholdBuilderInput(TypedDict, total=False): - """ + """Threshold building configuration. + Data transfert object mapping all possible configuration to build any threshold. """ @@ -211,9 +212,7 @@ def build_threshold( class Threshold(metaclass=abc.ABCMeta): - """ - Abstract super class for all thresholds. - """ + """Abstract super class for all thresholds.""" operator: Operator | str value: ThresholdValueType diff --git a/src/icclim/main.py b/src/icclim/main.py index 5bf767bc..1e090ff9 100644 --- a/src/icclim/main.py +++ b/src/icclim/main.py @@ -21,7 +21,7 @@ import xclim from icclim.ecad.ecad_indices import EcadIndexRegistry -from icclim.ecad.xclim_binding import XCLIM_BINDING +from icclim.ecad.xclim_binding import XclimBinding from icclim.generic_indices.generic_indicators import ( GenericIndicator, GenericIndicatorRegistry, @@ -207,7 +207,7 @@ def index( base_period_time_range: Sequence[dt.datetime] | Sequence[str] | None = None, doy_window_width: int = 5, only_leap_years: bool = False, - ignore_Feb29th: bool = False, + ignore_Feb29th: bool = False, # noqa: N803 interpolation: str | QuantileInterpolation = "median_unbiased", out_unit: str | None = None, netcdf_version: str | NetcdfVersion = "NETCDF4", @@ -224,7 +224,7 @@ def index( save_percentile: bool | None = None, indice_name: str | None = None, user_indice: UserIndexDict = None, - transfer_limit_Mbytes: float | None = None, + transfer_limit_Mbytes: float | None = None, # noqa: N803 ) -> Dataset: """ Main entry point for icclim to compute climate indices. @@ -519,7 +519,7 @@ def _handle_deprecated_params( save_thresholds, doy_window_width, indice_name, - transfer_limit_Mbytes, + transfer_limit_Mbytes, # noqa: N803 user_indice, save_percentile, window_width, @@ -588,8 +588,8 @@ def _compute_climate_index( and not isinstance( climate_index, ( - XCLIM_BINDING.StandardizedPrecipitationIndex6, - XCLIM_BINDING.StandardizedPrecipitationIndex3, + XclimBinding.StandardizedPrecipitationIndex6, + XclimBinding.StandardizedPrecipitationIndex3, ), ) ): @@ -649,7 +649,7 @@ def _build_history( initial_history: str | None, indice_computed: Indicator, ) -> str: - from icclim import __version__ as ICCLIM_VERSION + from icclim import __version__ as icclim_version if initial_history is None: # get xclim history @@ -666,7 +666,7 @@ def _build_history( f" [{current_time}]" f" Calculation of {indice_computed.name}" f" index ({config.frequency.adjective})" - f" - icclim version: {ICCLIM_VERSION}" + f" - icclim version: {icclim_version}" ) diff --git a/src/icclim/models/climate_variable.py b/src/icclim/models/climate_variable.py index 4a9225b5..f7d81410 100644 --- a/src/icclim/models/climate_variable.py +++ b/src/icclim/models/climate_variable.py @@ -95,7 +95,7 @@ def build_indicator_metadata( def build_climate_vars( climate_vars_dict: dict[str, InFileDictionary], - ignore_Feb29th: bool, + ignore_Feb29th: bool, # noqa: N803 time_range: Sequence[str], base_period: Sequence[str] | None, standard_index: StandardIndex | None, @@ -277,7 +277,7 @@ def _build_in_file_dict( def _build_climate_var( climate_var_name: str, climate_var_data: InFileDictionary | InFileBaseType, - ignore_Feb29th: bool, + ignore_Feb29th: bool, # noqa: N803 time_range: Sequence[str], standard_var: StandardVariable | None, ) -> ClimateVariable: diff --git a/src/icclim/models/frequency.py b/src/icclim/models/frequency.py index 1061b890..cdd80999 100644 --- a/src/icclim/models/frequency.py +++ b/src/icclim/models/frequency.py @@ -170,7 +170,7 @@ class Frequency: delta: timedelta | np.timedelta64 def build_frequency_kwargs(self) -> dict[str, Any]: - """Build kwargs with possible keys in {"freq", "month", "date_bounds"}""" + """Build kwargs with possible keys in {"freq", "month", "date_bounds"}.""" kwargs = {"freq": self.pandas_freq} if self.indexer is not None: kwargs.update(self.indexer) diff --git a/src/icclim/pre_processing/input_parsing.py b/src/icclim/pre_processing/input_parsing.py index 576909ef..cf6f531b 100644 --- a/src/icclim/pre_processing/input_parsing.py +++ b/src/icclim/pre_processing/input_parsing.py @@ -148,9 +148,7 @@ def read_dataset( def update_to_standard_coords(ds: Dataset) -> Dataset: - """ - Mutate input ds to use more icclim friendly coordinate names. - """ + """Mutate input ds to use more icclim friendly coordinate names.""" # TODO @bzah: see if cf-xarray could replace this # https://github.com/cerfacs-globc/icclim/issues/289 if ds.coords.get("t") is not None: @@ -281,7 +279,7 @@ def guess_input_type(data: DataArray) -> StandardVariable | None: def build_studied_data( original_da: DataArray, time_range: Sequence[str] | None, - ignore_Feb29th: bool, + ignore_Feb29th: bool, # noqa: N803 standard_var: StandardVariable | None, ) -> DataArray: if time_range is not None: @@ -360,12 +358,14 @@ def reduce_only_leap_years(da: DataArray) -> DataArray: return xr.concat(reduced_list, "time") -def read_threshold_DataArray( +def read_threshold_dataarray( thresh_da: DataArray, threshold_min_value: str | float, climatology_bounds: Sequence[str], unit: str, ): + # TODO @bzah: Make sure it is part of the public API or remove it if unused + # https://github.com/cerfacs-globc/icclim/issues/289 if PercentileDataArray.is_compatible(thresh_da): built_value = PercentileDataArray.from_da( standardize_percentile_dim_name(thresh_da), @@ -395,6 +395,20 @@ def build_reference_da( only_leap_years: bool, percentile_min_value: Quantity | None, ) -> DataArray: + """Build a reference DataArray to be used for percentile doy computation. + + Parameters + ---------- + original_da: DataArray + The DataArray used as a base. + base_period_time_range: Sequence[datetime | str] | None + The period to slice in the base DataArray. + only_leap_years: bool + Flag to only use leap years (years with 366 days). + percentile_min_value: Quantity | None + Optional, if set will replace every value from the base DataArray that are below + the `percentile_min_value` with np.nan. + """ reference = original_da if base_period_time_range: check_time_range_pre_validity("base_period_time_range", base_period_time_range) diff --git a/src/icclim/pre_processing/rechunk.py b/src/icclim/pre_processing/rechunk.py index 1d2543b8..e5900e7a 100644 --- a/src/icclim/pre_processing/rechunk.py +++ b/src/icclim/pre_processing/rechunk.py @@ -66,11 +66,12 @@ def create_optimized_zarr_store( filesystem: str | AbstractFileSystem = LOCAL_FILE_SYSTEM, ) -> Dataset: """ + Context manager to create an zarr store given an input netcdf or xarray structure. + -- EXPERIMENTAL FEATURE -- API may changes without deprecation warning! - Context manager to create an zarr store given an input netcdf or xarray structure. - The execution may take a long time + The execution may take a long time. The result is rechunked according to `chunking` schema provided. By default, when leaving `chunking` to None, the resulting zarr store is NOT chunked diff --git a/tests/test_cf_calendar.py b/tests/test_cf_calendar.py index bb8b9c74..4ea2074b 100644 --- a/tests/test_cf_calendar.py +++ b/tests/test_cf_calendar.py @@ -8,7 +8,7 @@ from icclim.models.cf_calendar import CfCalendarRegistry -class Test_CfCalendar: +class TestCfCalendar: def test_error_lookup(self): with pytest.raises(InvalidIcclimArgumentError): CfCalendarRegistry.lookup("NOPE!") @@ -28,22 +28,22 @@ def test_error_lookup(self): def test_success_lookup(self, cal): assert CfCalendarRegistry.lookup(cal).aliases[0] == cal - def test_NO_LEAP(self): + def test_no_leap(self): da = xr.DataArray(pd.date_range("2000", periods=100, freq="YS"), dims=["time"]) res = CfCalendarRegistry.NO_LEAP.is_leap(da) np.testing.assert_array_equal(False, res) - def test_DAYS_360(self): + def test_days_360(self): da = xr.DataArray(pd.date_range("2000", periods=100, freq="YS"), dims=["time"]) res = CfCalendarRegistry.DAYS_360.is_leap(da) np.testing.assert_array_equal(False, res) - def test_ALL_LEAP(self): + def test_all_leap(self): da = xr.DataArray(pd.date_range("2000", periods=100, freq="YS"), dims=["time"]) res = CfCalendarRegistry.ALL_LEAP.is_leap(da) np.testing.assert_array_equal(True, res) - def test_PROLEPTIC_GREGORIAN(self): + def test_proleptic_gregorian(self): res_1 = CfCalendarRegistry.PROLEPTIC_GREGORIAN.is_leap( xr.DataArray(np.asarray([40, 1600])), ) @@ -53,7 +53,7 @@ def test_PROLEPTIC_GREGORIAN(self): np.testing.assert_array_equal(True, res_1) np.testing.assert_array_equal(False, res_2) - def test_JULIAN(self): + def test_julian(self): res_1 = CfCalendarRegistry.JULIAN.is_leap( xr.DataArray(np.asarray([40, 1500, 1600, 1700])), ) @@ -65,7 +65,7 @@ def test_JULIAN(self): "cal", [CfCalendarRegistry.STANDARD, CfCalendarRegistry.NONE], ) - def test_STANDARD(self, cal): + def test_standard(self, cal): res_1 = cal.is_leap(xr.DataArray(np.asarray([40, 1500, 1600]))) res_2 = cal.is_leap(xr.DataArray(np.asarray([42, 1700]))) np.testing.assert_array_equal(True, res_1) diff --git a/tests/test_ecad_indices.py b/tests/test_ecad_indices.py index f10f5b3f..0dfd96b1 100644 --- a/tests/test_ecad_indices.py +++ b/tests/test_ecad_indices.py @@ -14,7 +14,7 @@ def test_listing(): assert len(res) == len(indices) -class Test_index_from_string: +class TestIndexFromString: def test_simple(self): res = EcadIndexRegistry.lookup("SU") assert res == EcadIndexRegistry.SU diff --git a/tests/test_frequency.py b/tests/test_frequency.py index 1524b52b..eb282627 100644 --- a/tests/test_frequency.py +++ b/tests/test_frequency.py @@ -10,13 +10,13 @@ from tests.testing_utils import stub_tas -class Test_build_frequency_over_frequency: +class TestBuildFrequencyOverFrequency: def test_simple(self): freq = FrequencyRegistry.lookup(FrequencyRegistry.YEAR) assert freq == FrequencyRegistry.YEAR -class Test_build_frequency_over_string: +class TestBuildFrequencyOverString: def test_error(self): with pytest.raises(InvalidIcclimArgumentError): FrequencyRegistry.lookup("yolo") @@ -26,7 +26,7 @@ def test_simple(self): assert freq == FrequencyRegistry.YEAR -class Test_build_frequency_over_list: +class TestBuildFrequencyOverList: def test_lookup_list__keyword_error(self): with pytest.raises(InvalidIcclimArgumentError): FrequencyRegistry.lookup(["cacahuêtes"]) @@ -86,7 +86,7 @@ def test_lookup_season__between_dates(self): assert freq.post_processing is not None -class Test_seasons_resampler: +class TestSeasonsResampler: def test_simple(self): # WHEN test_da = filter_months(stub_tas(), [4, 5, 6]).resample(time="YS").mean() diff --git a/tests/test_input_parsing.py b/tests/test_input_parsing.py index 9fb84443..2eb64ceb 100644 --- a/tests/test_input_parsing.py +++ b/tests/test_input_parsing.py @@ -42,7 +42,7 @@ def test_update_to_standard_coords(): assert "time" in res.coords -class Test_ReadDataset: +class TestReadDataset: OUTPUT_NC_FILE = Path("tmp.nc") OUTPUT_NC_FILE_2 = Path("tmp-2.nc") OUTPUT_ZARR_STORE = Path("tmp.zarr") @@ -86,7 +86,7 @@ def _cleanup(self): with contextlib.suppress(FileNotFoundError): f.unlink() - def test_read_dataset_xr_DataArray__simple(self): + def test_read_dataset_xr_dataarray__simple(self): # WHEN res = read_dataset(self.pr_da) # THEN diff --git a/tests/test_main.py b/tests/test_main.py index c5be37b6..7c335847 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -12,7 +12,7 @@ import pint import pytest import xarray as xr -from icclim import __version__ as ICCLIM_VERSION +from icclim import __version__ as icclim_version from icclim.ecad.ecad_indices import EcadIndexRegistry from icclim.generic_indices.threshold import build_threshold from icclim.icclim_exceptions import InvalidIcclimArgumentError @@ -39,12 +39,12 @@ def test_deprecated_indice(log_mock: MagicMock, index_mock: MagicMock): @pytest.mark.slow() -class Test_Integration: +class TestIntegration: """ Integration tests. We are not testing here the actual indices results, they are already tested in `test_ecad_indices.py` as well as in xclim directly. - The goal it to make sure every the whole app can run smoothly + The goal is to make sure the whole app can run smoothly. These tests have side effect: - writing and removing of "out.nc" file @@ -105,7 +105,7 @@ def _cleanup(self): with contextlib.suppress(FileNotFoundError): self.OUTPUT_FILE.unlink() - def test_index_SU(self): + def test_index_su(self): tas = stub_tas(tas_value=26 + K2C) tas[:5] = 0 res = icclim.index( @@ -114,20 +114,20 @@ def test_index_SU(self): out_file=self.OUTPUT_FILE, slice_mode="ms", ) - assert f"icclim version: {ICCLIM_VERSION}" in res.attrs["history"] + assert f"icclim version: {icclim_version}" in res.attrs["history"] assert res.SU.isel(time=0) == 26 # January - def test_index_SU__on_dataset(self): + def test_index_su__on_dataset(self): res = icclim.index( index_name="SU", var_name="data", in_files=self.dataset_with_time_bounds, out_file=self.OUTPUT_FILE, ) - assert f"icclim version: {ICCLIM_VERSION}" in res.attrs["history"] + assert f"icclim version: {icclim_version}" in res.attrs["history"] np.testing.assert_array_equal(0, res.SU) - def test_index_DTR(self): + def test_index_dtr(self): ds = self.data.to_dataset(name="toto") ds["tutu"] = self.data + 10 res = icclim.index( @@ -136,10 +136,10 @@ def test_index_DTR(self): out_file=self.OUTPUT_FILE, var_name=["toto", "tutu"], ) - assert f"icclim version: {ICCLIM_VERSION}" in res.attrs["history"] + assert f"icclim version: {icclim_version}" in res.attrs["history"] np.testing.assert_array_equal(-10, res.DTR) - def test_index_DTR__with_unit_conversion(self): + def test_index_dtr__with_unit_conversion(self): ds = self.data.to_dataset(name="toto") ds["tutu"] = self.data + 10 ds["toto"].attrs["units"] = "K" @@ -149,11 +149,11 @@ def test_index_DTR__with_unit_conversion(self): out_file=self.OUTPUT_FILE, var_name=["toto", "tutu"], ) - assert f"icclim version: {ICCLIM_VERSION}" in res.attrs["history"] + assert f"icclim version: {icclim_version}" in res.attrs["history"] np.testing.assert_array_equal(-10, res.DTR) np.testing.assert_array_equal("°C", res.DTR.attrs["units"]) - def test_index_CD(self): + def test_index_cd(self): ds = self.data.to_dataset(name="tas") ds["pr"] = self.data.copy(deep=True) ds["pr"].attrs[UNITS_KEY] = "kg m-2 d-1" @@ -162,7 +162,7 @@ def test_index_CD(self): in_files=ds, out_file=self.OUTPUT_FILE, ) - assert f"icclim version: {ICCLIM_VERSION}" in res.attrs["history"] + assert f"icclim version: {icclim_version}" in res.attrs["history"] np.testing.assert_array_equal(0, res.CD) def test__preserve_initial_history(self): @@ -170,7 +170,7 @@ def test__preserve_initial_history(self): res = icclim.su(in_files=self.data) assert "pouet pouet cacahuête" in res.attrs["history"] - def test_index_SU__time_selection(self): + def test_index_su__time_selection(self): # WHEN res_string_dates = icclim.index( index_name="SU", @@ -200,7 +200,7 @@ def test_index_SU__time_selection(self): res_datetime_dates.time_bounds, ) - def test_index_SU__pandas_time_slice_mode(self): + def test_index_su__pandas_time_slice_mode(self): # WHEN res = icclim.index( index_name="SU", @@ -225,7 +225,7 @@ def test_index_SU__pandas_time_slice_mode(self): " degC for each 2 wednesday starting week(s)." ) - def test_index_SU__monthy_sampled(self): + def test_index_su__monthy_sampled(self): res = icclim.index( index_name="SU", in_files=self.data, @@ -238,7 +238,7 @@ def test_index_SU__monthy_sampled(self): len(res.time), ) - def test_index_SU__monthy_sampled_cf_time(self): + def test_index_su__monthy_sampled_cf_time(self): res = icclim.index( index_name="SU", in_files=self.data_cf_time, @@ -269,7 +269,7 @@ def test_index_SU__monthy_sampled_cf_time(self): 0, ) - def test_index_SU__DJF_cf_time(self): + def test_index_su__djf_cf_time(self): res = icclim.index( index_name="SU", in_files=self.data_cf_time, @@ -302,7 +302,7 @@ def test_index_SU__DJF_cf_time(self): 0, ) - def test_indices__from_DataArray(self): + def test_indices__from_dataarray(self): res = icclim.indices( index_group=IndexGroupRegistry.HEAT, in_files=self.data, @@ -419,7 +419,7 @@ def test_indices__snow_indices(self): ): assert res[i.short_name] is not None - def test_indices_all_from_Dataset(self): + def test_indices_all_from_dataset(self): res = icclim.indices( index_group="all", in_files=self.full_data, @@ -429,7 +429,7 @@ def test_indices_all_from_Dataset(self): for i in EcadIndexRegistry.values(): assert res[i.short_name] is not None - def test_indices_all_from_Dataset__seasonal_SPI_error(self): + def test_indices_all_from_dataset__seasonal_spi_error(self): with pytest.raises(InvalidIcclimArgumentError): icclim.indices( index_group="SPI3", @@ -448,7 +448,7 @@ def test_spi6__no_time_bounds(self): ).load() assert "time_bounds" not in dataset.coords - def test_indices_all_from_Dataset__seasonal(self): + def test_indices_all_from_dataset__seasonal(self): res = icclim.indices( index_group="all", in_files=self.full_data, @@ -459,7 +459,7 @@ def test_indices_all_from_Dataset__seasonal(self): for i in self.not_spi_indices: assert res[i.short_name] is not None - def test_indices_all_from_Dataset__between_dates_seasonal(self): + def test_indices_all_from_dataset__between_dates_seasonal(self): res = icclim.indices( index_group="all", in_files=self.full_data, @@ -470,7 +470,7 @@ def test_indices_all_from_Dataset__between_dates_seasonal(self): for i in self.not_spi_indices: assert res[i.short_name] is not None - def test_indices_all_from_Dataset__JFM_seasonal(self): + def test_indices_all_from_dataset__jfm_seasonal(self): res = icclim.indices( index_group="all", in_files=self.full_data, @@ -481,7 +481,7 @@ def test_indices_all_from_Dataset__JFM_seasonal(self): for i in self.not_spi_indices: assert res[i.short_name] is not None - def test_indices_all_from_Dataset__between_year_season(self): + def test_indices_all_from_dataset__between_year_season(self): res = icclim.indices( index_group="all", in_files=self.full_data, @@ -527,7 +527,7 @@ def test_indices_all__error(self): ignore_error=False, ) - def test_index_TR(self): + def test_index_tr(self): tas = stub_tas(tas_value=26 + K2C) tas[:5] = 0 res = icclim.index( @@ -536,7 +536,7 @@ def test_index_TR(self): out_file=self.OUTPUT_FILE, slice_mode="ms", ) - assert f"icclim version: {ICCLIM_VERSION}" in res.attrs["history"] + assert f"icclim version: {icclim_version}" in res.attrs["history"] assert res.TR.isel(time=0) == 26 # January def test_index_prcptot(self): diff --git a/tests/test_threshold.py b/tests/test_threshold.py index aee69f08..33b533da 100644 --- a/tests/test_threshold.py +++ b/tests/test_threshold.py @@ -207,11 +207,11 @@ def test_build_per_threshold__from_query(): def test_build_basic_threshold__from_dataarray(): - TIME_RANGE = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") + time_range = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") data = xr.DataArray( - data=(np.full(len(TIME_RANGE), 20).reshape((len(TIME_RANGE), 1, 1))), + data=(np.full(len(time_range), 20).reshape((len(time_range), 1, 1))), dims=["time", "lat", "lon"], - coords={"lat": [42], "lon": [42], "time": TIME_RANGE}, + coords={"lat": [42], "lon": [42], "time": time_range}, attrs={UNITS_KEY: "degC"}, name="toto", ) @@ -224,11 +224,11 @@ def test_build_basic_threshold__from_dataarray(): def test_build_basic_threshold__from_dataset(): - TIME_RANGE = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") + time_range = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") ds = xr.DataArray( - data=(np.full(len(TIME_RANGE), 20).reshape((len(TIME_RANGE), 1, 1))), + data=(np.full(len(time_range), 20).reshape((len(time_range), 1, 1))), dims=["time", "lat", "lon"], - coords={"lat": [42], "lon": [42], "time": TIME_RANGE}, + coords={"lat": [42], "lon": [42], "time": time_range}, attrs={UNITS_KEY: "degC"}, name="tas", ).to_dataset() @@ -242,11 +242,11 @@ def test_build_basic_threshold__from_dataset(): def test_build_basic_threshold__from_dataset__error(): - TIME_RANGE = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") + time_range = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") ds = xr.DataArray( - data=(np.full(len(TIME_RANGE), 20).reshape((len(TIME_RANGE), 1, 1))), + data=(np.full(len(time_range), 20).reshape((len(time_range), 1, 1))), dims=["time", "lat", "lon"], - coords={"lat": [42], "lon": [42], "time": TIME_RANGE}, + coords={"lat": [42], "lon": [42], "time": time_range}, attrs={UNITS_KEY: "degC"}, name="toto", ).to_dataset() @@ -256,14 +256,14 @@ def test_build_basic_threshold__from_dataset__error(): build_threshold(operator=">=", value=ds, threshold_min_value="280K") -class Test_FileBased: +class TestFileBased: IN_FILE_PATH = Path("in.nc") - TIME_RANGE = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") + time_range = pd.date_range(start="2042-01-01", end="2045-12-31", freq="D") data = xr.DataArray( - data=(np.full(len(TIME_RANGE), 20).reshape((len(TIME_RANGE), 1, 1))), + data=(np.full(len(time_range), 20).reshape((len(time_range), 1, 1))), dims=["time", "lat", "lon"], - coords={"lat": [42], "lon": [42], "time": TIME_RANGE}, + coords={"lat": [42], "lon": [42], "time": time_range}, attrs={UNITS_KEY: "degC"}, name="toto", ) diff --git a/tests/test_user_index.py b/tests/test_user_index.py index 89958574..f376773f 100644 --- a/tests/test_user_index.py +++ b/tests/test_user_index.py @@ -12,7 +12,7 @@ from tests.testing_utils import stub_tas -class Test_max: +class TestMax: def test_simple(self): da = stub_tas(use_dask=False) da.data[1] = 20 @@ -30,7 +30,7 @@ def test_simple(self): assert result.data[0] == 20 -class Test_min: +class TestMin: def test_simple(self): da = stub_tas(use_dask=False) da.data[1] = -20 @@ -43,7 +43,7 @@ def test_simple(self): assert result.data[0] == -20 -class Test_mean: +class TestMean: def test_simple(self): da = stub_tas(use_dask=False) da[2] = 366 @@ -56,7 +56,7 @@ def test_simple(self): assert result.data[0] == 2 -class Test_sum: +class TestSum: def test_simple(self): da = stub_tas(use_dask=False) # WHEN @@ -69,7 +69,7 @@ def test_simple(self): assert result.data[0] == 365 -class Test_count_events: +class TestCountEvents: def test_simple(self): # GIVEN da = stub_tas(10, False) @@ -195,7 +195,7 @@ def test_multi_threshold_and(self): assert result.data[0] == 1 -class Test_run_mean: +class TestRunMean: def test_run_mean_min(self): # GIVEN tmax = stub_tas(10, False) @@ -241,7 +241,7 @@ def test_run_mean_max(self): assert result.data[2] == 10 -class Test_run_sum: +class TestRunSum: def test_run_sum_min(self): # GIVEN tmax = stub_tas(10, False) @@ -287,7 +287,7 @@ def test_run_sum_max(self): assert result.data[2] == 20 -class Test_max_consecutive_event_count: +class TestMaxConsecutiveEventCount: def test_simple(self): # GIVEN tmax = stub_tas(10, False) @@ -308,7 +308,7 @@ def test_simple(self): assert result.data[1].isnull() -class Test_anomaly: +class TestAnomaly: def test_simple(self): # GIVEN tmax = stub_tas(10, False) diff --git a/tools/extract_icclim_funs.py b/tools/extract_icclim_funs.py index 82db176d..56bf170b 100644 --- a/tools/extract_icclim_funs.py +++ b/tools/extract_icclim_funs.py @@ -81,7 +81,7 @@ DOC_START_PLACEHOLDER = ".. Generated API comment:Begin\n" DOC_END_PLACEHOLDER = f"{TAB}{TAB}.. Generated API comment:End" MODULE_HEADER = f''' -# ruff: noqa: A001, E501 +# ruff: noqa: A001, E501, N803 """ icclim's API for ECAD indices and generic indices. @@ -239,7 +239,7 @@ def _get_generic_index_declaration(index: GenericIndicator) -> str: def {index.name.lower()}( {fun_signature_args}, ) -> Dataset: - \"\"\"{index.name} + \"\"\"{index.name}. {index.definition} @@ -275,7 +275,7 @@ def _get_standard_index_declaration(index: StandardIndex) -> str: def {index.short_name.lower()}( {fun_signature_args}, ) -> Dataset: - \"\"\"{index.short_name} + \"\"\"{index.short_name}. {index.definition} Source: {index.source}.