Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perturbed indicators #54

Merged
merged 17 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ jobs:
create-args: >-
mamba
python=${{ matrix.python-version }}
- name: Downgrade intake-esm (for xscen) and xclim
if: matrix.python-version == '3.9'
run: |
micromamba install -y intake-esm=2023.11.10
micromamba install -y xclim=0.47.0
- name: Conda and Mamba versions
run: |
mamba --version
Expand Down
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog

v0.4.0 (unreleased)
-------------------
Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Thomas-Charles Fortier Filion (:user:`TC-FF`).
Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Thomas-Charles Fortier Filion (:user:`TC-FF`), Gabriel Rondeau-Genesse (:user:`RondeauG`).

New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -15,10 +15,13 @@ New features and enhancements
* Added new functions to `xhydro.frequency_analysis.local` to calculate plotting positions and to prepare plots. (:pull:`87`).
* `xscen` now supports Python3.12. (:pull:`99`).
* `xscen` now supports `pandas` >= 2.2.0, `xarray` >= 2023.11.0, and `xclim` >= 0.47.0. (:pull:`99`).
* Added `xh.cc.sampled_indicators` to compute future indicators using a perturbation approach and random sampling. (:pull:`54`).

Breaking changes
^^^^^^^^^^^^^^^^
* Added `pooch` as an installation dependency. (:pull:`62`).
* `xhydro` now requires `xarray`>=2023.11.0, `xclim`>=0.48.2, `xscen`>=0.8.3, and, indirectly, `pandas`>=2.2.0. The main breaking change is in how yearly frequencies are called ('YS-' instead of 'AS-'). (:pull:`54`).
* Functions that output a dict with keys as xrfreq (namely, ``xh.indicators.compute_indicators``) will now return the new nomenclature (e.g. "YS-JAN" instead of "AS-JAN"). (:pull:`54`).

Internal changes
^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Welcome to xHydro's documentation!
installation
usage
notebooks/local_frequency_analysis
notebooks/climate_change
planification
apidoc/modules
contributing
Expand Down
640 changes: 640 additions & 0 deletions docs/notebooks/climate_change.ipynb
RondeauG marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

35 changes: 7 additions & 28 deletions docs/notebooks/local_frequency_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds.streamflow.dropna('time', 'all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
"ds.streamflow.dropna('time', how='all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
]
},
{
Expand Down Expand Up @@ -100,7 +100,7 @@
" \"spring\": {\"date_bounds\": [\"02-11\", \"06-19\"]},\n",
" \"summer\": {\"doy_bounds\": [152, 243]},\n",
" \"fall\": {\"month\": [9, 10, 11]},\n",
" \"winter\": {\"season\": ['DJF'], \"freq\": \"AS-DEC\"}, # To correctly wrap around the year, we need to specify the resampling frequency.\n",
" \"winter\": {\"season\": ['DJF'], \"freq\": \"YS-DEC\"}, # To correctly wrap around the year, we need to specify the resampling frequency.\n",
" \"august\": {\"month\": [8]},\n",
" \"annual\": {}\n",
" }"
Expand Down Expand Up @@ -140,13 +140,6 @@
"ds_4fa"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -155,7 +148,7 @@
},
"outputs": [],
"source": [
"ds_4fa.streamflow_max_summer.dropna('time', 'all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
"ds_4fa.streamflow_max_summer.dropna('time', how='all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
]
},
{
Expand Down Expand Up @@ -219,7 +212,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds_4fa.streamflow_max_custom.dropna('time', 'all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
"ds_4fa.streamflow_max_custom.dropna('time', how='all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
]
},
{
Expand Down Expand Up @@ -256,7 +249,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds_4fa.volume_sum_spring.dropna('time', 'all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
"ds_4fa.volume_sum_spring.dropna('time', how='all').hvplot(x='time', grid=True, widget_location='bottom', groupby='id')"
]
},
{
Expand Down Expand Up @@ -329,7 +322,7 @@
"source": [
"In a future release, plotting will be handled by a proper function. For now, we'll show an example in this Notebook using preliminary utilities.\n",
"\n",
"`xhfa.local._prepare_plots` generates datapoints required to plot the results of the frequency analysis. If `log=True`,will it return log-spaced x values between `xmin` and `xmax`.\n"
"`xhfa.local._prepare_plots` generates datapoints required to plot the results of the frequency analysis. If `log=True`, it will return log-spaced x values between `xmin` and `xmax`.\n"
]
},
{
Expand Down Expand Up @@ -390,20 +383,6 @@
"#And now combining the plots\n",
"p1 * p2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -422,7 +401,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.12.2"
},
"vscode": {
"interpreter": {
Expand Down
8 changes: 4 additions & 4 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ dependencies:
- pydantic >=2.0,<2.5.3 # FIXME: Remove pin once our dependencies (xclim, xscen) support pydantic 2.5.3
- spotpy
- statsmodels
- xarray
- xclim >=0.47.0
- xscen >=0.7.1
- xarray >=2023.11.0
- xclim >=0.48.2
- xscen >=0.8.3
- pip
- pip:
- xdatasets
- xdatasets >=0.3.1
# Dev
- black ==24.1.1
- blackdoc ==0.3.9
Expand Down
8 changes: 4 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ dependencies:
- pydantic >=2.0,<2.5.3 # FIXME: Remove pin once our dependencies (xclim, xscen) support pydantic 2.5.3
- spotpy
- statsmodels
- xarray
- xclim >=0.47.0
- xscen >=0.7.1
- xarray >=2023.11.0
- xclim >=0.48.2
- xscen >=0.8.3
- pip
- pip:
- xdatasets
- xdatasets >=0.3.1
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ dependencies = [
"pydantic>=2.0,<2.5.3",
"spotpy",
"statsmodels",
"xarray",
"xclim>=0.47.0",
"xarray>=2023.11.0",
"xclim>=0.48.2",
"xdatasets>=0.3.1",
"xscen>=0.7.1"
"xscen>=0.8.3"
]

[project.optional-dependencies]
Expand Down
Loading