cf.UMArray


class cf.UMArray(filename=None, address=None, dtype=None, shape=None, fmt=None, word_size=None, byte_ordering=None, mask=True, unpack=True, attributes=None, storage_options=None, source=None, copy=True)[source]

A sub-array stored in a PP or UM fields file.

Initialisation

Parameters:
filename: (sequence of) str, optional

The file name(s).

address: (sequence of) int, optional

The start position in the file(s) of the header(s).

Added in version 3.15.0.

dtype: numpy.dtype

The data type of the data array on disk.

shape: tuple

The shape of the unpacked data array. Note that this is the shape as required by the object containing the UMArray object, and so may contain extra size one dimensions. When read, the data on disk is reshaped to shape.

fmt: str, optional

'PP' or 'FF'

word_size: int, optional

4 or 8

byte_ordering: str, optional

'little_endian' or 'big_endian'

attributes: dict or None, optional

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

During the first __getitem__ call, any of the _FillValue, add_offset, scale_factor, units, and calendar attributes which haven’t already been set will be inferred from the lookup header and cached for future use.

Added in version 3.16.3.

source: optional

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

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

size: int

Deprecated at version 3.14.0.

ndim: int

Deprecated at version 3.14.0.

header_offset: int

Deprecated at version 3.15.0. Use the address parameter instead.

data_offset: int, optional

Deprecated at version 3.15.0.

disk_length: int, optional

Deprecated at version 3.15.0.

units: str or None, optional

Deprecated at version 3.16.3. Use the attributes parameter instead.

calendar: str or None, optional

Deprecated at version 3.16.3. Use the attributes parameter instead.

Inspection

Methods

get_compression_type

Returns the array's compression type.

get_attributes

The attributes of the array.

get_byte_ordering

The endianness of the data.

get_fmt

The file format of the UM file containing the array.

get_word_size

Word size in bytes.

get_mask

Whether or not to automatically mask the data.

get_unpack

Whether or not to automatically unpack the data.

is_subspace

True if the index represents a subspace of the data.

index

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

Attributes

array

Return an independent numpy array containing the data.

astype

Cast the data to a specified type.

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.

Units

The Units object containing the units of the array.

File

Methods

get_address

The name of the file containing the array.

close

Close the dataset containing the data.

open

Returns an open dataset and the address of the data.

get_filename

The name of the file containing the array.

get_format

The format of the files.

get_storage_options

Return s3fs.S3FileSystem options for accessing S3 files.

Miscellaneous

copy

Return a deep copy of the array.

to_memory

Bring data on disk into memory.

file_directory

The file directory.

replace_directory

Replace the file directory.

replace_filename

Replace the file location.

Special

__dask_tokenize__

Return a value fully representative of the object.

__getitem__

Returns a subspace of the data as a new UMArray.

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.

Deprecated

Methods

get_missing_values

The missing values of the data.

byte_ordering

The endianness of the data.

data_offset

The start position in the file of the data array.

file_address

The file name and address.

fmt

The file format of the UM file containing the array.

disk_length

The number of words on disk for the data array.

header_offset

The start position in the file of the header.

word_size

Word size in bytes.