Skip to content

Commit 66e13a2

Browse files
authored
Reference ncdata in iris conversion docs. (#9847)
1 parent f810185 commit 66e13a2

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

ci/requirements/doc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
- jupyter_client
2121
- matplotlib-base
2222
- nbsphinx
23+
- ncdata
2324
- netcdf4>=1.5
2425
- numba
2526
- numpy>=2

doc/getting-started-guide/faq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ integration with Cartopy_.
173173

174174
We think the design decisions we have made for xarray (namely, basing it on
175175
pandas) make it a faster and more flexible data analysis tool. That said, Iris
176-
has some great domain specific functionality, and xarray includes
177-
methods for converting back and forth between xarray and Iris. See
178-
:py:meth:`~xarray.DataArray.to_iris` for more details.
176+
has some great domain specific functionality, and there are dedicated methods for
177+
converting back and forth between xarray and Iris. See
178+
:ref:`Reading and Writing Iris data <io.iris>` for more details.
179179

180180
What other projects leverage xarray?
181181
------------------------------------

doc/user-guide/io.rst

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ format (recommended).
1313
1414
import os
1515
16+
import iris
17+
import ncdata.iris_xarray
1618
import numpy as np
1719
import pandas as pd
1820
import xarray as xr
@@ -1072,8 +1074,11 @@ Iris
10721074

10731075
The Iris_ tool allows easy reading of common meteorological and climate model formats
10741076
(including GRIB and UK MetOffice PP files) into ``Cube`` objects which are in many ways very
1075-
similar to ``DataArray`` objects, while enforcing a CF-compliant data model. If iris is
1076-
installed, xarray can convert a ``DataArray`` into a ``Cube`` using
1077+
similar to ``DataArray`` objects, while enforcing a CF-compliant data model.
1078+
1079+
DataArray ``to_iris`` and ``from_iris``
1080+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1081+
If iris is installed, xarray can convert a ``DataArray`` into a ``Cube`` using
10771082
:py:meth:`DataArray.to_iris`:
10781083

10791084
.. ipython:: python
@@ -1095,9 +1100,36 @@ Conversely, we can create a new ``DataArray`` object from a ``Cube`` using
10951100
da_cube = xr.DataArray.from_iris(cube)
10961101
da_cube
10971102
1103+
Ncdata
1104+
~~~~~~
1105+
Ncdata_ provides more sophisticated means of transferring data, including entire
1106+
datasets. It uses the file saving and loading functions in both projects to provide a
1107+
more "correct" translation between them, but still with very low overhead and not
1108+
using actual disk files.
10981109

1099-
.. _Iris: https://scitools.org.uk/iris
1110+
For example:
1111+
1112+
.. ipython:: python
1113+
:okwarning:
11001114
1115+
ds = xr.tutorial.open_dataset("air_temperature_gradient")
1116+
cubes = ncdata.iris_xarray.cubes_from_xarray(ds)
1117+
print(cubes)
1118+
print(cubes[1])
1119+
1120+
.. ipython:: python
1121+
:okwarning:
1122+
1123+
ds = ncdata.iris_xarray.cubes_to_xarray(cubes)
1124+
print(ds)
1125+
1126+
Ncdata can also adjust file data within load and save operations, to fix data loading
1127+
problems or provide exact save formatting without needing to modify files on disk.
1128+
See for example : `ncdata usage examples`_
1129+
1130+
.. _Iris: https://scitools.org.uk/iris
1131+
.. _Ncdata: https://ncdata.readthedocs.io/en/latest/index.html
1132+
.. _ncdata usage examples: https://github.com/pp-mo/ncdata/tree/v0.1.2?tab=readme-ov-file#correct-a-miscoded-attribute-in-iris-input
11011133

11021134
OPeNDAP
11031135
-------

0 commit comments

Comments
 (0)