cf.Data.nc_set_dataset_chunksizes

Data.nc_set_dataset_chunksizes(chunksizes)[source]

Set the dataset chunking strategy for the data.

Added in version (cfdm): 1.12.2.0

Parameters:
chunksizes: None or str or int or float or dict or a sequence

Set the chunking strategy for writing to a netCDF4 file. One of:

  • None: No dataset chunking strategy has been defined. The chunking strategy will be determined at write time by cf.write.

  • 'contiguous'

    The data will be written to the file contiguously, i.e. no chunking.

  • int or float or str

    The size in bytes of the dataset 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 the cf.write dataset_chunks parameter for details). For instance a chunksize of 1024 bytes may be specified with any of 1024, 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, and PB. Spaces in strings are optional.

  • sequence of int or None

    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 values None 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 as insert_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 values None 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 as insert_dimension).

    Each dictionary key is an integer that specifies an axis by its position in the data array.

Returns:

None

Examples

>>> d.shape
(1, 96, 73)
>>> d.nc_set_dataset_chunksizes([1, 35, 73])
>>> d.nc_dataset_chunksizes()
(1, 35, 73)
>>> d.nc_clear_dataset_chunksizes()
(1, 35, 73)
>>> d.nc_dataset_chunksizes()
None
>>> d.nc_set_dataset_chunksizes('contiguous')
>>> d.nc_dataset_chunksizes()
'contiguous'
>>> d.nc_set_dataset_chunksizes('1 KiB')
>>> d.nc_dataset_chunksizes()
1024
>>> d.nc_set_dataset_chunksizes(None)
>>> d.nc_dataset_chunksizes()
None
>>> d.nc_set_dataset_chunksizes([9999, -1, None])
>>> d.nc_dataset_chunksizes()
(1, 96, 73)
>>> d.nc_clear_dataset_chunksizes()
(1, 96, 73)
>>> d.nc_set_dataset_chunksizes({1: 24})
>>> d.nc_dataset_chunksizes()
(1, 24, 73)
>>> d.nc_set_dataset_chunksizes({0: None, 2: 50})
>>> d.nc_dataset_chunksizes()
(1, 24, 50)