From c25c53d5dca620c2db78f88fb90fccb9f9dfa25b Mon Sep 17 00:00:00 2001
From: Jeff Whitaker Groups in a netCDF file
object yields summary information about it's contents.
>>> def walktree(top):
-... values = top.groups.values()
-... yield values
+... yield top.groups.values()
... for value in top.groups.values():
-... for children in walktree(value):
-... yield children
+... yield from walktree(value)
>>> print(rootgrp)
<class 'netCDF4._netCDF4.Dataset'>
root group (NETCDF4 data model, file format HDF5):
@@ -987,8 +985,9 @@ Writing data
The result will be a numpy scalar array.
By default, netcdf4-python returns numpy masked arrays with values equal to the
-missing_value
or _FillValue
variable attributes masked. The
-Dataset.set_auto_mask
Dataset
and Variable
methods
+missing_value
or _FillValue
variable attributes masked for primitive and
+enum data types.
+The Dataset.set_auto_mask
Dataset
and Variable
methods
can be used to disable this feature so that
numpy arrays are always returned, with the missing values included. Prior to
version 1.4.0 the default behavior was to only return masked arrays when the
@@ -1596,7 +1595,7 @@
In-memory (diskless) Datasets
the parallel IO example, which is in examples/mpi_example.py
.
Unit tests are in the test
directory.
-contact: Jeffrey Whitaker jeffrey.s.whitaker@noaa.gov
+contact: Jeffrey Whitaker jeffrey.s.whitaker@noaa.gov
copyright: 2008 by Jeffrey Whitaker.
@@ -2403,7 +2402,8 @@ In-memory (diskless) Datasets
set_auto_mask(self, True_or_False)
Call Variable.set_auto_mask
for all variables contained in this Dataset
or
-Group
, as well as for all variables in all its subgroups.
+Group
, as well as for all variables in all its subgroups. Only affects
+Variables with primitive or enum types (not compound or vlen Variables).
True_or_False
: Boolean determining if automatic conversion to masked arrays
shall be applied for all variables.
@@ -2744,7 +2744,8 @@ In-memory (diskless) Datasets
mask
: If True, data is automatically converted to/from masked
arrays when missing values or fill values are present. Default is True
, can be
reset using Variable.set_auto_mask
and Variable.set_auto_maskandscale
-methods.
+methods. Only relevant for Variables with primitive or enum types (ignored
+for compound and vlen Variables).
chartostring
: If True, data is automatically converted to/from character
arrays to string arrays when the _Encoding
variable attribute is set.
From e5eb3fa062516398895cef2a16558bbaef6d00d8 Mon Sep 17 00:00:00 2001
From: Jeff Whitaker
Date: Sun, 20 Jun 2021 15:59:19 -0600
Subject: [PATCH 2/3] fix test so it doesn't fail on 32 bit machines
---
test/tst_slicing.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/tst_slicing.py b/test/tst_slicing.py
index 7d56f54c6..1b5c0bde2 100644
--- a/test/tst_slicing.py
+++ b/test/tst_slicing.py
@@ -2,7 +2,7 @@
from numpy.random import seed, randint
from numpy.testing import assert_array_equal, assert_equal,\
assert_array_almost_equal
-import tempfile, unittest, os, random
+import tempfile, unittest, os, random, sys
import numpy as np
file_name = tempfile.NamedTemporaryFile(suffix='.nc', delete=False).name
@@ -35,8 +35,8 @@ def setUp(self):
vu[:,::-1,:] = data
v1[:] = data[:, 0, 0]
- #v2[0:2**31] = 1 # issue 1112 (overflow on windows)
- v2[2**31] = 1 # issue 1112 (overflow on windows)
+ if sys.maxsize > 2**32:
+ v2[2**31] = 1 # issue 1112 (overflow on windows)
f.close()
def tearDown(self):
@@ -82,8 +82,8 @@ def test_1d(self):
v2 = f.variables['data1dx']
d = data[:,0,0]
assert_equal(v1[:], d)
- #assert_equal(v2[:], np.ones(2**31,dtype=np.uint8))
- assert_equal(v2[2**31], 1)
+ if sys.maxsize > 2**32:
+ assert_equal(v2[2**31], 1)
assert_equal(v1[4:], d[4:])
# test return of array scalar.
assert_equal(v1[0].shape, ())
From 26761d0826de4bb695074fe7be43973dd2a0f206 Mon Sep 17 00:00:00 2001
From: Jeff Whitaker
Date: Sun, 20 Jun 2021 20:26:41 -0600
Subject: [PATCH 3/3] update
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 268179b08..cebdc014c 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,10 @@
## News
For details on the latest updates, see the [Changelog](https://github.com/Unidata/netcdf4-python/blob/master/Changelog).
+6/22/2021: Version [1.5.7](https://pypi.python.org/pypi/netCDF4/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](https://pypi.python.org/pypi/netCDF4/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](https://pypi.python.org/pypi/netCDF4/1.5.5.1) released.