CF Python package added to the software tree#

According to this link:

The Python cf package is an Earth Science data analysis library that is built on a complete implementation of the CF data model. The cf package implements the CF data model 1 for its internal data structures and so is able to process any CF-compliant dataset. It is not strict about CF-compliance, however, so that partially conformant datasets may be ingested from existing datasets and written to new datasets. This is so that datasets that are partially conformant may nonetheless be modified in memory.

>>> import cf
>>> f = cf.read('file.nc')
>>> f
[<CF Field: air_temperature(time(12), latitude(64), longitude(128)) K>]
>>> print(f[0])
Field: air_temperature (ncvar%tas)
----------------------------------
Data            : air_temperature(time(12), latitude(64), longitude(128)) K
Cell methods    : time(12): mean (interval: 1.0 month)
Dimension coords: time(12) = [0450-11-16 00:00:00, ..., 0451-10-16 12:00:00] noleap
                : latitude(64) = [-87.8638, ..., 87.8638] degrees_north
                : longitude(128) = [0.0, ..., 357.1875] degrees_east
                : height(1) = [2.0] m

Where to find it?#

On MIstral, the cf python package is installed in the python3 module (python3/unstable):

% module load python3/unstable

Currently, the version 3.1.0 for CF 1.7 is installed. We are in the process of upgrading to newer versions.

Some additional sub-packages are also installed: cf-plot, cf utility and cf units

Note

If you use our Jupyterhub, you can always create your own conda environment as kernels and install the versions you want to experiment with.

Do you have your own conda#

Use this command to install the latest version of cf-python and the required packages:

conda install -c ncas -c conda-forge cf-python cf-plot udunits2
conda install -c conda-forge mpich esmpy

Troubleshootings#

  • DownloadWarning when using plot: often that means Internet access is required to download the maps. Just to mention, the nodes from shared partition have no Network to outside. The easiest workaround is to to try your code on different partition.