cf.NetCDFArray


class cf.NetCDFArray(filename=None, address=None, dtype=None, shape=None, mask=True, units=False, calendar=False, missing_values=None, source=None, copy=True)[source]

Bases: cf.data.array.mixin.filearraymixin.FileArrayMixin, cf.data.array.mixin.arraymixin.ArrayMixin, cf.mixin_container.Container, cfdm.data.netcdfarray.NetCDFArray

An array stored in a netCDF file.

Initialisation

Parameters
filename: (sequence of) str, optional

The name of the netCDF file(s) containing the array.

address: (sequence of) str or int, optional

The identity of the netCDF variable in each file defined by filename. Either a netCDF variable name or an integer netCDF variable ID.

New in version (cfdm): 1.10.1.0

dtype: numpy.dtype

The data type of the array in the netCDF file. May be None if the numpy data-type is not known (which can be the case for netCDF string types, for example).

shape: tuple

The array dimension sizes in the netCDF file.

size: int

Number of elements in the array in the netCDF file.

ndim: int

The number of array dimensions in the netCDF file.

mask: bool

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

A netCDF array is masked depending on the values of any of the netCDF variable attributes valid_min, valid_max, valid_range, _FillValue and missing_value.

New in version (cfdm): 1.8.2

units: str or None, optional

The units of the netCDF variable. Set to None to indicate that there are no units. If unset then the units will be set during the first __getitem__ call.

New in version (cfdm): 1.10.0.1

calendar: str or None, optional

The calendar of the netCDF variable. By default, or if set to None, then the CF default calendar is assumed, if applicable. If unset then the calendar will be set during the first __getitem__ call.

New in version (cfdm): 1.10.0.1

missing_values: dict, optional

The missing value indicators defined by the netCDF variable attributes. See get_missing_values for details.

New in version (cfdm): 1.10.0.3

source: optional

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

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the NetCDFArray 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 NetCDFArray instance then cf.NetCDFArray(source=x) is equivalent to x.copy().

New in version (cfdm): 1.10.0.0

copy: bool, optional

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

New in version (cfdm): 1.10.0.0

ncvar: Deprecated at version 1.10.1.0

Use the address parameter instead.

varid: Deprecated at version 1.10.1.0

Use the address parameter instead.

group: Deprecated at version 1.10.1.0

Use the address parameter instead.

Methods

add_file_location

Add a new file location.

close

Close the dataset containing the data.

copy

Return a deep copy of the array.

del_file_location

Remove reference to files in the given location.

file_locations

The locations of the files, any of which may contain the data.

filename

The name of the file containing the array.

get_address

The name of the file containing the array.

get_addresses

Return the names of the data addresses in the files.

get_format

The format of the files.

get_formats

Return the format of the files.

get_calendar

The calendar of the array.

get_compression_type

Returns the array’s compression type.

get_filename

The name of the file containing the array.

get_filenames

Return the names of files containing the data.

cf.NetCDFArray.get_group

get_groups

The netCDF4 group structure of a netCDF variable.

get_mask

Whether or not to automatically mask the data.

get_missing_values

The missing value indicators from the netCDF variable.

cf.NetCDFArray.get_ncvar

get_subspace

Return a subspace, defined by indices, of a numpy array.

get_units

The units of the array.

cf.NetCDFArray.get_varid

open

Return an open file object containing the data array.

to_memory

Bring data on disk into memory.

Units

The cf.Units object containing the units of the array.

Attributes

array

Return an independent numpy array containing the data.

dtype

Data-type of the array.

cf.NetCDFArray.file_address

ndim

Number of array dimensions.

shape

Shape of the array.

size

Number of elements in the array.

Special

Methods

__getitem__

Returns a subspace of the array as a numpy array.