Logo Iris 1.12

Previous topic

iris.experimental.ugrid

Next topic

iris.fileformats

This Page

iris.experimental.um

Low level support for UM FieldsFile variants.

In this module:

Represents a single entry in the LOOKUP component and its corresponding section of the DATA component.

class iris.experimental.um.Field(int_headers, real_headers, data_provider)

Bases: object

Create a Field from the integer headers, the floating-point headers, and an object which provides access to the corresponding data.

Args:

  • int_headers:

    A sequence of integer header values.

  • real_headers:

    A sequence of floating-point header values.

  • data_provider:

    Either, an object with a read_data() method which will provide the corresponding values from the DATA component, or a NumPy array, or None.

get_data()

Return a NumPy array containing the data for this field.

Data packed with the WGDOS archive method will be unpacked and returned as int/float data as appropriate.

num_values()

Return the number of values defined by this header.

set_data(data)

Set the data payload for this field.

  • data:

    Either, an object with a read_data() method which will provide the corresponding values from the DATA component, or a NumPy array, or None.

LBEGIN_OFFSET = 28

Zero-based index for lbegin.

LBLREC_OFFSET = 14

Zero-based index for lblrec.

LBNREC_OFFSET = 29

Zero-based index for lbnrec.

LBREL_OFFSET = 21

Zero-based index for lbrel.

int_headers = None

A NumPy array of integer header values.

real_headers = None

A NumPy array of floating-point header values.

↑ top ↑

Represents an entry from the LOOKUP component with a header release number of 2.

class iris.experimental.um.Field2(int_headers, real_headers, data_provider)

Bases: iris.experimental.um.Field

Create a Field from the integer headers, the floating-point headers, and an object which provides access to the corresponding data.

Args:

  • int_headers:

    A sequence of integer header values.

  • real_headers:

    A sequence of floating-point header values.

  • data_provider:

    Either, an object with a read_data() method which will provide the corresponding values from the DATA component, or a NumPy array, or None.

get_data()

Return a NumPy array containing the data for this field.

Data packed with the WGDOS archive method will be unpacked and returned as int/float data as appropriate.

num_values()

Return the number of values defined by this header.

set_data(data)

Set the data payload for this field.

  • data:

    Either, an object with a read_data() method which will provide the corresponding values from the DATA component, or a NumPy array, or None.

LBEGIN_OFFSET = 28
LBLREC_OFFSET = 14
LBNREC_OFFSET = 29
LBREL_OFFSET = 21
bacc
bdatum
bdx
bdy
bgor
bhlev
bhrlev
blev
bmdi
bmks
bplat
bplon
brlev
brsvd1
brsvd2
brsvd3
brsvd4
bzx
bzy
lbcfc
lbcode
lbdat
lbdatd
lbday
lbdayd
lbegin
lbexp
lbext
lbfc
lbft
lbhem
lbhr
lbhrd
lblev
lblrec
lbmin
lbmind
lbmon
lbmond
lbnpt
lbnrec
lbpack
lbproc
lbproj
lbrel
lbrow
lbrsvd1
lbrsvd2
lbrsvd3
lbrsvd4
lbrvc
lbsrce
lbtim
lbtyp
lbuser1
lbuser2
lbuser3
lbuser4
lbuser5
lbuser6
lbuser7
lbvc
lbyr
lbyrd

↑ top ↑

Represents an entry from the LOOKUP component with a header release number of 3.

class iris.experimental.um.Field3(int_headers, real_headers, data_provider)

Bases: iris.experimental.um.Field

Create a Field from the integer headers, the floating-point headers, and an object which provides access to the corresponding data.

Args:

  • int_headers:

    A sequence of integer header values.

  • real_headers:

    A sequence of floating-point header values.

  • data_provider:

    Either, an object with a read_data() method which will provide the corresponding values from the DATA component, or a NumPy array, or None.

get_data()

Return a NumPy array containing the data for this field.

Data packed with the WGDOS archive method will be unpacked and returned as int/float data as appropriate.

num_values()

Return the number of values defined by this header.

set_data(data)

Set the data payload for this field.

  • data:

    Either, an object with a read_data() method which will provide the corresponding values from the DATA component, or a NumPy array, or None.

