Skip to content

Hydrological signature indicators#2267

Open
e-larose wants to merge 135 commits intomainfrom
hydro_indicator
Open

Hydrological signature indicators#2267
e-larose wants to merge 135 commits intomainfrom
hydro_indicator

Conversation

@e-larose
Copy link
Copy Markdown
Contributor

@e-larose e-larose commented Nov 3, 2025

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features)
    • (If applicable) Documentation has been added / updated (for bug fixes / features)
  • CHANGELOG.rst has been updated (with summary of main changes)
    • Link to issue (:issue:number) and pull request (:pull:number) has been added

What kind of change does this PR introduce?

Adds Hydrological signature indicator wrapper

Does this PR introduce a breaking change?

Other information:

@github-actions github-actions bot added the docs Improvements to documenation label Dec 4, 2025
Copy link
Copy Markdown
Collaborator

@aulemahal aulemahal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm late and opiniated...

Comment thread docs/paper/tmp_saved_input_paper.bib Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove before merging!

Comment thread docs/references.bib Outdated
Comment on lines +4233 to +4261
abstract = {The duration of the seasonal snowpack determines numerous aspects of the
water cycle, ecology and the economy in cold and mountainous regions, and is a balance
between the magnitude of accumulated snow and the rate of melt. The contribution of
each component has not been well quantified under contrasting topography and
climatological conditions although this may provide useful insights into how snow cover
duration could respond to climate change. Here, we examined the contribution of the
annual peak snow water equivalent (SWE) and the seasonal melt rate to define the
duration of the snowpack over temperate mountains, using snow data for mountain areas
with different climatological characteristics across the Iberian Peninsula. We used a
daily snowpack database for the period 1980--2014 over Iberia to derive the seasonal
peak SWE, melt rate and season snow cover duration. The influence of peak SWE and melt
rates on seasonal snow cover duration was estimated using a stepwise linear model
approach. The stepwise linear models showed high R-adjusted values (average R-adjusted
= 0.7), without any clear dependence on the elevation or geographical location. In
general, the peak SWE influenced the snow cover duration over all of the mountain areas
analysed to a greater extent than the melt rates (89.1\%, 89.2\%, 81.6\%, 93.2\% and
95.5\% in the areas for the Cantabrian, Central, Iberian, Pyrenees and Sierra Nevada
mountain ranges, respectively). At these colder sites, the melt season occurs mostly in
the spring and tends to occur very fast. In contrast, the areas where the melt rates
dominated snow cover duration were located systematically at lower elevations, due to
the high interannual variability in the occurrence of annual peak SWE (in winter or
early spring), yielding highly variable melt rates. However, in colder sites the melt
season occurs mostly in spring and it is very fast in most of the years. The results
highlight the control that the seasonal precipitation patterns, in combination with
temperature, exert on the seasonal snow cover duration by influencing the peak SWE and
suggest a future increased importance of melt rates as temperatures increase. Despite
the high climatological variability of the Iberian mountain ranges, the results showed
a consistent behaviour along the different mountain ranges, indicating that the methods
and results may be transferrable to other temperate mountain areas of the world.}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the full abstract here ? For a smaller file and for coherence with the other entires, I think we could remove the abstracts here.

