Skip to content

Commit

Permalink
Merge 808e192 into 67d806c
Browse files Browse the repository at this point in the history
  • Loading branch information
coxipi committed Jun 11, 2024
2 parents 67d806c + 808e192 commit c23ce97
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 46 deletions.
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"name": "Braun, Marco",
"affiliation": "Ouranos",
"orcid": "0000-0001-5061-3217"
},
{
"name": "Dupuis, Éric",
"affiliation": "Ouranos, Montréal, Québec, Canada",
"orcid": "0000-0001-7976-4596"
}
],
"keywords": [
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Contributors

* Gabriel Rondeau-Genesse <rondeau-genesse.gabriel@ouranos.ca> `@RondeauG <https://github.com/RondeauG>`_
* Marco Braun <Braun.Marco@ouranos.ca> `@vindelico <https://github.com/vindelico>`_
* Éric Dupuis <dupuis.eric@ouranos.ca> `@coxipi <https://github.com/coxipi>`_
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog

0.4.0 (unreleased)
------------------
Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Marco Braun (:user:`vindelico`), Pascal Bourgault (:user:`aulemahal`), Sarah-Claude Bourdeau-Goulet (:user:`Sarahclaude`)
Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Marco Braun (:user:`vindelico`), Pascal Bourgault (:user:`aulemahal`), Sarah-Claude Bourdeau-Goulet (:user:`Sarahclaude`), Éric Dupuis (:user:`coxipi`)

New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -13,13 +13,16 @@ New features and enhancements
* Added style sheet ``transparent.mplstyle`` (:issue:`183`, :pull:`185`)
* Fix ``NaN`` issues, extreme values in sizes legend and added edgecolors in ``fg.matplotlib.scattermap`` (:pull:`184`).
* New function ``fg.data`` for fetching package data and defined `matplotlib` style definitions. (:pull:`211`).
* ``fg.taylordiagram`` can now accept datasets with many dimensions (not only `taylor_params`), provided that they all share the same `ref_std` (e.g. normalized taylor diagrams) (:pull:`214`).
* A new optional way to organize points in a `fg.taylordiagram` with `colors_key`, `markers_key` : DataArrays with a common dimension value or a common attrtibute are grouped with the same color/marker (:pull:`214`).

Breaking changes
^^^^^^^^^^^^^^^^
* `figanos` no longer supports Python 3.8. (:pull:`210`).
* `figanos` now uses a `'src' layout <https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout>`_ for the package. (:pull:`210`).
* `cartopy` has been pinned above v0.23.0 due to a licensing issue. (:pull:`210`).
* `twine` and `wheel` have been removed from the `dev` requirements. (:pull:`210`).
* ``fg.taylordiagram`` returns a tuple of `(fig, floating_ax, legend)` instead of only `floating_ax`. (:pull:`214`).

Internal changes
^^^^^^^^^^^^^^^^
Expand Down
70 changes: 54 additions & 16 deletions docs/notebooks/figanos_docs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1009,23 +1009,61 @@
"source": [
"da_ref = ds_time['tx_max_p50']\n",
"\n",
"# Toy data with same mean as `da_ref` & modify deviations with trigonometric functions\n",
"homogenous_ref_mean = xr.full_like(da_ref, da_ref.mean(dim=\"time\"))\n",
"simd = {}\n",
"for i, f_trig in enumerate([np.cos, lambda x: np.cos(x)**2, np.tan]):\n",
" da = homogenous_ref_mean + f_trig(da_ref.values)\n",
" da.attrs[\"units\"] = da_ref.attrs[\"units\"]\n",
" simd[f\"model{i}\"] = sdba.measures.taylordiagram(sim=da, ref=da_ref)\n",
"\n",
"rands = np.arange(15)\n",
"sims = {}\n",
"for rand in rands:\n",
" name = \"model\" + str(rand)\n",
" da = xr.DataArray(data=np.random.rand(13)*20+290+rand,\n",
" dims={'time': da_ref.time.values})\n",
" da.attrs[\"units\"] = da_ref.units\n",
"fg.taylordiagram(simd, std_range=(0, 1.3), contours=5, contours_kw={'colors': 'green'}, plot_kw={'reference': {'marker':'*'}})\n"
]
},
{
"cell_type": "markdown",
"id": "63",
"metadata": {},
"source": [
"### Normalized taylor diagram\n",
"\n",
" sims[name] = sdba.measures.taylordiagram(da, da_ref)\n",
"If we normalize the standard deviation of our measures, many Taylor diagrams with difference references can be combined in a single plot. In the following example, we have datasets with two variables (`tasmax, pr`) and three location coordinates. For each location (3) and variable (2), a Taylordiagram measure is computed. Each set of correlation and standard deviation is then plotted. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64",
"metadata": {},
"outputs": [],
"source": [
"ds_ref = xc.testing.open_dataset(\"sdba/ahccd_1950-2013.nc\")\n",
"ds_sim = xc.testing.open_dataset(\"sdba/nrcan_1950-2013.nc\")\n",
"for v in ds.data_vars: \n",
" ds_sim[v] = xc.core.units.convert_units_to(ds_sim[v], ds_ref[v], context=\"hydro\")\n",
"\n",
"# Here, we have three locations, two variables. We stack variables to convert from\n",
"# a Dataset to a DataArray.\n",
"da_ref = sdba.stack_variables(ds_ref)\n",
"da_sim = sdba.stack_variables(ds_sim)\n",
"\n",
"# Each location/variable will have its own set of taylor parameters\n",
"out = sdba.measures.taylordiagram(ref=da_ref, sim=da_sim, dim=\"time\")\n",
"\n",
"# If we normalize the taylor diagrams, they can be compared on the same plot\n",
"out[{\"taylor_param\":[0,1]}] = out[{\"taylor_param\":[0,1]}]/out[{\"taylor_param\":0}]\n",
"\n",
"fg.taylordiagram(sims, std_range=(0, 1.3), contours=5, contours_kw={'colors': 'green'}, plot_kw={'reference': {'marker':'*'}})\n"
"# The `markers_key` and `colors_key` are used to separate between two different features. \n",
"# Here, the type of marker is used to distinguish between locations, and the color \n",
"# distinguishes between variables. If those parameters are not specified, then each \n",
"# pair (location, multivar) has simply its own color.\n",
"# NB: Negatives correlations are not plotted\n",
"fg.taylordiagram(out, markers_key=\"location\", colors_key=\"multivar\")\n"
]
},
{
"cell_type": "markdown",
"id": "63",
"id": "65",
"metadata": {},
"source": [
"## Partition plots\n",
Expand All @@ -1045,7 +1083,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "64",
"id": "66",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1095,7 +1133,7 @@
},
{
"cell_type": "markdown",
"id": "65",
"id": "67",
"metadata": {},
"source": [
"Compute uncertainties with xclim and use `fractional_uncertainty` to have the right format to plot."
Expand All @@ -1104,7 +1142,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "66",
"id": "68",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1140,7 +1178,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "67",
"id": "69",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1160,7 +1198,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "68",
"id": "70",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -1178,7 +1216,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/figanos_multiplots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit c23ce97

Please sign in to comment.