Skip to content

Commit

Permalink
Merge branch 'main' into fix-141
Browse files Browse the repository at this point in the history
  • Loading branch information
juliettelavoie committed Feb 21, 2024
2 parents 180ce5a + 3868797 commit cf62642
Show file tree
Hide file tree
Showing 11 changed files with 423 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"project_slug": "figanos",
"project_short_description": "Outils pour produire des graphiques informatifs sur les impacts des changements climatiques.",
"pypi_username": "Sarahclaude",
"version": "0.2.2",
"version": "0.3.0",
"use_pytest": "y",
"use_black": "y",
"use_conda": "y",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: 'Dependency Review'
uses: actions/dependency-review-action@4901385134134e04cec5fbe5ddfe3b2c5bd5d976
uses: actions/dependency-review-action@be8bc500ee15e96754d2a6f2d34be14e945a46f3
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: Upload artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@e8893c57a1f3a2b659b6b55564fdfdbbd2982911 # 3.24.0
uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # 3.24.3
with:
sarif_file: results.sarif
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
hooks:
- id: rst-inline-touching-normal
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
rev: 24.2.0
hooks:
- id: black
exclude: ^docs/
Expand All @@ -53,7 +53,7 @@ repos:
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==24.1.1' ]
additional_dependencies: [ 'black==24.2.0' ]
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Changelog
=========

