https://github.com/NCAS-CMS/cf-python
A CF-compliant Earth Science data analysis library
https://github.com/NCAS-CMS/cf-python
cf cfdm cfunits data-analysis earth-science metadata netcdf pp python um
Last synced: 5 months ago
JSON representation
A CF-compliant Earth Science data analysis library
- Host: GitHub
- URL: https://github.com/NCAS-CMS/cf-python
- Owner: NCAS-CMS
- License: mit
- Created: 2019-09-13T08:57:37.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-07-09T13:45:50.000Z (5 months ago)
- Last Synced: 2025-07-14T06:02:31.536Z (5 months ago)
- Topics: cf, cfdm, cfunits, data-analysis, earth-science, metadata, netcdf, pp, python, um
- Language: Python
- Homepage: http://ncas-cms.github.io/cf-python
- Size: 136 MB
- Stars: 139
- Watchers: 3
- Forks: 22
- Open Issues: 115
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- open-sustainable-technology - cf-python - A CF-compliant Earth Science data analysis library. (Climate Change / Climate Data Standards)
README
cf-python
=========
The Python `cf` package is an Earth Science data analysis library that
is built on a complete implementation of the CF data model.
[](https://ncas-cms.github.io/cf-python/Changelog.html)
[](https://pypi.org/project/cf-python/)
[](https://anaconda.org/conda-forge/cf-python)
[](https://ncas-cms.github.io/cf-python/installation.html#operating-systems)
[](https://ncas-cms.github.io/cf-python/index.html)
[](https://github.com/NCAS-CMS/cf-python/blob/main/LICENSE)
[](https://codecov.io/gh/NCAS-CMS/cfdm)
[](https://github.com/NCAS-CMS/cfdm/actions)
[](https://fair-software.eu)
#### References
[](https://doi.org/10.5281/zenodo.3894533)
[](https://www.geosci-model-dev.net/10/4619/2017/)
[](https://doi.org/10.21105/joss.02717)
Dask
====
From version 3.14.0 the `cf` package uses
[Dask](https://docs.dask.org) for all of its data manipulations.
Documentation
=============
http://ncas-cms.github.io/cf-python
Installation
============
http://ncas-cms.github.io/cf-python/installation.html
Cheat Sheet
===========
https://ncas-cms.github.io/cf-python/cheat_sheet.html
Recipes
=======
https://ncas-cms.github.io/cf-python/recipes
Tutorial
========
https://ncas-cms.github.io/cf-python/tutorial.html
Functionality
=============
The `cf` package implements the [CF data
model](https://cfconventions.org/cf-conventions/cf-conventions.html#appendix-CF-data-model)
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 which
are partially conformant may nonetheless be modified in memory.
A simple example of reading a field construct from a file and
inspecting it:
>>> import cf
>>> f = cf.read('file.nc')
>>> 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) = [1991-11-16 00:00:00, ..., 1991-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
The `cf` package uses
[Dask](https://ncas-cms.github.io/cf-python/performance.html) for all
of its array manipulation and can:
* read field constructs from netCDF, CDL, Zarr, PP and UM datasets with a
choice of netCDF backends,and in local, http, and s3 locations,
* create new field constructs in memory,
* write and append field and domain constructs to netCDF datasets on disk,
* read, create, and manipulate UGRID mesh topologies,
* read, write, and create coordinates defined by geometry cells,
* read netCDF and CDL datasets containing hierarchical groups,
* inspect field constructs,
* test whether two field constructs are the same,
* modify field construct metadata and data,
* create subspaces of field constructs,
* write field constructs to netCDF datasets on disk,
* incorporate, and create, metadata stored in external files,
* read, write, and create data that have been compressed by convention
(i.e. ragged or gathered arrays, or coordinate arrays compressed by
subsampling), whilst presenting a view of the data in its
uncompressed form,
* combine field constructs arithmetically,
* manipulate field construct data by arithmetical and trigonometrical
operations,
* perform weighted statistical collapses on field constructs,
including those with geometry cells and UGRID mesh topologies,
* perform histogram, percentile and binning operations on field
constructs,
* regrid structured grid, mesh and DSG field constructs with
(multi-)linear, nearest neighbour, first- and second-order
conservative and higher order patch recovery methods, including 3-d
regridding,
* apply convolution filters to field constructs,
* create running means from field constructs,
* apply differential operators to field constructs,
* create derived quantities (such as relative vorticity).
* read and write that data that are quantized to eliminate false
precision.
Visualization
=============
Powerful and flexible visualizations of `cf` field constructs,
designed to be produced and configured in as few lines of code as
possible, are available with the [cf-plot
package](https://ncas-cms.github.io/cf-plot/build/index.html), which
needs to be installed separately to the `cf` package.
See the [cf-plot
gallery](https://ncas-cms.github.io/cf-plot/build/gallery.html) for a
range of plotting possibilities with example code.

Command line utilities
======================
During installation the ``cfa`` command line utility is also
installed, which
* generates text descriptions of field constructs contained in files,
and
* creates new datasets aggregated from existing files.
Tests
=====
Tests are run from within the ``cf/test`` directory:
python run_tests.py