cfdm.H5netcdfArray


class cfdm.H5netcdfArray(filename=None, address=None, dtype=None, shape=None, mask=True, unpack=True, attributes=None, storage_options=None, source=None, copy=True)[source]

Bases: cfdm.data.mixin.indexmixin.IndexMixin, cfdm.data.abstract.filearray.FileArray

A netCDF array accessed with h5netcdf.

New in version (cfdm): 1.11.2.0

Initialisation

Parameters
filename: (sequence of str), optional

The locations of datasets containing the array.

address: (sequence of str), optional

How to find the array in the datasets.

dtype: numpy.dtype, optional

The data type of the array. May be None if is not known. This may differ from the data type of the array in the datasets.

shape: tuple, optional

The shape of the dataset array.

mask: bool, optional

If True (the default) then mask by convention when reading data from disk.

unpack: bool, optional

If True (the default) then unpack by convention when reading data from disk.

attributes: dict or None, optional

Provide netCDF attributes for the data as a dictionary of key/value pairs.

If attributes is None, the default, then the attributes will be set during the first __getitem__ call.

storage_options: dict or None, optional

Key/value pairs to be passed on to the creation of s3fs.S3FileSystem file systems to control the opening of files in S3 object stores. Ignored for files not in an S3 object store, i.e. those whose names do not start with s3:.

By default, or if None, then storage_options is taken as {}.

If the 'endpoint_url' key is not in storage_options or is not in a dictionary defined by the 'client_kwargs key (which is always the case when storage_options is None), then one will be automatically inserted for accessing an S3 file. For example, for a file name of 's3://store/data/file.nc', an 'endpoint_url' key with value 'https://store' would be created.

Parameter example:

For a file name of 's3://store/data/file.nc', the following are equivalent: None, {}, and {'endpoint_url': 'https://store'}, {'client_kwargs': {'endpoint_url': 'https://store'}}

Parameter example:

{'key': 'scaleway-api-key...', 'secret': 'scaleway-secretkey...', 'endpoint_url': 'https://s3.fr-par.scw.cloud', 'client_kwargs': {'region_name': 'fr-par'}}

source: optional

Convert source, which can be any type of object, to a H5netcdfArray instance.

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the H5netcdfArray API. Any parameters that can not be retrieved from source in this way are assumed to have their default value.

Note that if x is also a H5netcdfArray instance then cfdm.H5netcdfArray(source=x) is equivalent to x.copy().

copy: bool, optional

If True (the default) then deep copy the input parameters prior to initialisation. By default the parameters are not deep copied.

Inspection

Methods

get_compression_type

Returns the array’s compression type.

cfdm.H5netcdfArray.get_subspace

get_attributes

The attributes of the array.

get_missing_values

The missing values of the data.

index

The index to be applied when converting to a numpy array.

is_subspace

True if the index represents a subspace of the data.

Attributes

array

Return an independent numpy array containing the data.

dtype

Data-type of the array.

ndim

Number of array dimensions.

shape

Shape of the array.

size

Number of elements in the array.

original_shape

The shape of the data in the file.

reference_shape

The shape of the data in the file with added dimensions.

Units

Methods

get_calendar

The calendar of the array.

get_units

The units of the array.

Attributes

Units

The Units object containing the units of the array.

File

Methods

file_directory

The file directory.

get_address

The name of the file containing the array.

close

Close the dataset containing the data.

open

Return a dataset file object and address.

get_filename

The name of the file containing the array.

get_groups

The netCDF4 group structure of a netCDF variable.

get_mask

Whether or not to automatically mask the data.

get_unpack

Whether or not to automatically unpack the data.

get_storage_options

Return s3fs.S3FileSystem options for accessing S3 files.

replace_directory

Replace the file directory.

replace_filename

Replace the file location.

Miscellaneous

copy

Return a deep copy of the array.

to_memory

Bring data on disk into memory.

Special

__getitem__

Returns a subspace of the data as a new H5netcdfArray.

Docstring substitutions

Methods

_docstring_special_substitutions

Return the special docstring substitutions.

_docstring_substitutions

Returns the substitutions that apply to methods of the class.

_docstring_package_depth

Returns the class {{package}} substitutions package depth.

_docstring_method_exclusions

Returns method names excluded in the class substitutions.