Skip to content

Commit

Permalink
Merge pull request #493 from Ouranosinc/minor-doc-fix-and-hack
Browse files Browse the repository at this point in the history
Minor doc fixes and hack for xclim.sdba - new release
  • Loading branch information
aulemahal authored Jun 26, 2020
2 parents f907237 + d2c9291 commit 675a8a8
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 23 deletions.
17 changes: 11 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
version: 2

sphinx:
configuration: docs/conf.py

formats: []

build:
image: latest

python:
version: 3.6
install:
method: pip
extra_requirements:
- docs

formats:
- none
- method: pip
path: .
extra_requirements:
- docs
5 changes: 0 additions & 5 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ Unit handling module
:show-inheritance:


.. _sdba-api:

Statistical downscaling and bias-adjustment
===========================================

.. toctree::

sdba_api
Expand Down
6 changes: 6 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import os
import sys

import xarray as xr

import xclim

# If extensions (or modules to document with autodoc) are in another
Expand All @@ -25,6 +27,10 @@
sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath("."))

# Hack to be able to parse sdba
# sdba.__init__ fails if xarray doesn't have polyval as a test for the version.
xr.__dict__["polyval"] = None


def _get_indicators(module):
"""For all modules or classes listed, return the children that are instances of xclim.indicators.Indicator.
Expand Down
45 changes: 40 additions & 5 deletions docs/notebooks/options.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"source": [
"# Customizing and controlling xclim\n",
"\n",
"xclim's behaviour can be controlled globally or contextually through `xclim.set_options`, which acts the same way as `xarray.set_options`.\n",
"\n",
"## Missing values\n",
"\n",
"For example, one can globally change the missing method."
"xclim's behaviour can be controlled globally or contextually through `xclim.set_options`, which acts the same way as `xarray.set_options`."
]
},
{
Expand Down Expand Up @@ -44,6 +40,45 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Checks\n",
"Above, we created fake temperature data from a xarray tutorial dataset that doesn't have all the standard CF attributes. By default, when triggering a computation with an Indicator from xclim, warnings will be raised:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tx_mean = xc.atmos.tx_mean(tasmax=tasmax, freq='MS') # compute monthly max tasmax"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Setting `cf_compliance` to `'log'` mutes those warnings and sends them to the log instead."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xc.set_options(cf_compliance='log')\n",
"\n",
"tx_mean = xc.atmos.tx_mean(tasmax=tasmax, freq='MS') # compute monthly max tasmax"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Missing values\n",
"\n",
"For example, one can globally change the missing method.\n",
"\n",
"Change the default missing method to \"pct\" and set its tolerance to 8%:"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/units.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Using [`pint`](https://pint.readthedocs.io/), `xclim` provides useful functions to convert the units of datasets and `DataArray`s. Here, we convert our kelvin data to the very useful Fahrenheits:"
"Using [pint](https://pint.readthedocs.io/), `xclim` provides useful functions to convert the units of datasets and `DataArray`s. Here, we convert our kelvin data to the very useful Fahrenheits:"
]
},
{
Expand Down Expand Up @@ -120,7 +120,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.17.4-beta
current_version = 0.18.0
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+).(?P<patch>\d+)(\-(?P<release>[a-z]+))?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
AUTHOR = "Travis Logan"
AUTHOR_EMAIL = "[email protected]"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "0.17.4-beta"
VERSION = "0.18.0"
LICENSE = "Apache Software License 2.0"

with open("README.rst") as readme_file:
Expand Down
2 changes: 1 addition & 1 deletion xclim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

__author__ = """Travis Logan"""
__email__ = "[email protected]"
__version__ = "0.17.4-beta"
__version__ = "0.18.0-beta"
5 changes: 3 additions & 2 deletions xclim/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def merge_attributes(
missing_str: Optional[str] = None,
**inputs_kws: Union[xr.DataArray, xr.Dataset],
):
"""Merge attributes from several DataArrays or Datasets.
"""
Merge attributes from several DataArrays or Datasets.
If more than one input is given, its name (if available) is prepended as: "<input name> : <input attribute>".
Expand All @@ -144,7 +145,7 @@ def merge_attributes(
The datasets or variables that were used to produce the new object. Inputs given that way will be prefixed by their `name` attribute if available.
new_line : str
The character to put between each instance of the attributes. Usually, in CF-conventions,
the history attributes uses "\n" while cell_methods uses " ".
the history attributes uses '\\n' while cell_methods uses ' '.
missing_str : str
A string that is printed if an input doesn't have the attribute. Defaults to None, in which
case the input is simply skipped.
Expand Down

0 comments on commit 675a8a8

Please sign in to comment.