Comment thread src/xclim/indicators/land/_snow.py Outdated
Comment on lines +285 to +292
days_with_snowpack = Snow(
title="Days with snowpack",
identifier="days_with_snowpack",
units="days",
long_name="Days with snowpack",
description="The total number of days with snow water equivalent (SWE) above a given threshold.",
compute=xci.days_with_snowpack,
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already exists as snw_days_above, no ?

Comment thread src/xclim/indices/_hydrology.py Outdated
Comment on lines +769 to +771
@declare_units(swe="[length]", thresh="[length]")
def days_with_snowpack(
swe: xarray.DataArray,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see the nuance now. I would argue that swe is exactly the same as snw and the difference in variable doesn't justify a new indicator. Also, snw is the CMIP name, which is why we chose it in xclim.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think of a PR I co-authored with Ludwig, I could dig this up.

There is the special field [precipitation], which can do automatic conversions. Having this with snw -> swe would be dangerous. What you say is that user should do all their work in snw, then convert to swe at the end, correct? snw_to_snd functions already exist, it would be easy to add a new converter with the correct density to have snw_to_swe

Copy link
Copy Markdown
Collaborator

@aulemahal aulemahal Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of xclim, what I think is that we should try to limit the number of non-conventional variables to a minimum. swe is so close to snw that I don't think it warrants a special treatment.

Also, days_with_snowpack and snw_days_above are two very different names for the same thing. The {var}_days_above construct being the choice made by xclim for clear and systematic naming, unless days_with_snowpack is a jargon term refering to a (domain-)specific algorithm.

Finally, if we really need to keep this indicator, I would suggest removing the compute function nonetheless and simply creating a day_with_snowpack in indicators/land/_snow.py instead.

But outside of the context of xclim, in my very personal opinion, I find talking about snow in terms of liquid water a bit weird. You don't need to melt it to study it on a computer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about the distinction and already removed it.

Comment thread src/xclim/indices/_hydrology.py Outdated
Comment on lines +859 to +861
@declare_units(swe="[length]", q="[discharge]")
def lag_snowpack_flow_peaks(
swe: xarray.DataArray,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. Please use snw.

Comment thread tests/conftest.py Outdated
Comment thread .gitignore
Comment on lines 116 to +117
docs/paper/tmp_saved_input_paper.bib
docs/tmp_saved_input_references.bib
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docs/paper/tmp_saved_input_paper.bib
docs/tmp_saved_input_references.bib
docs/tmp_saved_input_references.bib
docs/paper/tmp_saved_input_paper.bib

revert unneeded change

Comment thread src/xclim/indices/_hydrology.py Outdated
Comment on lines +769 to +771
@declare_units(swe="[length]", thresh="[length]")
def days_with_snowpack(
swe: xarray.DataArray,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think of a PR I co-authored with Ludwig, I could dig this up.

There is the special field [precipitation], which can do automatic conversions. Having this with snw -> swe would be dangerous. What you say is that user should do all their work in snw, then convert to swe at the end, correct? snw_to_snd functions already exist, it would be easy to add a new converter with the correct density to have snw_to_swe

Zeitsperre and others added 2 commits February 6, 2026 16:00
Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com>
@Zeitsperre
Copy link
Copy Markdown
Collaborator

@coxipi I performed a merge of main, but I found that there were quite a few conflicts from the previous hydro indice PR (as though this branch was based off an older version before it was merged to main).

I may have totally botched the merge, so apologies.

@coxipi
Copy link
Copy Markdown
Contributor

coxipi commented Feb 6, 2026

@Zeitsperre am I in charge of this PR now 😆 ? oh wait, are your referring to a conflict from a change I made in another PR?

Anyways, we can discuss what to do with this in the next meeting. I'm not sure what your botched merge entails, but we'll figure something out

@Zeitsperre
Copy link
Copy Markdown
Collaborator

Zeitsperre commented Feb 6, 2026

@Zeitsperre am I in charge of this PR now 😆 ? oh wait, are your referring to a conflict from a change I made in another PR?

Nope, just the last merge commit I performed this morning. I have some time to see if I can clean it up before Miller Time.

Update: Managed to clean up the mess. Testing is failing as sen_slope is not a resampled indicator, but otherwise PR is looking reasonable.

Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com>
Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com>
@Zeitsperre Zeitsperre requested a review from coxipi April 14, 2026 14:30
@Zeitsperre Zeitsperre assigned Zeitsperre and coxipi and unassigned Zeitsperre Apr 14, 2026
Comment thread CHANGELOG.rst
v0.60.0 (2026-01-23)
--------------------
Contributors to this version: Éric Dupuis (:user:`coxipi`), Trevor James Smith (:user:`Zeitsperre`), Juliette Lavoie (:user:`juliettelavoie`), Ève Larose (:user:`e-larose`), Faisal Mahmood (:user:`faimahsho`), David Huard (:user:`huard`), Pascal Bourgault (:user:`aulemahal`).
Contributors to this version: Éric Dupuis (:user:`coxipi`), Trevor James Smith (:user:`Zeitsperre`), Juliette Lavoie (:user:`juliettelavoie`), Faisal Mahmood (:user:`faimahsho`), David Huard (:user:`huard`), Pascal Bourgault (:user:`aulemahal`).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ève's other PR made it into the last version ;)

Suggested change
Contributors to this version: Éric Dupuis (:user:`coxipi`), Trevor James Smith (:user:`Zeitsperre`), Juliette Lavoie (:user:`juliettelavoie`), Faisal Mahmood (:user:`faimahsho`), David Huard (:user:`huard`), Pascal Bourgault (:user:`aulemahal`).
Contributors to this version: Éric Dupuis (:user:`coxipi`), Trevor James Smith (:user:`Zeitsperre`), Juliette Lavoie (:user:`juliettelavoie`), Ève Larose (:user:`e-larose`), Faisal Mahmood (:user:`faimahsho`), David Huard (:user:`huard`), Pascal Bourgault (:user:`aulemahal`).

Comment thread tests/test_land.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to remove the print calls!

Comment thread tests/test_snow.py

import numpy as np
import pytest
import xarray as xr
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import xarray as xr
from xarray import DataArray

Comment thread tests/test_snow.py
out = land.days_with_snowpack(swe, freq="YS")

assert out.attrs["units"] == "days"
assert isinstance(out, xr.DataArray)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert isinstance(out, xr.DataArray)
assert isinstance(out, DataArray)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements to documenation indicators Climate indices and indicators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hydrological signature Indicators

5 participants