Skip to content

Commit

Permalink
Update ensemble notebook to use latest xclim (#98)
Browse files Browse the repository at this point in the history
Fixes 1/2 of
Ouranosinc/pavics-jupyter-env-issues#11

For new Jupyter env in
Ouranosinc/PAVICS-e2e-workflow-tests#137

### Changes

* Updates the ensemble analysis tools to use the latest xclim
conventions
* Updates the pre-commit configuration
* Uses `https` for external links where possible
* Fixes a small typo in the ReadMe file
  • Loading branch information
tlvu authored Nov 14, 2024
2 parents b599595 + dd31057 commit 32f257c
Show file tree
Hide file tree
Showing 45 changed files with 3,637 additions and 3,096 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PyCharm
.idea/
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
rev: v3.17.0
hooks:
- id: pyupgrade
args: [ '--py37-plus' ]
args: [ '--py310-plus' ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand All @@ -23,7 +23,7 @@ repos:
rev: 24.10.0
hooks:
- id: black
args: [ '--target-version=py37' ]
args: [ '--target-version=py310' ]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
Expand All @@ -33,11 +33,11 @@ repos:
rev: 1.8.7
hooks:
- id: nbqa-pyupgrade
args: [ '--py37-plus' ]
additional_dependencies: [ 'pyupgrade==v3.16.0' ]
args: [ '--py310-plus' ]
additional_dependencies: [ 'pyupgrade==v3.17.0' ]
- id: nbqa-black
args: [ '--target-version=py37' ]
additional_dependencies: [ 'black==24.4.2' ]
args: [ '--target-version=py310' ]
additional_dependencies: [ 'black==24.10.0' ]
- id: nbqa-isort
args: [ '--profile=black' ]
additional_dependencies: [ 'isort==5.13.2' ]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ For testing, you can run `npx http-server src -c-1` to view the site locally, or

# Python environment.yml

To ensure notebooks and exemples will run on the platform correctly it is advised to use the most recent PAVICS environment.yml
To ensure notebooks and examples will run on the platform correctly it is advised to use the most recent PAVICS environment.yml
https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/blob/master/docker/environment.yml
2 changes: 1 addition & 1 deletion content/homepage/hydro-intro_en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PAVICS offers a suite of tools to streamline the analysis of climate change's impacts on hydrology. It relies on [Raven](http://raven.uwaterloo.ca/), an hydrological modeling framework that lets hydrologists define custom hydrological models or emulate existing ones. These models are minimally driven by daily time series of temperature and precipitation, and return series of flow and state variables such as snow pack and soil water.
PAVICS offers a suite of tools to streamline the analysis of climate change's impacts on hydrology. It relies on [Raven](https://raven.uwaterloo.ca/), an hydrological modeling framework that lets hydrologists define custom hydrological models or emulate existing ones. These models are minimally driven by daily time series of temperature and precipitation, and return series of flow and state variables such as snow pack and soil water.

The platform can, among other functionalities
* simulate stream flow using one of four global models: HMETS, GR4J-CemaNeige, HBV-EC and MOHYSE;
Expand Down
2 changes: 1 addition & 1 deletion content/homepage/hydro-intro_fr.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PAVICS offre une gamme d'outils pour faciliter l'analyse des impacts des changements climatiques sur l'hydrologie. Elle s'appuie pour cela sur [Raven](http://raven.uwaterloo.ca/), un cadre de modélisation hydrologique qui permet d'assembler différents processus hydrologiques pour créer des modèles sur mesure ou émuler des modèles existant. Ces modèles doivent minimalement être forcés par des séries journalières de température et précipitation, et retournent des séries de débits en rivière et les variables d'état du modèle, comme la neige ou l'eau dans le sol.
PAVICS offre une gamme d'outils pour faciliter l'analyse des impacts des changements climatiques sur l'hydrologie. Elle s'appuie pour cela sur [Raven](https://raven.uwaterloo.ca/), un cadre de modélisation hydrologique qui permet d'assembler différents processus hydrologiques pour créer des modèles sur mesure ou émuler des modèles existant. Ces modèles doivent minimalement être forcés par des séries journalières de température et précipitation, et retournent des séries de débits en rivière et les variables d'état du modèle, comme la neige ou l'eau dans le sol.

La plateforme permet entre autres de
* simuler les débits en rivière par quatre modèles globaux: HMETS, GR4J-CemaNeige, HBV-EC et MOHYSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7331,12 +7331,11 @@
if (!diagrams.length) {
return;
}
const mermaid = (await import("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs")).default;
const mermaid = (await import("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.6.0/mermaid.esm.min.mjs")).default;
const parser = new DOMParser();

mermaid.initialize({
maxTextSize: 100000,
maxEdges: 100000,
startOnLoad: false,
fontFamily: window
.getComputedStyle(document.body)
Expand Down Expand Up @@ -7407,8 +7406,7 @@
let results = null;
let output = null;
try {
let { svg } = await mermaid.render(id, raw, el);
svg = cleanMermaidSvg(svg);
const { svg } = await mermaid.render(id, raw, el);
results = makeMermaidImage(svg);
output = document.createElement("figure");
results.map(output.appendChild, output);
Expand All @@ -7423,38 +7421,6 @@
parent.appendChild(output);
}


/**
* Post-process to ensure mermaid diagrams contain only valid SVG and XHTML.
*/
function cleanMermaidSvg(svg) {
return svg.replace(RE_VOID_ELEMENT, replaceVoidElement);
}


/**
* A regular expression for all void elements, which may include attributes and
* a slash.
*
* @see https://developer.mozilla.org/en-US/docs/Glossary/Void_element
*
* Of these, only `<br>` is generated by Mermaid in place of `\n`,
* but _any_ "malformed" tag will break the SVG rendering entirely.
*/
const RE_VOID_ELEMENT =
/<\s*(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\s*([^>]*?)\s*>/gi;

/**
* Ensure a void element is closed with a slash, preserving any attributes.
*/
function replaceVoidElement(match, tag, rest) {
rest = rest.trim();
if (!rest.endsWith('/')) {
rest = `${rest} /`;
}
return `<${tag} ${rest}>`;
}

void Promise.all([...diagrams].map(renderOneMarmaid));
});
</script>
Expand Down Expand Up @@ -7528,7 +7494,7 @@
</div>
<div class="jp-InputArea jp-Cell-inputArea"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput" data-mime-type="text/markdown">
<p>PAVICS climate <a href="/datasets.html" target="_blank">datasets<a></a> are hosted on a <a href="https://www.unidata.ucar.edu/software/tds/current/" target="_blank">THREDDS data server</a> at <a href="https://pavics.ouranos.ca/thredds" target="_blank">https://pavics.ouranos.ca/thredds</a>. Although THREDDS provides a user-interface for browsing datasets, it is often more practical to navigate the catalogue programatically. The tutorial introduces the <a href="https://unidata.github.io/siphon/latest/index.html" target="_blank">siphon</a> library to browse the THREDDS catalog, and <a href="http://xarray.pydata.org/en/stable/index.html" target="_blank">xarray</a> to open a streaming connection to the remote data.</a></p>
<p>PAVICS climate <a href="/datasets.html" target="_blank">datasets<a></a> are hosted on a <a href="https://www.unidata.ucar.edu/software/tds/current/" target="_blank">THREDDS data server</a> at <a href="https://pavics.ouranos.ca/thredds" target="_blank">https://pavics.ouranos.ca/thredds</a>. Although THREDDS provides a user-interface for browsing datasets, it is often more practical to navigate the catalogue programatically. The tutorial introduces the <a href="https://unidata.github.io/siphon/latest/index.html" target="_blank">siphon</a> library to browse the THREDDS catalog, and <a href="https://docs.xarray.dev/en/stable/index.html" target="_blank">xarray</a> to open a streaming connection to the remote data.</a></p>
<p>More specifically, the tutorial demonstrates how to access an ensemble of climate simulations, namely Ouranos' Ensemble of Bias-adjusted Simulations - Global models CMIP6 - RDRS v2.1 <a href="https://www.nature.com/articles/s41597-023-02855-z" target="_blank"><strong>(ESPO-G6-R2 v1.0)</strong></a>, using python commands. The ensemble contains <a href="https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/datasets/simulations/bias_adjusted/cmip6/ouranos/ESPO-G/ESPO-G6-R2v1.0.0/catalog.html" target="_blank">76 </a> bias-adjusted CMIP6 climate simulations based on a high-resolution North American reanalysis , each with three variables (tasmin, tasmax, pr). The server can provide multiple <a href="https://www.unidata.ucar.edu/software/tds/current/reference/Services.html#dataAccessServices" target="_blank"> data access</a> and <a href="https://www.unidata.ucar.edu/software/tds/current/reference/Services.html#metadataServices" target="_blank"> metadata services</a> but in the following steps the tutorial will focus on the <em>OPeNDAP</em> service, where instead of downloading huge volumes of data locally, only the relevant portion is accessed using a standard called Data Access Protocol (DAP).</p>
<ul>
<li>For general information on selecting climate models and emission scenarios for climate change adaptation projects you can consult Ouranos' <a href="https://www.ouranos.ca/en/scientific-guidelines" target="_blank">Guidance Document</a></li>
Expand Down Expand Up @@ -9207,7 +9173,7 @@ <h3 id="Advanced-example">Advanced example<a class="anchor-link" href="#Advanced
<span class="s2">"NorESM2-LM"</span><span class="p">,</span>
<span class="s2">"KACE-1-0-G"</span><span class="p">,</span>
<span class="s2">"GFDL-ESM4"</span><span class="p">,</span>
<span class="s2">"MIROC-ES2L"</span>
<span class="s2">"MIROC-ES2L"</span><span class="p">,</span>
<span class="p">]</span>


Expand Down
Loading

0 comments on commit 32f257c

Please sign in to comment.