Skip to content

Commit

Permalink
add water cycle intensity indices and indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
huard committed Oct 8, 2024
1 parent b7b4630 commit 38595a3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions xclim/data/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1403,5 +1403,11 @@
"abstract": "Les unités de froid (chill units) sont une mesure du potentiel de débourrement de différentes récoltes basée sur le modèle Utah.",
"long_name": "Unités de froid selon le modèle Utah",
"description": "Les unités de froid (chill units) sont une mesure du potentiel de débourrement de différentes récoltes basée sur le modèle Utah."
},
"WATER_CYCLE_INTENSITY": {
"title": "Intensité du cycle de l'eau",
"long_name": "Intensité du cycle de l'eau",
"description": "Indice {freq} de l'intensité du cycle de l'eau, défini comme la somme de la précipitation et de l'évapotranspiration.",
"abstract": "la somme de la précipitation et de l'évapotranspiration."
}
}
6 changes: 6 additions & 0 deletions xclim/data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ variables:
cell_methods: "time: mean"
description: The amount of water, in all phases, flowing in the river channel and flood plain.
standard_name: water_volume_transport_in_river_channel
evspsbl:
canonical_units: kg m-2 s-1
cell_methods: "time: mean"
description: Actual evapotranspiration flux.
dimensions: "[discharge]"
standard_name: water_evapotranspiration_flux
evspsblpot:
canonical_units: kg m-2 s-1
cell_methods: "time: mean"
Expand Down
15 changes: 14 additions & 1 deletion xclim/indicators/atmos/_precip.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"standardized_precipitation_index",
"warm_and_dry_days",
"warm_and_wet_days",
"water_cycle_intensity",
"wet_precip_accumulation",
"wet_spell_frequency",
"wet_spell_max_length",
Expand Down Expand Up @@ -790,7 +791,19 @@ class HrPrecip(Hourly):
units=["", "", "days"],
abstract="Start time, end time and length of the rain season, notably useful for West Africa (sivakumar, 1998). "
"The rain season starts with a period of abundant rainfall, followed by a period without prolonged dry sequences, "
"which must happen before a given date. The rain season stops during a dry period happening after a given date",
"which must happen before a given date. The rain season stops during a dry period happening after a given date.",
cell_methods="",
compute=indices.rain_season,
)

water_cycle_intensity = PrecipWithIndexing(
title="Water cycle intensity",
identifier="water_cycle_intensity",
realm="atmos",
units="mm",
long_name="Water cycle intensity",
description="The {freq} water cycle intensity, defined as the sum of precipitation and actual evapotranspiration.",
abstract="The sum of precipitation and actual evapotranspiration.",
cell_methods="time: sum over days",
compute=indices.water_cycle_intensity,
)
34 changes: 34 additions & 0 deletions xclim/indices/_multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"warm_and_dry_days",
"warm_and_wet_days",
"warm_spell_duration_index",
"water_cycle_intensity",
"winter_rain_ratio",
]

Expand Down Expand Up @@ -1865,3 +1866,36 @@ def blowing_snow(
out = cond.resample(time=freq).sum(dim="time")
out = out.assign_attrs(units=to_agg_units(out, snd, "count"))
return out


@declare_units(pr="[precipitation]", evspsbl="[precipitation]")
def water_cycle_intensity(
pr: xarray.DataArray, evspsbl: xarray.DataArray, freq="YS"
) -> xarray.DataArray:
"""Water cycle intensity.
The sum of precipitation and actual evapotranspiration.
Parameters
----------
pr : xarray.DataArray
Precipitation flux.
evspsbl : xarray.DataArray
Actual evapotranspiration flux.
Returns
-------
xarray.DataArray
The sum of precipitation and actual evapotranspiration for each period.
References
----------
:cite:cts:`huntington_2018`
"""
pr = convert_units_to(pr, evspsbl)

# Water cycle intensity
wci = pr + evspsbl
wci = rate2amount(wci)
wci = wci.resample(time=freq).sum(dim="time").assign_attrs(units=wci.units)
return wci

0 comments on commit 38595a3

Please sign in to comment.