Xclim
Library of derived climate variables, ie climate indicators, based on xarray.
Install / Use
/learn @Ouranosinc/XclimREADME
=============================================================== xclim: Climate services library |logo| |logo-dark| |logo-light|
+----------------------------+-----------------------------------------------------+ | Versions | |pypi| |conda| |versions| | +----------------------------+-----------------------------------------------------+ | Documentation and Support | |docs| |discussions| | +----------------------------+-----------------------------------------------------+ | Open Source | |license| |ossf-score| |zenodo| |pyOpenSci| |joss| | +----------------------------+-----------------------------------------------------+ | Coding Standards | |ruff| |pre-commit| |ossf-bp| |fossa| | +----------------------------+-----------------------------------------------------+ | Development Status | |status| |build| |coveralls| | +----------------------------+-----------------------------------------------------+
xclim is an operational Python library for climate services, providing numerous climate-related indicator tools
with an extensible framework for constructing custom climate indicators, statistical downscaling and bias
adjustment of climate model simulations, as well as climate model ensemble analysis tools.
xclim is built using xarray_ and can seamlessly benefit from the parallelization handling provided by dask_.
Its objective is to make it as simple as possible for users to perform typical climate services data treatment workflows.
Leveraging xarray and dask, users can easily bias-adjust climate simulations over large spatial domains or compute indices from large climate datasets.
For example, the following would compute monthly mean temperature from daily mean temperature:
.. code-block:: python
import xclim
import xarray as xr
ds = xr.open_dataset(filename)
tg = xclim.atmos.tg_mean(ds.tas, freq="MS")
For applications where metadata and missing values are important to get right, xclim provides a class for each index
that validates inputs, checks for missing values, converts units and assigns metadata attributes to the output.
This also provides a mechanism for users to customize the indices to their own specifications and preferences.
xclim currently provides over 150 indices related to mean, minimum and maximum daily temperature, daily precipitation,
streamflow and sea ice concentration, numerous bias-adjustment algorithms, as well as a dedicated module for ensemble analysis.
.. _xarray: https://docs.xarray.dev/ .. _dask: https://docs.dask.org/
Quick Install
xclim can be installed from PyPI:
.. code-block:: shell
$ pip install xclim
or from Anaconda (conda-forge):
.. code-block:: shell
$ conda install -c conda-forge xclim
Documentation
The official documentation is at https://xclim.readthedocs.io/
How to make the most of xclim: Basic Usage Examples_ and In-Depth Examples_.
.. _Basic Usage Examples: https://xclim.readthedocs.io/en/stable/notebooks/usage.html .. _In-Depth Examples: https://xclim.readthedocs.io/en/stable/notebooks/index.html
Conventions
In order to provide a coherent interface, xclim tries to follow different sets of conventions. In particular, input data should follow the CF conventions_ whenever possible for variable attributes. Variable names are usually the ones used in CMIP6_, when they exist.
However, xclim will always assume the temporal coordinate is named "time". If your data uses another name (for example: "T"), you can rename the variable with:
.. code-block:: python
ds = ds.rename(T="time")
xclim employs a black-compatible code formatting style (via a modified ruff configuration) and (mostly) adheres to the NumPy docstring_ style. For more information on coding and development conventions, see the Contributing Guidelines_.
.. _black: https://black.readthedocs.io/en/stable/ .. _ruff: https://docs.astral.sh/ruff/ .. _CF Conventions: http://cfconventions.org/ .. _CMIP6: https://clipc-services.ceda.ac.uk/dreq/mipVars.html .. _NumPy docstring: https://numpydoc.readthedocs.io/en/stable/format.html
Contributing to xclim
xclim is in active development and is being used in production by climate services specialists around the world.
-
If you're interested in participating in the development of
xclimby suggesting new features, new indices or report bugs, please leave us a message on theissue tracker_.- If you have a support/usage question or would like to translate
xclimto a new language, be sure to check out the existing |discussions| first!
- If you have a support/usage question or would like to translate
-
If you would like to contribute code or documentation (which is greatly appreciated!), check out the
Contributing Guidelines_ before you begin!
.. _issue tracker: https://github.com/Ouranosinc/xclim/issues .. _Contributing Guidelines: https://github.com/Ouranosinc/xclim/blob/main/CONTRIBUTING.rst
How to cite this library
If you wish to cite xclim in a research publication, we kindly ask that you refer to our article published in The Journal of Open Source Software (JOSS_): https://doi.org/10.21105/joss.05415
To cite a specific version of xclim, the bibliographical reference information can be found through Zenodo_
.. _JOSS: https://joss.theoj.org/ .. _Zenodo: https://doi.org/10.5281/zenodo.2795043
License
This is free software: you can redistribute it and/or modify it under the terms of the Apache License 2.0. A copy of this license is provided in the code repository (LICENSE).
.. _Apache License 2.0: https://opensource.org/license/apache-2-0/ .. _LICENSE: https://github.com/Ouranosinc/xclim/blob/main/LICENSE
Energy and Carbon Usage
The xclim development team is interested in thoroughly testing our software while also reducing the environmental impact of the software we develop.
This repository uses the ECO-CI_ tool to estimate and track the energy use and carbon emissions of our continuous integration workflows.
+---------------------------------------------------------------------------------------+
| ECO-CI_ Energy Use and Carbon Emissions from CI Workflows (since November 2024) |
+------------------+------------------+-------------------------------------------------+
| Testing suite | Energy Usage | |energy-last| |energy-average| |energy-total| |
| +------------------+-------------------------------------------------+
| (main branch) | Carbon Emissions | |carbon-last| |carbon-average| |carbon-total| |
+------------------+------------------+-------------------------------------------------+
Credits
xclim development is funded through Ouranos_, Environment and Climate Change Canada (ECCC_), the Fonds vert_ and the Fonds d'électrification et de changements climatiques (FECC_), the Canadian Foundation for Innovation (CFI_), and the Fonds de recherche du Québec (FRQ_).
This package was created with Cookiecutter_ and the audreyfeldroy/cookiecutter-pypackage_ project template.
.. _audreyfeldroy/cookiecutter-pypackage: https://github.com/audreyfeldroy/cookiecutter-pypackage/ .. _CFI: https://www.innovation.ca/ .. _Cookiecutter: https://github.com/cookiecutter/cookiecutter/ .. _ECCC: https://www.canada.ca/en/environment-climate-change.html .. _ECO-CI: https://www.green-coding.io/ .. _FECC: https://www.environnement.gouv.qc.ca/ministere/fonds-electrification-changements-climatiques/index.htm .. _Fonds vert: https://www.environnement.gouv.qc.ca/ministere/fonds-vert/index.htm .. _FRQ: https://frq.gouv.qc.ca/ .. _Ouranos: https://www.ouranos.ca/
.. |pypi| image:: https://img.shields.io/pypi/v/xclim.svg :target: https://pypi.python.org/pypi/xclim :alt: Python Package Index Build
.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/xclim.svg :target: https://anaconda.org/conda-forge/xclim :alt: Conda-forge Build Version
.. |discussions| image:: https://img.shields.io/badge/GitHub-Discussions-blue :target: https://github.com/Ouranosinc/xclim/discussions :alt: Static Badge
.. |build| image:: https://github.com/Ouranosinc/xclim/actions/workflows/main.yml/badge.svg :target: https://github.com/Ouranosinc/xclim/actions/workflows/main.yml :alt: Build Status
.. |coveralls| image:: https://coveralls.io/repos/github/Ouranosinc/xclim/badge.svg :target: https://coveralls.io/github/Ouranosinc/xclim :alt: Coveralls
.. |docs| image:: https://readthedocs.org/projects/xclim/badge :target: https://xclim.readthedocs.io/en/latest :alt: Documentation Status
.. |zenodo| image:: https://zenodo.org/badge/142608764.svg :target: https://zenodo.org/badge/latestdoi/142608764 :alt: DOI
.. |pyOpenSci| image:: https://tinyurl.com/y22nb8up :target: https://github.com/pyOpenSci/software-review/issues/73 :alt: pyOpenSci
.. |joss| image:: https://joss.theoj.org/papers/10.21105/joss.05415/status.svg :target: https://doi.org/10.21105/joss.05415 :alt: JOSS
.. |license| image:: https://img.shields.io/github/license/Ouranosinc/xclim.svg :target: https://github.com/Ouranosinc/xclim/blob/main/LICENSE :alt: License
.. |ossf-bp| image:: https://bestpractices.coreinfrastructure.org/projects/6041/badge :target: https://bestpractices.coreinfrastructure.org/projects/6041 :alt: Open Source Security Foundation Best Practices
.. |ossf-score| image:: https://api.securityscorecards.dev/projects/github.com/Ouranosinc/xclim/badge :target: https://securityscorecards.dev/viewer/?uri=github.com/Ouranosinc/xclim :alt: Open Source Security Foundation Scorecard
.. |fossa| image:: https://app.f
Related Skills
node-connect
331.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
81.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
81.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
331.7kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