0.3.0 (Unreleased)
0.3.0 (2024-02-16)
------------------
Contributors to this version: Sarah-Claude Bourdeau-Goulet (:user:`Sarahclaude`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`), Juliette Lavoie (:user:`juliettelavoie`), Gabriel Rondeau-Genesse (:user:`RondeauG`).

Expand All @@ -19,6 +19,7 @@ New features and enhancements
* New function ``fg.partition`` (:pull:`134`).
* Add wrapper around ``xarray.plot.facetgrid`` for map functions (``fg.gridmap``, ``fg.scattermap``, ``fg.hatchmap``). (:issue:`51`, :pull:`136`).
* `figanos` now uses `Semantic Versioning v2.0 <https://semver.org/spec/v2.0.0.html>`_. (:pull:`143`).
* Add wrapper around ``xarray.plot.facetgrid`` for multiple functions (``fg.gridmap``, ``fg.scattermap``, ``fg.hatchmap``, ``fg.timeseries``). (:issue:`51`, :pull:`136`).

Bug fixes
^^^^^^^^^
Expand Down
41 changes: 39 additions & 2 deletions docs/notebooks/figanos_docs.ipynb

Large diffs are not rendered by default.

111 changes: 71 additions & 40 deletions docs/notebooks/figanos_multiplots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Figanos multiple plots"
"# Multiple plots"
]
},
{
Expand All @@ -17,7 +17,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"is_executing": true
}
},
"outputs": [],
"source": [
"# import necessary libraries\n",
Expand All @@ -30,6 +34,13 @@
"fg.utils.set_mpl_style('ouranos')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Timeseries"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -41,6 +52,41 @@
"opened = xr.open_dataset(url, decode_timedelta=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds_time = opened.isel(lon=[500], lat=[150, 250])\n",
"im = fg.timeseries({'p50': ds_time.tx_max_p50, 'p90': ds_time.tx_max_p90},\n",
" plot_kw={'p50': {\"col\": \"lat\"}, 'p90': {\"col\": \"lat\"}},\n",
" fig_kw={'figsize':(10,4)},\n",
" legend=\"edge\",\n",
" show_lat_lon=True)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#creating fake scenarios\n",
"ds_time = ds_time[['tx_max_p10', 'tx_max_p50', 'tx_max_p90']]\n",
"data = {'tasmax_ssp434': ds_time,\n",
" 'tasmax_ssp245': ds_time.copy()-10,\n",
" 'tasmax_ssp585': ds_time.copy()+10}\n",
"\n",
"fg.timeseries(data=data,\n",
" legend='facetgrid',\n",
" show_lat_lon=False,\n",
" fig_kw = {'figsize':(9,4)},\n",
" plot_kw={'tasmax_ssp434': {\"col\": \"lat\"}, 'tasmax_ssp245': {\"col\": \"lat\"}, \"tasmax_ssp585\": {\"col\": \"lat\"}}\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -127,45 +173,30 @@
"metadata": {},
"outputs": [],
"source": [
"# from xclim import ensembles\n",
"# urls = ['https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/NorESM1-M_rcp85_prcptot_monthly.nc',\n",
"# 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/MPI-ESM-LR_rcp85_prcptot_monthly.nc',\n",
"# 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/IPSL-CM5B-LR_rcp85_prcptot_monthly.nc',\n",
"# ]\n",
"# ens = ensembles.create_ensemble(urls)\n",
"# s8=[]\n",
"# i5=[]\n",
"# for horizon in [[\"2020\", \"2050\"],['2050','2080']]:\n",
"# fut = ens.sel(time=slice(*map(str, horizon))).prcptot\n",
"# ref = ens.sel(time=slice(\"1990\", \"2020\")).prcptot\n",
"# chng_f= ensembles.robustness_fractions(\n",
"# fut, ref, test=\"threshold\", abs_thresh=2\n",
"# )\n",
"# s8.append(chng_f.where(chng_f.changed>0.8).assign_coords(horizon=horizon).changed)\n",
"# i5.append(chng_f.where(chng_f.changed<0.5).assign_coords(horizon=horizon).changed)\n",
"# sup_8=xr.concat(s8, dim='horizon')\n",
"# inf_5=xr.concat(i5, dim='horizon') \n",
"from xclim import ensembles\n",
"sup_305k = ds_space.where(ds_space.tx_max_p50>305)\n",
"inf_300k = ds_space.where(ds_space.tx_max_p50<300)\n",
"\n",
"# im = fg.hatchmap({'sup_8': sup_8, 'inf_5': inf_5},\n",
"# plot_kw={\n",
"# 'sup_8': {\n",
"# 'hatches': '*',\n",
"# 'col': 'horizon',\n",
"# \"x\": \"lon\",\n",
"# \"y\": \"lat\"\n",
"# },\n",
"# 'inf_5': {\n",
"# 'hatches': 'x',\n",
"# 'col': 'horizon',\n",
"# \"x\": \"lon\",\n",
"# \"y\": \"lat\"\n",
"# },\n",
"# },\n",
"# features = ['coastline','ocean'],\n",
"# frame = True,\n",
"# legend_kw = {'title': 'Ensemble change'})\n",
"im = fg.hatchmap({'sup_305k': sup_305k, 'inf_300k': inf_300k},\n",
" plot_kw={\n",
" 'sup_305k': {\n",
" 'hatches': '*',\n",
" 'col': 'time',\n",
" \"x\": \"lon\",\n",
" \"y\": \"lat\"\n",
" },\n",
" 'inf_300k': {\n",
" 'hatches': 'x',\n",
" 'col': 'time',\n",
" \"x\": \"lon\",\n",
" \"y\": \"lat\"\n",
" },\n",
" },\n",
" features = ['coastline','ocean'],\n",
" frame = True,\n",
" legend_kw = {'title': 'Ensemble change'})\n",
"\n",
"# im.fig.suptitle(\"Multiple hatchmaps\", y=1.08)\n"
"im.fig.suptitle(\"Multiple hatchmaps\", y=1.08)\n"
]
},
{
Expand Down Expand Up @@ -336,7 +367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.0"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion figanos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Sarah-Claude Bourdeau-Goulet"""
__email__ = "bourdeau-goulet.sarah-claude@ouranos.ca"
__version__ = "0.2.2"
__version__ = "0.3.0"

from . import matplotlib
from ._logo import Logos

0 comments on commit cf62642

Please sign in to comment.