cfdm.Data.nc_set_hdf5_chunksizes¶
-
Data.
nc_set_hdf5_chunksizes
(chunksizes)[source]¶ Set the HDF5 chunking strategy for the data.
New in version (cfdm): 1.7.2
- Parameters
- chunksizes:
None
orstr
orint
orfloat
ordict
or a sequence Set the chunking strategy for writing to a netCDF4 file. One of:
None
: No HDF5 chunking strategy has been defined. The chunking strategy will be determined at write time bycfdm.write
.'contiguous'
: The data will be written to the file contiguously, i.e. no chunking.int
orfloat
orstr
: The size in bytes of the HDF5 chunks. A floating point value is rounded down to the nearest integer, and a string represents a quantity of byte units. “Square-like” chunk shapes are preferred, maximising the amount of chunks that are completely filled with data values (see thecfdm.write
hdf5_chunks parameter for details). For instance a chunksize of 1024 bytes may be specified with any of1024
,1024.9
,'1024'
,'1024.9'
,'1024 B'
,'1 KiB'
,'0.0009765625 MiB'
, etc. Recognised byte units are (case insensitive):B
,KiB
,MiB
,GiB
,TiB
,PiB
,KB
,MB
,GB
,TB
, andPB
. Spaces in strings are optional.sequence of
int
orNone
: The maximum number of array elements in a chunk along each data axis, provided in the same order as the data axes. Values are automatically limited to the full size of their corresponding data axis, but the special valuesNone
or-1
may be used to indicate the full axis size. This chunking strategy may get automatically modified by methods that change the data shape (such asinsert_dimension
).dict
: The maximum number of array elements in a chunk along the axes specified by the dictionary keys. Integer values are automatically limited to the full size of their corresponding data axis, and the special valuesNone
or-1
may be used to indicate the full axis size. The chunk size for an unspecified axis defaults to an existing chunk size for that axis, if there is one, or else the axis size. This chunking strategy may get automatically modified by methods that change the data shape (such asinsert_dimension
). Each dictionary key is an integer that specifies an axis by its position in the data array.
- chunksizes:
- Returns
Examples
>>> d.shape (1, 96, 73) >>> d.nc_set_hdf5_chunksizes([1, 35, 73]) >>> d.nc_hdf5_chunksizes() (1, 35, 73) >>> d.nc_clear_hdf5_chunksizes() (1, 35, 73) >>> d.nc_hdf5_chunksizes() None >>> d.nc_set_hdf5_chunksizes('contiguous') >>> d.nc_hdf5_chunksizes() 'contiguous' >>> d.nc_set_hdf5_chunksizes('1 KiB') >>> d.nc_hdf5_chunksizes() 1024 >>> d.nc_set_hdf5_chunksizes(None) >>> d.nc_hdf5_chunksizes() None >>> d.nc_set_hdf5_chunksizes([9999, -1, None]) >>> d.nc_hdf5_chunksizes() (1, 96, 73) >>> d.nc_clear_hdf5_chunksizes() (1, 96, 73) >>> d.nc_set_hdf5_chunksizes({1: 24}) >>> d.nc_hdf5_chunksizes() (1, 24, 73) >>> d.nc_set_hdf5_chunksizes({0: None, 2: 50}) >>> d.nc_hdf5_chunksizes() (1, 24, 50)