netCDF4 1.2.1__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of netCDF4 might be problematic. Click here for more details.
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/Changelog +54 -0
- {netCDF4-1.2.1/netCDF4.egg-info → netCDF4-1.2.3.1}/PKG-INFO +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/README.md +20 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/docs/netCDF4/index.html +146 -37
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/bench_compress.py +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/bench_compress2.py +25 -10
- netCDF4-1.2.3.1/examples/bench_compress3.py +73 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/threaded_read.py +5 -4
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/writing_netCDF.ipynb +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/include/constants.pyx +1 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/include/netCDF4.pxi +11 -2
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/man/nc3tonc4.1 +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/man/nc4tonc3.1 +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4/_netCDF4.c +14255 -11198
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4/_netCDF4.pyx +264 -90
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4/utils.py +32 -29
- {netCDF4-1.2.1 → netCDF4-1.2.3.1/netCDF4.egg-info}/PKG-INFO +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4.egg-info/SOURCES.txt +2 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netcdftime/__init__.py +1 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netcdftime/netcdftime.py +19 -8
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/setup.py +33 -5
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/run_all.py +6 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_atts.py +25 -0
- netCDF4-1.2.3.1/test/tst_cdf5.py +35 -0
- netCDF4-1.2.3.1/test/tst_filepath.py +15 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_masked.py +7 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_masked3.py +8 -8
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_multifile.py +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_multifile2.py +1 -1
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_netcdftime.py +41 -9
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_scaled.py +8 -8
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_vlen.py +7 -1
- netCDF4-1.2.1/examples/bench_compress3.py +0 -50
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/COPYING +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/MANIFEST.in +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/README.md +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/bench.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/bench_diskless.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/json_att.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/reading_netCDF.ipynb +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/subset.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/test_stringarr.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/examples/tutorial.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/man/ncinfo.1 +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4/__init__.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4.egg-info/dependency_links.txt +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4.egg-info/entry_points.txt +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4.egg-info/requires.txt +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netCDF4.egg-info/top_level.txt +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netcdftime/_datetime.c +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/netcdftime/_datetime.pyx +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/setup.cfg +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/setup.cfg.template +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/netcdf_dummy_file.nc +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_compound_alignment.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_compoundatt.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_compoundvar.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_compression.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_dap.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_dims.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_diskless.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_endian.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_enum.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_fancyslicing.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_get_variables_by_attributes.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_grps.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_grps2.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_masked2.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_refcount.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_rename.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_scalarvar.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_shape.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_slicing.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_stringarr.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_types.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_unicode.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_unicode3.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_unlimdim.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_utils.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/test/tst_vars.py +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/utils/nc3tonc4 +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/utils/nc4tonc3 +0 -0
- {netCDF4-1.2.1 → netCDF4-1.2.3.1}/utils/ncinfo +0 -0
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
version 1.2.3.1 (tag v1.2.3.1rel)
|
|
2
|
+
==================================
|
|
3
|
+
* fix bug in setup.py (pull request #539, introduced in issue #518).
|
|
4
|
+
|
|
5
|
+
version 1.2.3 (tag v1.2.3rel)
|
|
6
|
+
==============================
|
|
7
|
+
* try to avoid writing NC_STRING attributes if possible, by
|
|
8
|
+
trying to convert unicode strings to ascii and write as NC_CHAR (issue
|
|
9
|
+
#529). This preserves compatibility with clients (like Matlab) that
|
|
10
|
+
can't deal with NC_STRING attributes. A 'setncattr_string' method
|
|
11
|
+
was added for Dataset and Variable to that users can force attributes
|
|
12
|
+
to be written as NC_STRING if necessary.
|
|
13
|
+
* fix failing tests with numpy 1.11 (issues #521 and #522).
|
|
14
|
+
* fix indentation bug in nc4tonc3 utility (issue #519).
|
|
15
|
+
* add the capability in setup.py to use pkg-config instead of
|
|
16
|
+
nc-config (pull request #518).
|
|
17
|
+
* make sure slices which return scalar masked arrays
|
|
18
|
+
are consistent with numpy.ma (issue #515).
|
|
19
|
+
* add test/tst_cdf5.py and test/tst_filepath.py (to test new
|
|
20
|
+
NETCDF3_64BIT_DATA format and filepath Dataset method).
|
|
21
|
+
* expose netcdftime.__version__ (issue #504).
|
|
22
|
+
* fix potential memory leak in Dataset.filepath in attempt to fix
|
|
23
|
+
mysterious segfaults on CentOS6 (issue #506). Segfaults
|
|
24
|
+
can apparently still occur on systems like CentOS6 with old versions of glibc.
|
|
25
|
+
|
|
26
|
+
version 1.2.2 (tag v1.2.2rel)
|
|
27
|
+
=============================
|
|
28
|
+
* fix failing tests on python 2.6 (issue #497). Change minimum required
|
|
29
|
+
python from 2.5 to 2.6.
|
|
30
|
+
* Potential memory leaks fixed by freeing string pointers internally allocated
|
|
31
|
+
in netcdf-c using nc_free_string. Also use nc_free_vlens to free space allocated
|
|
32
|
+
for vlens inside netcdf-c (issue #495).
|
|
33
|
+
* invoke str on filename argument to Dataset constructor, so pathlib
|
|
34
|
+
instances can be used (issue #489).
|
|
35
|
+
* don't use hardwired NC_MAX_DIMS or NC_MAX_VARS internally to allocate space
|
|
36
|
+
for dimension or variable ids. Instead, find out the number of dims
|
|
37
|
+
and vars and use malloc. NC_MAX_NAME is still used to allocate space
|
|
38
|
+
for attribute and variable names, since there is no obvious way to
|
|
39
|
+
determine the length of these names.
|
|
40
|
+
* if trying to write a unicode attribute, check to see if it exists
|
|
41
|
+
first and is NC_CHAR, and if so, delete it and recreate it. Workaround for C
|
|
42
|
+
lib bug discovered in issue #485.
|
|
43
|
+
* support for NETCDF3_64BIT_DATA format supported in netcdf-c 4.4.0.
|
|
44
|
+
Similar to NETCDF3_64BIT (now NETCDF3_64BIT_OFFSET), but includes
|
|
45
|
+
64 bit dimensions and sizes, plus unsigned and 64 bit integer
|
|
46
|
+
data types.
|
|
47
|
+
* make sure chunksize does not exceed dimension size
|
|
48
|
+
(for non-unlimited dimensions) on variable creation (issue #480).
|
|
49
|
+
* add 'size' attribute to Dimension (same as len(d), where
|
|
50
|
+
d is a Dimension instance, issue #477).
|
|
51
|
+
* fix bug in nc3tonc4 with --unpackshort=1 (issue #474).
|
|
52
|
+
* dates do not have to be contiguous, i.e. can be before and after the
|
|
53
|
+
missing dates in Gregorian calendar (pull request #476).
|
|
54
|
+
|
|
1
55
|
version 1.2.1 (tag v1.2.1rel)
|
|
2
56
|
=============================
|
|
3
57
|
* add the capability to slice variables with unsorted integer sequences,
|
|
@@ -7,6 +7,25 @@
|
|
|
7
7
|
## News
|
|
8
8
|
For the latest updates, see the [Changelog](https://github.com/Unidata/netcdf4-python/blob/master/Changelog).
|
|
9
9
|
|
|
10
|
+
3/10/2016: Version [1.2.3](https://pypi.python.org/pypi/netCDF4/1.2.3) released. Various bug fixes.
|
|
11
|
+
All text attributes in ``NETCDF4`` formatted files are now written as type ``NC_CHAR``, unless they contain unicode characters that
|
|
12
|
+
cannot be encoded in ascii, in which case they are written as ``NC_STRING``. Previously,
|
|
13
|
+
all unicode strings were written as ``NC_STRING``. This change preserves compatibility
|
|
14
|
+
with clients, like Matlab, that can't deal with ``NC_STRING`` attributes.
|
|
15
|
+
A ``setncattr_string`` method was added to force attributes to be written as ``NC_STRING``.
|
|
16
|
+
|
|
17
|
+
1/1/2016: Version [1.2.2](https://pypi.python.org/pypi/netCDF4/1.2.2) released. Mostly bugfixes, but with two new features.
|
|
18
|
+
|
|
19
|
+
* support for the new ``NETCDF3_64BIT_DATA`` format introduced in netcdf-c 4.4.0.
|
|
20
|
+
Similar to ``NETCDF3_64BIT`` (now ``NETCDF3_64BIT_OFFSET``), but includes
|
|
21
|
+
64 bit dimension sizes (> 2 billion), plus unsigned and 64 bit integer data types.
|
|
22
|
+
Uses the classic (netcdf-3) data model, and does not use HDF5 as the underlying storage format.
|
|
23
|
+
|
|
24
|
+
* Dimension objects now have a ``size`` attribute, which is the current length
|
|
25
|
+
of the dimension (same as invoking ``len`` on the Dimension instance).
|
|
26
|
+
|
|
27
|
+
The minimum required python version has now been increased from 2.5 to 2.6.
|
|
28
|
+
|
|
10
29
|
10/15/2015: Version [1.2.1](https://pypi.python.org/pypi/netCDF4/1.2.1) released. Adds the ability
|
|
11
30
|
to slice Variables with unsorted integer sequences, and integer sequences with duplicates.
|
|
12
31
|
|
|
@@ -50,7 +69,7 @@ instead of relying exclusively on the nc-config utility.
|
|
|
50
69
|
* Clone GitHub repository (`git clone https://github.com/Unidata/netcdf4-python.git`), or get source tarball from [PyPI](https://pypi.python.org/pypi/netCDF4). Links to Windows and OS X precompiled binary packages are also available on [PyPI](https://pypi.python.org/pypi/netCDF4).
|
|
51
70
|
|
|
52
71
|
* Make sure [numpy](http://www.numpy.org/) (required) and [Cython](http://cython.org/) (recommended) are
|
|
53
|
-
installed and you have [Python](https://www.python.org) 2.
|
|
72
|
+
installed and you have [Python](https://www.python.org) 2.6 or newer.
|
|
54
73
|
|
|
55
74
|
* Make sure [HDF5](http://www.h5py.org/) and netcdf-4 are installed, and the `nc-config` utility
|
|
56
75
|
is in your Unix PATH. If `setup.cfg` does not exist, copy `setup.cfg.template`
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
|
5
5
|
|
|
6
6
|
<title>netCDF4 API documentation</title>
|
|
7
|
-
<meta name="description" content="Version 1.2.
|
|
7
|
+
<meta name="description" content="Version 1.2.3
|
|
8
8
|
-------------
|
|
9
9
|
- - -
|
|
10
10
|
|
|
@@ -1096,6 +1096,7 @@ table {
|
|
|
1096
1096
|
<li class="mono"><a href="#netCDF4.Dataset.set_fill_off">set_fill_off</a></li>
|
|
1097
1097
|
<li class="mono"><a href="#netCDF4.Dataset.set_fill_on">set_fill_on</a></li>
|
|
1098
1098
|
<li class="mono"><a href="#netCDF4.Dataset.setncattr">setncattr</a></li>
|
|
1099
|
+
<li class="mono"><a href="#netCDF4.Dataset.setncattr_string">setncattr_string</a></li>
|
|
1099
1100
|
<li class="mono"><a href="#netCDF4.Dataset.setncatts">setncatts</a></li>
|
|
1100
1101
|
<li class="mono"><a href="#netCDF4.Dataset.sync">sync</a></li>
|
|
1101
1102
|
</ul>
|
|
@@ -1150,6 +1151,7 @@ table {
|
|
|
1150
1151
|
<li class="mono"><a href="#netCDF4.Group.set_fill_off">set_fill_off</a></li>
|
|
1151
1152
|
<li class="mono"><a href="#netCDF4.Group.set_fill_on">set_fill_on</a></li>
|
|
1152
1153
|
<li class="mono"><a href="#netCDF4.Group.setncattr">setncattr</a></li>
|
|
1154
|
+
<li class="mono"><a href="#netCDF4.Group.setncattr_string">setncattr_string</a></li>
|
|
1153
1155
|
<li class="mono"><a href="#netCDF4.Group.setncatts">setncatts</a></li>
|
|
1154
1156
|
<li class="mono"><a href="#netCDF4.Group.sync">sync</a></li>
|
|
1155
1157
|
</ul>
|
|
@@ -1181,6 +1183,7 @@ table {
|
|
|
1181
1183
|
<li class="mono"><a href="#netCDF4.MFDataset.set_fill_off">set_fill_off</a></li>
|
|
1182
1184
|
<li class="mono"><a href="#netCDF4.MFDataset.set_fill_on">set_fill_on</a></li>
|
|
1183
1185
|
<li class="mono"><a href="#netCDF4.MFDataset.setncattr">setncattr</a></li>
|
|
1186
|
+
<li class="mono"><a href="#netCDF4.MFDataset.setncattr_string">setncattr_string</a></li>
|
|
1184
1187
|
<li class="mono"><a href="#netCDF4.MFDataset.setncatts">setncatts</a></li>
|
|
1185
1188
|
<li class="mono"><a href="#netCDF4.MFDataset.sync">sync</a></li>
|
|
1186
1189
|
<li class="mono"><a href="#netCDF4.MFDataset.__init__">__init__</a></li>
|
|
@@ -1232,6 +1235,7 @@ table {
|
|
|
1232
1235
|
<li class="mono"><a href="#netCDF4.Variable.set_auto_scale">set_auto_scale</a></li>
|
|
1233
1236
|
<li class="mono"><a href="#netCDF4.Variable.set_var_chunk_cache">set_var_chunk_cache</a></li>
|
|
1234
1237
|
<li class="mono"><a href="#netCDF4.Variable.setncattr">setncattr</a></li>
|
|
1238
|
+
<li class="mono"><a href="#netCDF4.Variable.setncattr_string">setncattr_string</a></li>
|
|
1235
1239
|
<li class="mono"><a href="#netCDF4.Variable.setncatts">setncatts</a></li>
|
|
1236
1240
|
</ul>
|
|
1237
1241
|
|
|
@@ -1251,7 +1255,7 @@ table {
|
|
|
1251
1255
|
|
|
1252
1256
|
<header id="section-intro">
|
|
1253
1257
|
<h1 class="title"><span class="name">netCDF4</span> module</h1>
|
|
1254
|
-
<h2>Version 1.2.
|
|
1258
|
+
<h2>Version 1.2.3</h2>
|
|
1255
1259
|
<hr />
|
|
1256
1260
|
<h1>Introduction</h1>
|
|
1257
1261
|
<p>netcdf4-python is a Python interface to the netCDF C library. </p>
|
|
@@ -1279,7 +1283,7 @@ types) are not supported.</p>
|
|
|
1279
1283
|
</ul>
|
|
1280
1284
|
<h1>Requires</h1>
|
|
1281
1285
|
<ul>
|
|
1282
|
-
<li>Python 2.
|
|
1286
|
+
<li>Python 2.6 or later (python 3 works too).</li>
|
|
1283
1287
|
<li><a href="http://numpy.scipy.org">numpy array module</a>, version 1.7.0 or later.</li>
|
|
1284
1288
|
<li><a href="http://cython.org">Cython</a>, version 0.19 or later, is optional - if it is installed setup.py will
|
|
1285
1289
|
use it to recompile the Cython source code into C, using conditional compilation
|
|
@@ -1352,10 +1356,17 @@ types) are not supported.</p>
|
|
|
1352
1356
|
constructor. This is also the method used to open an existing netCDF
|
|
1353
1357
|
file. If the file is open for write access (<code>mode='w', 'r+'</code> or <code>'a'</code>), you may
|
|
1354
1358
|
write any type of data including new dimensions, groups, variables and
|
|
1355
|
-
attributes. netCDF files come in
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
+
attributes. netCDF files come in five flavors (<code>NETCDF3_CLASSIC,
|
|
1360
|
+
NETCDF3_64BIT_OFFSET, NETCDF3_64BIT_DATA, NETCDF4_CLASSIC</code>, and <code>NETCDF4</code>).
|
|
1361
|
+
<code>NETCDF3_CLASSIC</code> was the original netcdf binary format, and was limited
|
|
1362
|
+
to file sizes less than 2 Gb. <code>NETCDF3_64BIT_OFFSET</code> was introduced
|
|
1363
|
+
in version 3.6.0 of the library, and extended the original binary format
|
|
1364
|
+
to allow for file sizes greater than 2 Gb.
|
|
1365
|
+
<code>NETCDF3_64BIT_DATA</code> is a new format that requires version 4.4.0 of
|
|
1366
|
+
the C library - it extends the <code>NETCDF3_64BIT_OFFSET</code> binary format to
|
|
1367
|
+
allow for unsigned/64 bit integer data types and 64-bit dimension sizes.
|
|
1368
|
+
<code>NETCDF3_64BIT</code> is an alias for <code>NETCDF3_64BIT_OFFSET</code>.
|
|
1369
|
+
<code>NETCDF4_CLASSIC</code> files use the version 4 disk format (HDF5), but omits features
|
|
1359
1370
|
not found in the version 3 API. They can be read by netCDF 3 clients
|
|
1360
1371
|
only if they have been relinked against the netCDF 4 library. They can
|
|
1361
1372
|
also be read by HDF5 clients. <code>NETCDF4</code> files use the version 4 disk
|
|
@@ -1383,7 +1394,7 @@ OPenDAP support, via the <code>--enable-dap</code> configure option (added in
|
|
|
1383
1394
|
version 4.0.1).</p>
|
|
1384
1395
|
<h2><div id='section2'>2) Groups in a netCDF file.</h2>
|
|
1385
1396
|
<p>netCDF version 4 added support for organizing data in hierarchical
|
|
1386
|
-
groups, which are
|
|
1397
|
+
groups, which are analogous to directories in a filesystem. Groups serve
|
|
1387
1398
|
as containers for variables, dimensions and attributes, as well as other
|
|
1388
1399
|
groups. A <a href="#netCDF4.Dataset"><code>Dataset</code></a> defines creates a special group, called
|
|
1389
1400
|
the 'root group', which is similar to the root directory in a unix
|
|
@@ -1499,9 +1510,9 @@ The <a href="#netCDF4.Dimension.isunlimited"><code>isunlimited</code></a> method
|
|
|
1499
1510
|
can be used to determine if the dimensions is unlimited, or appendable.</p>
|
|
1500
1511
|
<div class="codehilite"><pre><span class="o">>>></span> <span class="k">print</span> <span class="nb">len</span><span class="p">(</span><span class="n">lon</span><span class="p">)</span>
|
|
1501
1512
|
<span class="mi">144</span>
|
|
1502
|
-
<span class="o">>>></span> <span class="k">print</span> <span class="nb">len</span><span class="o">.</span><span class="n">
|
|
1513
|
+
<span class="o">>>></span> <span class="k">print</span> <span class="nb">len</span><span class="o">.</span><span class="n">isunlimited</span><span class="p">()</span>
|
|
1503
1514
|
<span class="bp">False</span>
|
|
1504
|
-
<span class="o">>>></span> <span class="k">print</span> <span class="n">time</span><span class="o">.</span><span class="n">
|
|
1515
|
+
<span class="o">>>></span> <span class="k">print</span> <span class="n">time</span><span class="o">.</span><span class="n">isunlimited</span><span class="p">()</span>
|
|
1505
1516
|
<span class="bp">True</span>
|
|
1506
1517
|
</pre></div>
|
|
1507
1518
|
|
|
@@ -1787,8 +1798,8 @@ Variables in the list of files that share the same unlimited
|
|
|
1787
1798
|
dimension are aggregated together, and can be sliced across multiple
|
|
1788
1799
|
files. To illustrate this, let's first create a bunch of netCDF files with
|
|
1789
1800
|
the same variable (with the same unlimited dimension). The files
|
|
1790
|
-
must in be in <code>
|
|
1791
|
-
<code>NETCDF4_CLASSIC
|
|
1801
|
+
must in be in <code>NETCDF3_64BIT_OFFSET</code>, <code>NETCDF3_64BIT_DATA</code>, <code>NETCDF3_CLASSIC</code> or
|
|
1802
|
+
<code>NETCDF4_CLASSIC</code> format (<code>NETCDF4</code> formatted multi-file
|
|
1792
1803
|
datasets are not supported).</p>
|
|
1793
1804
|
<div class="codehilite"><pre><span class="o">>>></span> <span class="k">for</span> <span class="n">nf</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>
|
|
1794
1805
|
<span class="o">>>></span> <span class="n">f</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="s">"mftest</span><span class="si">%s</span><span class="s">.nc"</span> <span class="o">%</span> <span class="n">nf</span><span class="p">,</span><span class="s">"w"</span><span class="p">)</span>
|
|
@@ -1833,7 +1844,7 @@ and <code>endian</code> keyword arguments to
|
|
|
1833
1844
|
<a href="#netCDF4.Dataset.createVariable"><code>createVariable</code></a>. These keyword arguments only
|
|
1834
1845
|
are relevant for <code>NETCDF4</code> and <code>NETCDF4_CLASSIC</code> files (where the
|
|
1835
1846
|
underlying file format is HDF5) and are silently ignored if the file
|
|
1836
|
-
format is <code>NETCDF3_CLASSIC</code> or <code>
|
|
1847
|
+
format is <code>NETCDF3_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p>
|
|
1837
1848
|
<p>If your data only has a certain number of digits of precision (say for
|
|
1838
1849
|
example, it is temperature data that was measured with a precision of
|
|
1839
1850
|
0.1 degrees), you can dramatically improve zlib compression by
|
|
@@ -2420,7 +2431,7 @@ Enum types defined for the <a href="#netCDF4.Group"><code>Group</code></a> or <a
|
|
|
2420
2431
|
of the <a href="#netCDF4.EnumType"><code>EnumType</code></a> class.</p>
|
|
2421
2432
|
<p><strong><code>data_model</code></strong>: <code>data_model</code> describes the netCDF
|
|
2422
2433
|
data model version, one of <code>NETCDF3_CLASSIC</code>, <code>NETCDF4</code>,
|
|
2423
|
-
<code>NETCDF4_CLASSIC</code> or <code>
|
|
2434
|
+
<code>NETCDF4_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p>
|
|
2424
2435
|
<p><strong><code>file_format</code></strong>: same as <code>data_model</code>, retained for backwards compatibility.</p>
|
|
2425
2436
|
<p><strong><code>disk_format</code></strong>: <code>disk_format</code> describes the underlying
|
|
2426
2437
|
file format, one of <code>NETCDF3</code>, <code>HDF5</code>, <code>HDF4</code>,
|
|
@@ -2468,7 +2479,7 @@ compound types defined for the <a href="#netCDF4.Group"><code>Group</code></a> o
|
|
|
2468
2479
|
|
|
2469
2480
|
<div class="desc"><p><code>data_model</code> describes the netCDF
|
|
2470
2481
|
data model version, one of <code>NETCDF3_CLASSIC</code>, <code>NETCDF4</code>,
|
|
2471
|
-
<code>NETCDF4_CLASSIC</code> or <code>
|
|
2482
|
+
<code>NETCDF4_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p></div>
|
|
2472
2483
|
<div class="source_cont">
|
|
2473
2484
|
</div>
|
|
2474
2485
|
|
|
@@ -2614,13 +2625,15 @@ variable-length types defined for the <a href="#netCDF4.Group"><code>Group</code
|
|
|
2614
2625
|
|
|
2615
2626
|
|
|
2616
2627
|
<div class="desc"><p><a href="#netCDF4.Dataset"><code>Dataset</code></a> constructor.</p>
|
|
2617
|
-
<p><strong><code>filename</code></strong>: Name of netCDF file to hold dataset
|
|
2628
|
+
<p><strong><code>filename</code></strong>: Name of netCDF file to hold dataset. Can also
|
|
2629
|
+
be a python 3 pathlib instance or the URL of an OpenDAP dataset.</p>
|
|
2618
2630
|
<p><strong><code>mode</code></strong>: access mode. <code>r</code> means read-only; no data can be
|
|
2619
2631
|
modified. <code>w</code> means write; a new file is created, an existing file with
|
|
2620
2632
|
the same name is deleted. <code>a</code> and <code>r+</code> mean append (in analogy with
|
|
2621
2633
|
serial files); an existing file is opened for reading and writing.
|
|
2622
2634
|
Appending <code>s</code> to modes <code>w</code>, <code>r+</code> or <code>a</code> will enable unbuffered shared
|
|
2623
|
-
access to <code>NETCDF3_CLASSIC</code
|
|
2635
|
+
access to <code>NETCDF3_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or
|
|
2636
|
+
<code>NETCDF3_64BIT_DATA</code> formatted files.
|
|
2624
2637
|
Unbuffered acesss may be useful even if you don't need shared
|
|
2625
2638
|
access, since it may be faster for programs that don't access data
|
|
2626
2639
|
sequentially. This option is ignored for <code>NETCDF4</code> and <code>NETCDF4_CLASSIC</code>
|
|
@@ -2629,18 +2642,22 @@ formatted files.</p>
|
|
|
2629
2642
|
will clobber an existing file with the same name. if <code>False</code>, an
|
|
2630
2643
|
exception will be raised if a file with the same name already exists.</p>
|
|
2631
2644
|
<p><strong><code>format</code></strong>: underlying file format (one of <code>'NETCDF4',
|
|
2632
|
-
'NETCDF4_CLASSIC', 'NETCDF3_CLASSIC'</code
|
|
2633
|
-
|
|
2645
|
+
'NETCDF4_CLASSIC', 'NETCDF3_CLASSIC'</code>, <code>'NETCDF3_64BIT_OFFSET'</code> or
|
|
2646
|
+
<code>'NETCDF3_64BIT_DATA'</code>.
|
|
2647
|
+
Only relevant if <code>mode = 'w'</code> (if <code>mode = 'r','a'</code> or <code>'r+'</code> the file format
|
|
2634
2648
|
is automatically detected). Default <code>'NETCDF4'</code>, which means the data is
|
|
2635
2649
|
stored in an HDF5 file, using netCDF 4 API features. Setting
|
|
2636
2650
|
<code>format='NETCDF4_CLASSIC'</code> will create an HDF5 file, using only netCDF 3
|
|
2637
2651
|
compatibile API features. netCDF 3 clients must be recompiled and linked
|
|
2638
2652
|
against the netCDF 4 library to read files in <code>NETCDF4_CLASSIC</code> format.
|
|
2639
2653
|
<code>'NETCDF3_CLASSIC'</code> is the classic netCDF 3 file format that does not
|
|
2640
|
-
handle 2+ Gb files
|
|
2654
|
+
handle 2+ Gb files. <code>'NETCDF3_64BIT_OFFSET'</code> is the 64-bit offset
|
|
2641
2655
|
version of the netCDF 3 file format, which fully supports 2+ GB files, but
|
|
2642
2656
|
is only compatible with clients linked against netCDF version 3.6.0 or
|
|
2643
|
-
later
|
|
2657
|
+
later. <code>'NETCDF3_64BIT_DATA'</code> is the 64-bit data version of the netCDF 3
|
|
2658
|
+
file format, which supports 64-bit dimension sizes plus unsigned and
|
|
2659
|
+
64 bit integer data types, but is only compatible with clients linked against
|
|
2660
|
+
netCDF version 4.4.0 or later.</p>
|
|
2644
2661
|
<p><strong><code>diskless</code></strong>: If <code>True</code>, create diskless (in memory) file.<br />
|
|
2645
2662
|
This is an experimental feature added to the C library after the
|
|
2646
2663
|
netcdf-4.2 release.</p>
|
|
@@ -2753,7 +2770,7 @@ datatype.</p></div>
|
|
|
2753
2770
|
<div class="desc"><p>Creates a new <a href="#netCDF4.Group"><code>Group</code></a> with the given <code>groupname</code>.</p>
|
|
2754
2771
|
<p>If <code>groupname</code> is specified as a path, using forward slashes as in unix to
|
|
2755
2772
|
separate components, then intermediate groups will be created as necessary
|
|
2756
|
-
(
|
|
2773
|
+
(analogous to <code>mkdir -p</code> in unix). For example,
|
|
2757
2774
|
<code>createGroup('/GroupA/GroupB/GroupC')</code> will create <code>GroupA</code>,
|
|
2758
2775
|
<code>GroupA/GroupB</code>, and <code>GroupA/GroupB/GroupC</code>, if they don't already exist.
|
|
2759
2776
|
If the specified path describes a group that already exists, no error is
|
|
@@ -2943,7 +2960,7 @@ contain all of the matches. For example, </p>
|
|
|
2943
2960
|
<div class="codehilite"><pre><span class="o">>>></span> <span class="c"># Get variables with x-axis attribute.</span>
|
|
2944
2961
|
<span class="o">>>></span> <span class="n">vs</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s">'X'</span><span class="p">)</span>
|
|
2945
2962
|
<span class="o">>>></span> <span class="c"># Get variables with matching "standard_name" attribute</span>
|
|
2946
|
-
<span class="o">>>></span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">standard_name</span><span class="o">=</span><span class="s">'northward_sea_water_velocity'</span><span class="p">)</span>
|
|
2963
|
+
<span class="o">>>></span> <span class="n">vs</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">standard_name</span><span class="o">=</span><span class="s">'northward_sea_water_velocity'</span><span class="p">)</span>
|
|
2947
2964
|
</pre></div>
|
|
2948
2965
|
|
|
2949
2966
|
|
|
@@ -3188,6 +3205,23 @@ with the same name as one of the reserved python attributes.</p></div>
|
|
|
3188
3205
|
</div>
|
|
3189
3206
|
|
|
3190
3207
|
|
|
3208
|
+
<div class="item">
|
|
3209
|
+
<div class="name def" id="netCDF4.Dataset.setncattr_string">
|
|
3210
|
+
<p>def <span class="ident">setncattr_string</span>(</p><p>self,name,value)</p>
|
|
3211
|
+
</div>
|
|
3212
|
+
|
|
3213
|
+
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
<div class="desc"><p>set a netCDF dataset or group string attribute using name,value pair.
|
|
3217
|
+
Use if you need to ensure that of netCDF attribute is created with type
|
|
3218
|
+
<code>NC_STRING</code> if the file format is <code>NETCDF4</code>.</p></div>
|
|
3219
|
+
<div class="source_cont">
|
|
3220
|
+
</div>
|
|
3221
|
+
|
|
3222
|
+
</div>
|
|
3223
|
+
|
|
3224
|
+
|
|
3191
3225
|
<div class="item">
|
|
3192
3226
|
<div class="name def" id="netCDF4.Dataset.setncatts">
|
|
3193
3227
|
<p>def <span class="ident">setncatts</span>(</p><p>self,attdict)</p>
|
|
@@ -3235,7 +3269,9 @@ calling the python <code>len</code> function on the <a href="#netCDF4.Dimension"
|
|
|
3235
3269
|
determine if the dimension is unlimited.</p>
|
|
3236
3270
|
<p>Read-only class variables:</p>
|
|
3237
3271
|
<p><strong><code>name</code></strong>: String name, used when creating a <a href="#netCDF4.Variable"><code>Variable</code></a> with
|
|
3238
|
-
<a href="#netCDF4.Dataset.createVariable"><code>createVariable</code></a>.</p
|
|
3272
|
+
<a href="#netCDF4.Dataset.createVariable"><code>createVariable</code></a>.</p>
|
|
3273
|
+
<p><strong><code>size</code></strong>: Current <a href="#netCDF4.Dimension"><code>Dimension</code></a> size (same as <code>len(d)</code>, where <code>d</code> is a
|
|
3274
|
+
<a href="#netCDF4.Dimension"><code>Dimension</code></a> instance).</p></div>
|
|
3239
3275
|
<div class="source_cont">
|
|
3240
3276
|
</div>
|
|
3241
3277
|
|
|
@@ -3255,6 +3291,16 @@ determine if the dimension is unlimited.</p>
|
|
|
3255
3291
|
|
|
3256
3292
|
<div class="desc"><p>A string describing the name of the <a href="#netCDF4.Dimension"><code>Dimension</code></a> - used when creating a
|
|
3257
3293
|
<a href="#netCDF4.Variable"><code>Variable</code></a> instance with <a href="#netCDF4.Dataset.createVariable"><code>createVariable</code></a>.</p></div>
|
|
3294
|
+
<div class="source_cont">
|
|
3295
|
+
</div>
|
|
3296
|
+
|
|
3297
|
+
</div>
|
|
3298
|
+
<div class="item">
|
|
3299
|
+
<p id="netCDF4.Dimension.size" class="name">var <span class="ident">size</span></p>
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3258
3304
|
<div class="source_cont">
|
|
3259
3305
|
</div>
|
|
3260
3306
|
|
|
@@ -3402,7 +3448,7 @@ method of a <a href="#netCDF4.Dataset"><code>Dataset</code></a> or <a href="#net
|
|
|
3402
3448
|
|
|
3403
3449
|
|
|
3404
3450
|
<div class="desc"><p>Groups define a hierarchical namespace within a netCDF file. They are
|
|
3405
|
-
|
|
3451
|
+
analogous to directories in a unix filesystem. Each <a href="#netCDF4.Group"><code>Group</code></a> behaves like
|
|
3406
3452
|
a <a href="#netCDF4.Dataset"><code>Dataset</code></a> within a Dataset, and can contain it's own variables,
|
|
3407
3453
|
dimensions and attributes (and other Groups). See <a href="#netCDF4.Group.__init__"><code>__init__</code></a>
|
|
3408
3454
|
for more details.</p>
|
|
@@ -3452,7 +3498,7 @@ compound types defined for the <a href="#netCDF4.Group"><code>Group</code></a> o
|
|
|
3452
3498
|
|
|
3453
3499
|
<div class="desc inherited"><p><code>data_model</code> describes the netCDF
|
|
3454
3500
|
data model version, one of <code>NETCDF3_CLASSIC</code>, <code>NETCDF4</code>,
|
|
3455
|
-
<code>NETCDF4_CLASSIC</code> or <code>
|
|
3501
|
+
<code>NETCDF4_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p></div>
|
|
3456
3502
|
<div class="source_cont">
|
|
3457
3503
|
</div>
|
|
3458
3504
|
|
|
@@ -3775,7 +3821,7 @@ datatype.</p></div>
|
|
|
3775
3821
|
<div class="desc inherited"><p>Creates a new <a href="#netCDF4.Group"><code>Group</code></a> with the given <code>groupname</code>.</p>
|
|
3776
3822
|
<p>If <code>groupname</code> is specified as a path, using forward slashes as in unix to
|
|
3777
3823
|
separate components, then intermediate groups will be created as necessary
|
|
3778
|
-
(
|
|
3824
|
+
(analogous to <code>mkdir -p</code> in unix). For example,
|
|
3779
3825
|
<code>createGroup('/GroupA/GroupB/GroupC')</code> will create <code>GroupA</code>,
|
|
3780
3826
|
<code>GroupA/GroupB</code>, and <code>GroupA/GroupB/GroupC</code>, if they don't already exist.
|
|
3781
3827
|
If the specified path describes a group that already exists, no error is
|
|
@@ -3985,7 +4031,7 @@ contain all of the matches. For example, </p>
|
|
|
3985
4031
|
<div class="codehilite"><pre><span class="o">>>></span> <span class="c"># Get variables with x-axis attribute.</span>
|
|
3986
4032
|
<span class="o">>>></span> <span class="n">vs</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s">'X'</span><span class="p">)</span>
|
|
3987
4033
|
<span class="o">>>></span> <span class="c"># Get variables with matching "standard_name" attribute</span>
|
|
3988
|
-
<span class="o">>>></span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">standard_name</span><span class="o">=</span><span class="s">'northward_sea_water_velocity'</span><span class="p">)</span>
|
|
4034
|
+
<span class="o">>>></span> <span class="n">vs</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">standard_name</span><span class="o">=</span><span class="s">'northward_sea_water_velocity'</span><span class="p">)</span>
|
|
3989
4035
|
</pre></div>
|
|
3990
4036
|
|
|
3991
4037
|
|
|
@@ -4282,6 +4328,27 @@ with the same name as one of the reserved python attributes.</p></div>
|
|
|
4282
4328
|
</div>
|
|
4283
4329
|
|
|
4284
4330
|
|
|
4331
|
+
<div class="item">
|
|
4332
|
+
<div class="name def" id="netCDF4.Group.setncattr_string">
|
|
4333
|
+
<p>def <span class="ident">setncattr_string</span>(</p><p>self,name,value)</p>
|
|
4334
|
+
</div>
|
|
4335
|
+
|
|
4336
|
+
<p class="inheritance">
|
|
4337
|
+
<strong>Inheritance:</strong>
|
|
4338
|
+
<code><a href="#netCDF4.Dataset">Dataset</a></code>.<code><a href="#netCDF4.Dataset.setncattr_string">setncattr_string</a></code>
|
|
4339
|
+
</p>
|
|
4340
|
+
|
|
4341
|
+
|
|
4342
|
+
|
|
4343
|
+
<div class="desc inherited"><p>set a netCDF dataset or group string attribute using name,value pair.
|
|
4344
|
+
Use if you need to ensure that of netCDF attribute is created with type
|
|
4345
|
+
<code>NC_STRING</code> if the file format is <code>NETCDF4</code>.</p></div>
|
|
4346
|
+
<div class="source_cont">
|
|
4347
|
+
</div>
|
|
4348
|
+
|
|
4349
|
+
</div>
|
|
4350
|
+
|
|
4351
|
+
|
|
4285
4352
|
<div class="item">
|
|
4286
4353
|
<div class="name def" id="netCDF4.Group.setncatts">
|
|
4287
4354
|
<p>def <span class="ident">setncatts</span>(</p><p>self,attdict)</p>
|
|
@@ -4331,8 +4398,8 @@ each attribute</p></div>
|
|
|
4331
4398
|
|
|
4332
4399
|
<div class="desc"><p>Class for reading multi-file netCDF Datasets, making variables
|
|
4333
4400
|
spanning multiple files appear as if they were in one file.
|
|
4334
|
-
Datasets must be in <code>NETCDF4_CLASSIC, NETCDF3_CLASSIC
|
|
4335
|
-
format (<code>NETCDF4</code> Datasets won't work).</p>
|
|
4401
|
+
Datasets must be in <code>NETCDF4_CLASSIC, NETCDF3_CLASSIC, NETCDF3_64BIT_OFFSET
|
|
4402
|
+
or NETCDF3_64BIT_DATA</code> format (<code>NETCDF4</code> Datasets won't work).</p>
|
|
4336
4403
|
<p>Adapted from <a href="http://pysclint.sourceforge.net/pycdf">pycdf</a> by Andre Gosselin.</p>
|
|
4337
4404
|
<p>Example usage (See <a href="#netCDF4.MFDataset.__init__"><code>__init__</code></a> for more details):</p>
|
|
4338
4405
|
<div class="codehilite"><pre><span class="o">>>></span> <span class="kn">import</span> <span class="nn">numpy</span>
|
|
@@ -4393,7 +4460,7 @@ compound types defined for the <a href="#netCDF4.Group"><code>Group</code></a> o
|
|
|
4393
4460
|
|
|
4394
4461
|
<div class="desc inherited"><p><code>data_model</code> describes the netCDF
|
|
4395
4462
|
data model version, one of <code>NETCDF3_CLASSIC</code>, <code>NETCDF4</code>,
|
|
4396
|
-
<code>NETCDF4_CLASSIC</code> or <code>
|
|
4463
|
+
<code>NETCDF4_CLASSIC</code>, <code>NETCDF3_64BIT_OFFSET</code> or <code>NETCDF3_64BIT_DATA</code>.</p></div>
|
|
4397
4464
|
<div class="source_cont">
|
|
4398
4465
|
</div>
|
|
4399
4466
|
|
|
@@ -4660,7 +4727,7 @@ datatype.</p></div>
|
|
|
4660
4727
|
<div class="desc inherited"><p>Creates a new <a href="#netCDF4.Group"><code>Group</code></a> with the given <code>groupname</code>.</p>
|
|
4661
4728
|
<p>If <code>groupname</code> is specified as a path, using forward slashes as in unix to
|
|
4662
4729
|
separate components, then intermediate groups will be created as necessary
|
|
4663
|
-
(
|
|
4730
|
+
(analogous to <code>mkdir -p</code> in unix). For example,
|
|
4664
4731
|
<code>createGroup('/GroupA/GroupB/GroupC')</code> will create <code>GroupA</code>,
|
|
4665
4732
|
<code>GroupA/GroupB</code>, and <code>GroupA/GroupB/GroupC</code>, if they don't already exist.
|
|
4666
4733
|
If the specified path describes a group that already exists, no error is
|
|
@@ -4870,7 +4937,7 @@ contain all of the matches. For example, </p>
|
|
|
4870
4937
|
<div class="codehilite"><pre><span class="o">>>></span> <span class="c"># Get variables with x-axis attribute.</span>
|
|
4871
4938
|
<span class="o">>>></span> <span class="n">vs</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="s">'X'</span><span class="p">)</span>
|
|
4872
4939
|
<span class="o">>>></span> <span class="c"># Get variables with matching "standard_name" attribute</span>
|
|
4873
|
-
<span class="o">>>></span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">standard_name</span><span class="o">=</span><span class="s">'northward_sea_water_velocity'</span><span class="p">)</span>
|
|
4940
|
+
<span class="o">>>></span> <span class="n">vs</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">get_variables_by_attributes</span><span class="p">(</span><span class="n">standard_name</span><span class="o">=</span><span class="s">'northward_sea_water_velocity'</span><span class="p">)</span>
|
|
4874
4941
|
</pre></div>
|
|
4875
4942
|
|
|
4876
4943
|
|
|
@@ -5148,6 +5215,27 @@ with the same name as one of the reserved python attributes.</p></div>
|
|
|
5148
5215
|
</div>
|
|
5149
5216
|
|
|
5150
5217
|
|
|
5218
|
+
<div class="item">
|
|
5219
|
+
<div class="name def" id="netCDF4.MFDataset.setncattr_string">
|
|
5220
|
+
<p>def <span class="ident">setncattr_string</span>(</p><p>self,name,value)</p>
|
|
5221
|
+
</div>
|
|
5222
|
+
|
|
5223
|
+
<p class="inheritance">
|
|
5224
|
+
<strong>Inheritance:</strong>
|
|
5225
|
+
<code><a href="#netCDF4.Dataset">Dataset</a></code>.<code><a href="#netCDF4.Dataset.setncattr_string">setncattr_string</a></code>
|
|
5226
|
+
</p>
|
|
5227
|
+
|
|
5228
|
+
|
|
5229
|
+
|
|
5230
|
+
<div class="desc inherited"><p>set a netCDF dataset or group string attribute using name,value pair.
|
|
5231
|
+
Use if you need to ensure that of netCDF attribute is created with type
|
|
5232
|
+
<code>NC_STRING</code> if the file format is <code>NETCDF4</code>.</p></div>
|
|
5233
|
+
<div class="source_cont">
|
|
5234
|
+
</div>
|
|
5235
|
+
|
|
5236
|
+
</div>
|
|
5237
|
+
|
|
5238
|
+
|
|
5151
5239
|
<div class="item">
|
|
5152
5240
|
<div class="name def" id="netCDF4.MFDataset.setncatts">
|
|
5153
5241
|
<p>def <span class="ident">setncatts</span>(</p><p>self,attdict)</p>
|
|
@@ -5453,7 +5541,7 @@ method of a <a href="#netCDF4.Dataset"><code>Dataset</code></a> or <a href="#net
|
|
|
5453
5541
|
|
|
5454
5542
|
|
|
5455
5543
|
<div class="desc"><p>A netCDF <a href="#netCDF4.Variable"><code>Variable</code></a> is used to read and write netCDF data. They are
|
|
5456
|
-
|
|
5544
|
+
analogous to numpy array objects. See <a href="#netCDF4.Variable.__init__"><code>__init__</code></a> for more
|
|
5457
5545
|
details.</p>
|
|
5458
5546
|
<p>A list of attribute names corresponding to netCDF attributes defined for
|
|
5459
5547
|
the variable can be obtained with the <a href="#netCDF4.Variable.ncattrs"><code>ncattrs</code></a> method. These
|
|
@@ -5884,7 +5972,9 @@ is set to the missing_value attribute (if it exists), otherwise
|
|
|
5884
5972
|
the netCDF _FillValue attribute (which has a default value
|
|
5885
5973
|
for each data type). When data is written to a variable, the masked
|
|
5886
5974
|
array is converted back to a regular numpy array by replacing all the
|
|
5887
|
-
masked values by the
|
|
5975
|
+
masked values by the missing_value attribute of the variable (if it
|
|
5976
|
+
exists). If the variable has no missing_value attribute, the _FillValue
|
|
5977
|
+
is used instead.</p>
|
|
5888
5978
|
<p>The default value of <code>mask</code> is <code>True</code>
|
|
5889
5979
|
(automatic conversions are performed).</p></div>
|
|
5890
5980
|
<div class="source_cont">
|
|
@@ -5912,7 +6002,9 @@ is set to the missing_value attribute (if it exists), otherwise
|
|
|
5912
6002
|
the netCDF _FillValue attribute (which has a default value
|
|
5913
6003
|
for each data type). When data is written to a variable, the masked
|
|
5914
6004
|
array is converted back to a regular numpy array by replacing all the
|
|
5915
|
-
masked values by the
|
|
6005
|
+
masked values by the missing_value attribute of the variable (if it
|
|
6006
|
+
exists). If the variable has no missing_value attribute, the _FillValue
|
|
6007
|
+
is used instead.</p>
|
|
5916
6008
|
<p>If <code>maskandscale</code> is set to <code>True</code>, and the variable has a
|
|
5917
6009
|
<code>scale_factor</code> or an <code>add_offset</code> attribute, then data read
|
|
5918
6010
|
from that variable is unpacked using::</p>
|
|
@@ -6009,6 +6101,23 @@ attributes.</p></div>
|
|
|
6009
6101
|
</div>
|
|
6010
6102
|
|
|
6011
6103
|
|
|
6104
|
+
<div class="item">
|
|
6105
|
+
<div class="name def" id="netCDF4.Variable.setncattr_string">
|
|
6106
|
+
<p>def <span class="ident">setncattr_string</span>(</p><p>self,name,value)</p>
|
|
6107
|
+
</div>
|
|
6108
|
+
|
|
6109
|
+
|
|
6110
|
+
|
|
6111
|
+
|
|
6112
|
+
<div class="desc"><p>set a netCDF variable string attribute using name,value pair.
|
|
6113
|
+
Use if you need to ensure that of netCDF attribute is created with type
|
|
6114
|
+
<code>NC_STRING</code> if the file format is <code>NETCDF4</code>.</p></div>
|
|
6115
|
+
<div class="source_cont">
|
|
6116
|
+
</div>
|
|
6117
|
+
|
|
6118
|
+
</div>
|
|
6119
|
+
|
|
6120
|
+
|
|
6012
6121
|
<div class="item">
|
|
6013
6122
|
<div class="name def" id="netCDF4.Variable.setncatts">
|
|
6014
6123
|
<p>def <span class="ident">setncatts</span>(</p><p>self,attdict)</p>
|
|
@@ -6036,7 +6145,7 @@ each attribute</p></div>
|
|
|
6036
6145
|
<footer id="footer">
|
|
6037
6146
|
<p>
|
|
6038
6147
|
Documentation generated by
|
|
6039
|
-
<a href="https://github.com/BurntSushi/pdoc">pdoc 0.3.
|
|
6148
|
+
<a href="https://github.com/BurntSushi/pdoc">pdoc 0.3.2.dev16</a>
|
|
6040
6149
|
</p>
|
|
6041
6150
|
|
|
6042
6151
|
<p>pdoc is in the public domain with the
|
|
@@ -13,7 +13,7 @@ n4dim = 144
|
|
|
13
13
|
ntrials = 10
|
|
14
14
|
sys.stdout.write('reading and writing a %s by %s by %s by %s random array ..\n'%(n1dim,n2dim,n3dim,n4dim))
|
|
15
15
|
sys.stdout.write('(average of %s trials)\n' % ntrials)
|
|
16
|
-
array = netCDF4._quantize(uniform(size=(n1dim,n2dim,n3dim,n4dim)),4)
|
|
16
|
+
array = netCDF4.utils._quantize(uniform(size=(n1dim,n2dim,n3dim,n4dim)),4)
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def write_netcdf(filename,zlib=False,shuffle=False,complevel=6):
|
|
@@ -12,22 +12,20 @@ n3dim = 73
|
|
|
12
12
|
n4dim = 144
|
|
13
13
|
ntrials = 10
|
|
14
14
|
sys.stdout.write('reading and writing a %s by %s by %s by %s random array ..\n'%(n1dim,n2dim,n3dim,n4dim))
|
|
15
|
-
sys.stdout.write('(average of %s trials)\n' % ntrials)
|
|
16
|
-
|
|
17
|
-
if lsd is not None:
|
|
18
|
-
array = netCDF4._quantize(uniform(size=(n1dim,n2dim,n3dim,n4dim)),4)
|
|
19
|
-
else:
|
|
20
|
-
array = uniform(size=(n1dim,n2dim,n3dim,n4dim))
|
|
15
|
+
sys.stdout.write('(average of %s trials)\n\n' % ntrials)
|
|
16
|
+
array = uniform(size=(n1dim,n2dim,n3dim,n4dim))
|
|
21
17
|
|
|
22
18
|
|
|
23
|
-
def write_netcdf(filename,complevel):
|
|
19
|
+
def write_netcdf(filename,complevel,lsd):
|
|
24
20
|
file = netCDF4.Dataset(filename,'w',format='NETCDF4')
|
|
25
21
|
file.createDimension('n1', n1dim)
|
|
26
22
|
file.createDimension('n2', n2dim)
|
|
27
23
|
file.createDimension('n3', n3dim)
|
|
28
24
|
file.createDimension('n4', n4dim)
|
|
29
25
|
foo = file.createVariable('data',\
|
|
30
|
-
'f8',('n1','n2','n3','n4')
|
|
26
|
+
'f8',('n1','n2','n3','n4'),\
|
|
27
|
+
zlib=True,shuffle=True,complevel=complevel,\
|
|
28
|
+
least_significant_digit=lsd)
|
|
31
29
|
foo[:] = array
|
|
32
30
|
file.close()
|
|
33
31
|
|
|
@@ -36,10 +34,27 @@ def read_netcdf(filename):
|
|
|
36
34
|
data = file.variables['data'][:]
|
|
37
35
|
file.close()
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
lsd = None
|
|
38
|
+
sys.stdout.write('using least_significant_digit %s\n\n' % lsd)
|
|
39
|
+
for complevel in range(0,10,2):
|
|
40
40
|
sys.stdout.write('testing compression with complevel %s...\n' % complevel)
|
|
41
41
|
# writing.
|
|
42
|
-
t = Timer("write_netcdf('test.nc',%s)" % complevel,"from __main__ import write_netcdf")
|
|
42
|
+
t = Timer("write_netcdf('test.nc',%s,%s)" % (complevel,lsd),"from __main__ import write_netcdf")
|
|
43
|
+
sys.stdout.write('writing took %s seconds\n' %\
|
|
44
|
+
repr(sum(t.repeat(ntrials,1))/ntrials))
|
|
45
|
+
# test reading.
|
|
46
|
+
t = Timer("read_netcdf('test.nc')","from __main__ import read_netcdf")
|
|
47
|
+
sys.stdout.write('reading took %s seconds\n' %
|
|
48
|
+
repr(sum(t.repeat(ntrials,1))/ntrials))
|
|
49
|
+
# print out size of resulting files.
|
|
50
|
+
sys.stdout.write('size of test.nc = %s\n'%repr(os.stat('test.nc').st_size))
|
|
51
|
+
|
|
52
|
+
complevel = 4
|
|
53
|
+
sys.stdout.write('\nusing complevel %s\n\n' % complevel)
|
|
54
|
+
for lsd in range(1,6):
|
|
55
|
+
sys.stdout.write('testing compression with least_significant_digit %s...\n' % lsd)
|
|
56
|
+
# writing.
|
|
57
|
+
t = Timer("write_netcdf('test.nc',%s,%s)" % (complevel,lsd),"from __main__ import write_netcdf")
|
|
43
58
|
sys.stdout.write('writing took %s seconds\n' %\
|
|
44
59
|
repr(sum(t.repeat(ntrials,1))/ntrials))
|
|
45
60
|
# test reading.
|