cfdm.AggregatedArray¶
- class cfdm.AggregatedArray(filename=None, address=None, dtype=None, mask=True, unpack=True, fragment_array=None, attributes=None, filesystem=None, backend=None, backend_options=None, fragment_filesystem=None, fragment_backend=None, fragment_backend_options=None, source=None, copy=True)[source]¶
Bases:
FileArrayAn array stored in a CF aggregation variable.
Added in version (cfdm): 1.12.0.0
Initialisation
- Parameters:
- filename:
str, optional The name of the aggregation file containing the aggregation variable.
- address:
str, optional The name of the aggregation variable for the array.
- dtype:
numpy.dtype The data type of the aggregated data array. May be
Noneif the numpy data-type is not known (which can be the case for some string types, for example).- 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.
- fragment_array:
dict A dictionary representation of the fragment array, in either “uri” form:
{'map': <'map' fragment variable data>, 'uris': <'uris' fragment variable data>, 'identifiers': <'identifiers' fragment variable data>}
or else in “unique_value” form:
{'map': <'map' fragment variable data>, 'unique_values': <'unique_values' fragment variable data>}
- filesystem: optional
A pre-authenticated filesystem object (for example an
fsspecfilesystem 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 callingfilesystem.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 filesystemopenmethod; for instance, the dataset's3://authority/bucket/file.nc'is treated asfilesystem.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:
Noneor (sequence of)str, optional Which library to use for opening a string-like, file-like, or directory-like dataset. An attempt to read the dataset is made by the given backends in the order in which they are provided, stopping after the first successful read. By default backend isNone, which is equivalent to providing the ordered sequence of backends:('pyfive', 'zarr', 'umfive', 'netCDF4', 'netcdf_file', 'h5py', 'xarray')If the dataset is given as a (subclass of a) backend object, then that backend must be one of the backends identified by the backend parameter.
Performance may be improved by specifying a backend library, as this reduces or removes unsuccessful dataset read attempts, which can be expensive, especially for remote datasets.
The available backends, and the formats they can read, are:
Backend
Library
Dataset formats
'pyfive'pyfivenetCDF-4
'zarr'Zarr, Kerchunk
'umfive'umfivePP, fields file
'netCDF4'netCDF4netCDF-4, netCDF-3
'netcdf_file'scipy.io.netcdf_filenetCDF-3
'h5py'h5pynetCDF-4
'xarray'xarraynetCDF-4, netCDF-3, Zarr, Kerchunk, GRIB
Note that the
xarraylibrary is itself an interface to other backends.- Example:
To only attempt
'netCDF4':'netCDF4'or['netCDF4']- Example:
To only attempt
'netCDF4'or'pyfive', in that order:('netCDF4', 'pyfive')Added in version (cfdm): 1.13.3.0
- backend_options:
Noneordict, optional The options to use with each backend when opening a dataset.
Added in version (cfdm): 1.13.3.0
- attributes:
dictorNone, 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 the netCDF variable during the first__getitem__call.- fragment_filesystem: optional
A pre-authenticated filesystem object (for example an
fsspecfilesystem instance) to use for opening the fragment.If
None(the default) then a fragment path is passed unchanged to the backends defined by the fragament_backend parameter.When provided, a fragment path (
fragment) is treated as the file-like objectfilesytem.open(fragment, 'rb')which is passed to the backends (see the fragment_backend parameter).Added in version (cfdm): 1.13.3.0
- fragment_backend:
Noneor (sequence of)str, optional Which library or libraries to use for reading the fragment. When the fragment is accessed, an attempt to open each fragment dataset is made by the given backends in order, stopping after the first successful read. The available backends are those allowed by
xnetcdf.By default fragment_backend is
None, which is equivalent to providing the ordered sequence of the default backends forxnetcdf.Added in version (cfdm): 1.13.3.0
- fragment_backend_options:
Noneordict, optional The options to use with each backend when opening a fragment dataset.
Added in version (cfdm): 1.13.3.0
- source: optional
Convert source, which can be any type of object, to a
AggregatedArrayinstance.All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the
AggregatedArrayAPI. Any parameters that can not be retrieved from source in this way are assumed to have their default value.Note that if
xis also aAggregatedArrayinstance thencfdm.AggregatedArray(source=x)is equivalent tox.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 NEXTERSION
Use filesystem instead.
- storage_protocol: Deprecated at version NEXTERSION
Use filesystem instead.
- filename:
Methods¶
Methods
The |
|
Return an independent numpy array containing the data. |
|
Cast the data to a specified type. |
|
Close the dataset containing the data. |
|
Return a deep copy of the array. |
|
Data-type of the array. |
|
The file directory. |
|
The name of the file containing the array. |
|
The attributes of the array. |
|
The names of the packages for accessing the dataset. |
|
Backend options when opening a dataset. |
|
The calendar of the array. |
|
Returns the array's compression type. |
|
The name of the file containing the array. |
|
Return the file system which contains the dataset. |
|
Get the aggregation data dictionary. |
|
Get the sizes of the fragment dimensions. |
|
The names of the packages for accessing the fragment dataset. |
|
Backend options when opening a fragment dataset. |
|
Return the file system which contains the fragment dataset. |
|
The type of fragments in the fragment array. |
|
The positions of dimensions spanned by two or more fragments. |
|
Whether or not to automatically mask the data. |
|
The missing values of the data. |
|
Return the file system options. |
|
The file system protocol. |
|
The units of the array. |
|
Whether or not to automatically unpack the data. |
|
Get the open dataset variable object for the data. |
|
Whether or not there is a remote file system protocol. |
|
Number of array dimensions. |
|
Return a dataset file object and address. |
|
Replace the file directory. |
|
Replace the file location. |
|
Shape of the array. |
|
Number of elements in the array. |
|
Create the subarray shapes. |
|
Return descriptors for every subarray. |
|
Create a dask array with |
|
Bring data on disk into memory. |