earthkit.data.encoders.bufr

Attributes

Classes

BufrEncodedData

Base class for representing encoded data.

BufrEncoder

Encode BUFR data.

Module Contents

class earthkit.data.encoders.bufr.BufrEncodedData(handle)

Bases: earthkit.data.encoders.EncodedData

Base class for representing encoded data.

It is meant to be used by a Target to write/add data to a given target. It is the return value from the Encoder.encode() method.

get(key, default=None)
handle
prefer_file_path = False
to_bytes()

Return the data as a bytesarray.

to_file(f)

Write the data to a file.

Parameters:

f (file-like object) – File-like object to write to

class earthkit.data.encoders.bufr.BufrEncoder(**kwargs)

Bases: earthkit.data.encoders.Encoder

Encode BUFR data.

encode(data=None, target=None, **kwargs)

Encode the data.

Parameters:
  • data (obj, None) – The data to encode. Should be used via double dispatch. Must have an _encode() method, which will call the appropriate _encode_* method on the Encoder.

  • values (obj, None) – The values to encode.

  • check_nans (bool) – If True, check for NaN values in the data and replace them with the missing_value.

  • metadata (dict) – Metadata to use when encoding the data. When None, the metadata the Encoder was created with will be used if available.

  • template (obj, None) – The template to use to encode the data. When None, the template the Encoder was created with will be used if available.

  • missing_value (number) – The value to use for missing values.

  • target (Target, None) – The target to write to. Can be used by the encoder to determine how to encode the data. When None, the encoder will determine the target from the data to write (if possible) or from the Encoder properties.

  • **kwargs (dict) – Additional keyword arguments.

Returns:

The encoded data.

Return type:

EncodedData

metadata
template = None
earthkit.data.encoders.bufr.encoder