LBEGIN_OFFSET = 28
LBLREC_OFFSET = 14
LBNREC_OFFSET = 29
LBREL_OFFSET = 21
bacc
bdatum
bdx
bdy
bgor
bhlev
bhrlev
blev
bmdi
bmks
bplat
bplon
brlev
brsvd1
brsvd2
brsvd3
brsvd4
bzx
bzy
lbcfc
lbcode
lbdat
lbdatd
lbegin
lbexp
lbext
lbfc
lbft
lbhem
lbhr
lbhrd
lblev
lblrec
lbmin
lbmind
lbmon
lbmond
lbnpt
lbnrec
lbpack
lbproc
lbproj
lbrel
lbrow
lbrsvd1
lbrsvd2
lbrsvd3
lbrsvd4
lbrvc
lbsec
lbsecd
lbsrce
lbtim
lbtyp
lbuser1
lbuser2
lbuser3
lbuser4
lbuser5
lbuser6
lbuser7
lbvc
lbyr
lbyrd

↑ top ↑

Represents a single a file containing UM FieldsFile variant data.

class iris.experimental.um.FieldsFileVariant(filename, mode=READ_MODE, word_size=8)

Bases: object

Opens the given filename as a UM FieldsFile variant.

Args:

  • filename:

    The name of the file containing the UM FieldsFile variant.

Kwargs:

  • mode:

    The file access mode: READ_MODE for read-only; UPDATE_MODE for amending; CREATE_MODE for creating a new file.

  • word_size:

    The number of byte in each word.

close()

Write out any pending changes, and close the underlying file.

If the file was opened for update or creation then the current state of the fixed length header, the constant components (e.g. integer_constants, level_dependent_constants), and the list of fields are written to the file before closing. The process of writing to the file also updates the values in the fixed length header and fields which relate to layout within the file. For example, integer_constants_start and integer_constants_shape within the fixed length header, and the lbegin and lbnrec elements within the fields.

If the file was opened in read mode then no changes will be made.

After calling close() any subsequent modifications to any of the attributes will have no effect on the underlying file.

Calling close() more than once is allowed, but only the first call will have any effect.

Note

On output, each field’s data is encoded according to the LBPACK and BACC words in the field. A field data array defined using Field.set_data() can only be written in an “unpacked” form, corresponding to LBACK=0 (or the equivalent 2000 / 3000). However, data from the input file can be saved in its original packed form, as long as the data, LBPACK and BACC remain unchanged.

CREATE_MODE = CREATE_MODE

The file will be created, overwriting the file if it already exists.

READ_MODE = READ_MODE

The file will be opened for read-only access.

UPDATE_MODE = UPDATE_MODE

The file will be opened for update.

filename
mode

↑ top ↑

Represents the FIXED_LENGTH_HEADER component of a UM FieldsFile variant.

Access to simple header items is provided via named attributes, e.g. fixed_length_header.sub_model. Other header items can be accessed via the raw attribute which provides a simple array view of the header.

class iris.experimental.um.FixedLengthHeader(integers)

Bases: object

Create a FixedLengthHeader from the given sequence of integer values.

classmethod empty(word_size=8)
classmethod from_file(source, word_size=8)

Create a FixedLengthHeader from a file-like object.

Args:

  • source:

    The file-like object to read from.

Kwargs:

  • word_size:

    The number of bytes in each word of the header.

IMDI = -32768
NUM_WORDS = 256
calendar
column_dependent_constants_shape
column_dependent_constants_start
compressed_field_index1_shape
compressed_field_index1_start
compressed_field_index2_shape
compressed_field_index2_start
compressed_field_index3_shape
compressed_field_index3_start
data_set_format_version
data_shape
data_start
dataset_type
experiment_number
extra_constants_shape
extra_constants_start
fields_of_constants_shape
fields_of_constants_start
grid_staggering
horiz_grid_type
integer_constants_shape
integer_constants_start
last_fieldop_type
level_dependent_constants_shape
level_dependent_constants_start
lookup_shape
lookup_start
max_length
model_version
obs_file_type
projection_number
raw
real_constants_shape
real_constants_start
row_dependent_constants_shape
row_dependent_constants_start
run_identifier
sub_model
temp_historyfile_shape
temp_historyfile_start
time_type
total_prognostic_fields
vert_coord_type