earthkit.data.data.pp

Classes

PPData

Represent data in UK Met Office PP format.

Module Contents

class earthkit.data.data.pp.PPData(source_or_reader)

Bases: earthkit.data.data.source.SourceData

Represent data in UK Met Office PP format.

PP is a binary file format used by the UK Met Office to store meteorological data. This class provides methods to convert PP data into various formats such as Xarray datasets and FieldLists.

PP data can be converted with the following methods:

property available_types

Return the list of available types that this data object can be converted to.

Type:

list[str]

describe()

Provide a description of the PP data.

Returns:

A DataDescriber object containing a description of the PP data.

Return type:

earthkit.data.utils.summary.DataDescriber

is_stream()

Return False as this data object is not a stream.

property path: str | list[str] | None

Return the path(s) of the data object.

Returns:

The path(s) of the data object.

Return type:

str|List[str]|None

to(to_type, *args, **kwargs)

Convert the data object into another type.

Parameters:
  • to_type (str or Any) – The type to convert to. It can be a str or an object that can be used to determine the target type. In the latter case, the object can be an earthkit-data object or an object that earthkit-data supports as an input. If no suitable conversion method is found, a NotImplementedError will be raised.

  • *args – Positional arguments to pass to the conversion method.

  • **kwargs – Keyword arguments to pass to the conversion method.

Returns:

The converted data object in the target type.

Return type:

Any

Raises:

NotImplementedError – If conversion to the target type is not implemented.

to_array(*args, **kwargs)

Convert into an array of a given array-like type.

This method is not implemented for this data object and raises NotImplementedError.

to_featurelist(*args, **kwargs)

Convert into a featurelist.

This method is not implemented for this data object and raises NotImplementedError.

to_fieldlist(**kwargs)

Convert into a FieldList.

This method first converting the PP data into an Xarray dataset with to_xarray() (using the Iris library), and then converting the resulting Xarray dataset into a FieldList.

Parameters:

**kwargs – Keyword arguments to pass to to_xarray() method, which is used internally to read the PP data before converting it to a FieldList.

Returns:

A FieldList containing the PP data.

Return type:

earthkit.data.readers.pp.fieldlist.PPFieldList

to_geopandas(**kwargs)

Convert into a GeoPandas dataframe.

This method is not implemented for this data object and raises NotImplementedError.

to_numpy(*args, **kwargs)

Convert into a numpy array.

This method is not implemented for this data object and raises NotImplementedError.

to_pandas(*args, **kwargs)

Convert into a pandas dataframe.

This method is not implemented for this data object and raises NotImplementedError.

to_target(target, *args, **kwargs)

Write the data to a target.

Parameters:
  • target (str) – The target to write to. See to_target() for more details on the supported targets.

  • *args – Positional arguments to pass to the to_target()

  • **kwargs – Keyword arguments to pass to the to_target(). Cannot specify data in kwargs.

See also

to_target()

to_value(*args, **kwargs)

Convert into a single value.

This method is not implemented for this data object and raises NotImplementedError.

to_xarray(iris_open_kwargs=None, iris_save_kwargs=None, xr_load_kwargs=None)

Convert into an Xarray dataset.

This method uses the Iris library to read the PP file and convert it into an Xarray dataset. The conversion process involves reading the PP file with iris.load(), then calling ncdata.iris_xarray.cubes_to_xarray().

Parameters:
Returns:

An Xarray dataset containing the PP data.

Return type:

xarray.Dataset