cfdm.XnetcdfArray


class cfdm.XnetcdfArray(filename=None, address=None, dtype=None, shape=None, mask=True, unpack=True, attributes=None, filesystem=None, backend=None, backend_options=None, variable=None, source=None, copy=True)[source]

Bases: IndexMixin, FileArray

A netCDF array accessed with xnetcdf.

Added in version (cfdm): 1.13.3.0

Initialisation

Parameters:
filename: (sequence of str), optional

The location of the dataset containing the array.

address: (sequence of str), optional

How to find the array in the dataset.

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 dataset.

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 from those in the dataset during the first __getitem__ call.

filesystem: optional

A pre-authenticated filesystem object (for example an fsspec filesystem instance) to use for opening the filename. When the dataset is given as a string, it is treated as a path understood by filesystem and the dataset will be opened by calling filesystem.open(dataset, 'rb'), the result of which will be passed to the backend(s) (see the backend parameter). S3 is a special case for which the leading scheme and authority is automatically removed from the dataset name passed to the filesystem open method; for instance, the dataset 's3://authority/bucket/file.nc' is treated as filesystem.open('bucket/file.nc', 'rb').

If filename is not a string then filesystem is ignored.

If None (the default) then filename, regardless of its type, is passed unchanged to the backends.

Added in version (cfdm): 1.13.1.0

backend: None or (sequence of) str, optional

Which library to use for opening a dataset.

Added in version (cfdm): 1.13.3.0

backend_options: None or dict, optional

The options to use with each backend when opening a dataset.

Added in version (cfdm): 1.13.1.0

variable: optional

An open dataset variable object. Setting variable does not replace the need for the filename and address parameters, instead it complements them by allowing faster data access.

Added in version (cfdm): 1.13.1.0

source: optional

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

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the XnetcdfArray 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 XnetcdfArray instance then cfdm.XnetcdfArray(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.

storage_options: Deprecated at version (cfdm) 1.13.3.0

Use filesystem instead.

storage_protocol: Deprecated at version (cfdm) 1.13.3.0

Use filesystem instead.

Inspection

Methods

get_compression_type

Returns the array's compression type.

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 object and address.

get_filename

The name of the file containing the array.

get_mask

Whether or not to automatically mask the data.

get_unpack

Whether or not to automatically unpack the data.

get_storage_options

Return the file system options.

replace_directory

Replace the file directory.

replace_filename

Replace the file location.

get_storage_protocol

The file system protocol.

get_variable

Get the open dataset variable object for the data.

has_remote_storage_protocol

Whether or not there is a remote file system protocol.

get_backend

The names of the packages for accessing the dataset.

get_backend_options

Backend options when opening a dataset.

get_filesystem

Return the file system which contains the dataset.

Miscellaneous

copy

Return a deep copy of the array.

to_memory

Bring data on disk into memory.

astype

Cast the data to a specified type.

Special

__getitem__

Returns a subspace of the data as a new XnetcdfArray.

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.