Python/numpy interface to the netCDF C library.
News
For details on the latest updates, see the Changelog.
10/22/2026: Version 1.7.5.1 released. See Changelog for details.
10/17/2026: Version 1.7.5 released. See Changelog for details.
1/5/2026: Version 1.7.4 released. Compression plugins now included in wheels, windows/arm64 and
free-threaded python wheels provided. Automatic conversion of character arrays <--> string arrays works for Unicode (not just ascii) strings.
WARNING: netcdf-c is not thread-safe and netcdf4-python does have internal locking so expect segfaults if you
use netcdf4-python on multiple threads with free-threaded python. Users must exercise care to only call netcdf from
a single thread.
10/13/2025: Version 1.7.3 released. Minor updates/bugfixes and python 3.14 wheels, see Changelog for details.
10/22/2024: Version 1.7.2 released. Minor updates/bugfixes and python 3.13 wheels, see Changelog for details.
06/17/2024: Version 1.7.1 released. Fixes for wheels, no code changes.
06/13/2024: Version 1.7.0 released. Add support for complex numbers via auto_complex keyword to Dataset (PR #1295)
10/20/2023: Version 1.6.5 released.
Fix for issue #1271 (mask ignored if bool MA assigned to uint8 var),
support for python 3.12 (removal of python 3.7 support), more
informative error messages.
6/4/2023: Version 1.6.4 released. Now requires
certifi to locate SSL certificates - this allows
OpenDAP https URLs to work with linux wheels (issue #1246).
3/3/2023: Version 1.6.3 released.
11/15/2022: Version 1.6.2 released. Fix for
compilation with netcdf-c < 4.9.0 (issue #1209).
Slicing multi-dimensional variables with an all False boolean index array
now returns an empty numpy array (instead of raising an exception - issue #1197).
09/18/2022: Version 1.6.1 released. GIL now
released for all C lib calls, set_alignment and get_alignment module functions
added to modify/retrieve HDF5 data alignment properties. Added Dataset methods to
query availability of optional compression filters.
06/24/2022: Version 1.6.0 released. Support
for quantization (bit-grooming and bit-rounding) functionality in netcdf-c 4.9.0 which can
dramatically improve compression. Dataset.createVariable now accepts dimension instances (instead
of just dimension names). 'compression' kwarg added to Dataset.createVariable to support szip as
well as new compression algorithms available in netcdf-c 4.9.0 through compression plugins (such
as zstd, bzip2 and blosc). Working arm64 wheels for Apple M1 Silicon now available on pypi.
10/31/2021: Version 1.5.8 released. Fix Enum bug, add binary wheels for aarch64 and python 3.10.
6/22/2021: Version 1.5.7 released.
Fixed OverflowError on Windows when reading data with dimension sizes greater than 2**32-1.
Masked arrays no longer returned for vlens.
2/15/2021: Version 1.5.6 released. Added Dataset.fromcdl and Dataset.tocdl, which require ncdump and ncgen utilities to be in $PATH. Removed python 2.7 support.
12/20/2020: Version 1.5.5.1 released.
Updated binary wheels for OSX and linux that link latest netcdf-c and hdf5 libs.
12/01/2020: Version 1.5.5 released.
Update license wording to be consistent with MIT license.
07/23/2020: Version 1.5.4 released.
Now requires numpy >= 1.9.
10/27/2019: Version 1.5.3 released. Fix for
issue #972, plus binary wheels for
python 3.8.
09/03/2019: Version 1.5.2 released. Bugfixes, no new features.
05/06/2019: Version 1.5.1.2 released. Fixes another slicing
regression (issue #922)) introduced in the 1.5.1 release.
05/02/2019: Version 1.5.1.1 released. Fixes incorrect __version__
module variable in 1.5.1 release, plus a slicing bug (issue #919)).
04/30/2019: Version 1.5.1 released. Bugfixes, no new features.
04/02/2019: Version 1.5.0.1 released. Binary wheels for macos x
and linux rebuilt with netcdf-c 4.6.3 (instead of 4.4.1.1). Added read-shared capability for faster reads
of NETCDF3 files (mode='rs').
03/24/2019: Version 1.5.0 released. Parallel IO support for classic
file formats added using the pnetcdf library (contribution from Lars Pastewka, pull request #897).
03/08/2019: Version 1.4.3.2 released.
Include missing membuf.pyx file in source tarball. No need to update if you installed
1.4.3.1 from a binary wheel.
03/07/2019: Version 1.4.3.1 released.
Fixes bug in implementation of NETCDF4_CLASSIC parallel IO support in 1.4.3.
03/05/2019: Version 1.4.3 released. Issues with netcdf-c 4.6.2 fixed (including broken parallel IO). set_ncstring_attrs() method added, memoryview buffer now returned when an in-memory Dataset is closed.
10/26/2018: Version 1.4.2 released. Minor bugfixes, added Variable.get_dims() method and master_file kwarg for MFDataset.__init__.
08/10/2018: Version 1.4.1 released. The old slicing behavior
(numpy array returned unless missing values are present, otherwise masked array returned) is re-enabled
via set_always_mask(False).
05/11/2018: Version 1.4.0 released. The netcdftime package is no longer
included, it is now a separate package dependency. In addition to several
bug fixes, there are a few important changes to the default behaviour to note:
- Slicing a netCDF variable will now always return masked array by default, even if there are no
masked values. The result depended on the slice before, which was too surprising.
If auto-masking is turned off (with
set_auto_mask(False)) a numpy array will always
be returned.
_FillValue is no longer treated as a valid_min/valid_max. This was too surprising, despite
the fact the thet netcdf docs attribute best practices suggests that
clients should to this if valid_min, valid_max and valid_range are not set.
- Changed behavior of string attributes so that
nc.stringatt = ['foo','bar']
produces an vlen string array attribute in NETCDF4, instead of concatenating
into a single string (foobar). In NETCDF3/NETCDF4_CLASSIC, an IOError
is now raised, instead of writing foobar.
- Retrieved compound-type variable data now returned with character array elements converted to
numpy strings (issue #773).
Works for assignment also. Can be disabled using
set_auto_chartostring(False). Numpy structured
array dtypes with 'SN' string subtypes can now be used to
define netcdf compound types in createCompoundType (they get converted to ('S1',N)
character array types automatically).
valid_min, valid_max, _FillValue and missing_value are now treated as unsigned
integers if _Unsigned variable attribute is set (to mimic behaviour of netcdf-java).
Conversion to unsigned type now occurs before masking and scale/offset
operation (issue #794)
11/01/2017: Version 1.3.1 released. Parallel IO support with MPI!
Requires that netcdf-c and hdf5 be built with MPI support, and mpi4py.
To open a file for parallel access in a program running in an MPI environment
using mpi4py, just use parallel=True when creating
the Dataset instance. See examples/mpi_example.py
for a demonstration. For more info, see the tutorial section.
9/25/2017: Version 1.3.0 released. Bug fixes
for netcdftime and optimizations for reading strided slices. encoding kwarg added to
Dataset.__init__ and Dataset.filepath to deal with oddball encodings in filename
paths (sys.getfilesystemencoding() is used by default to determine encoding).
Make sure numpy datatypes used to define CompoundTypes have isalignedstruct flag set
to avoid segfaults - which required bumping the minimum required numpy from 1.7.0
to 1.9.0. In cases where missing_value/valid_min/valid_max/_FillValue cannot be
safely cast to the variable's dtype, they are no longer be used to automatically
mask the data and a warning message is issued.
6/10/2017: Version 1.2.9 released. Fixes for auto-scaling
and masking when _Unsigned and/or valid_min, valid_max attributes present. setup.py updated
so that pip install works if cython not installed. Now requires setuptools
version 18.0 or greater.
6/1/2017: Version 1.2.8 released. From Changelog:
- recognize
_Unsigned attribute used by netcdf-java
to designate unsigned integer data stored with a signed integer type in netcdf-3
issue #656.