dataobjects API detail#

_BaseData#

The base dataclass inherited by (most of) the dataclasses below.

class openghg.dataobjects._BaseData(data, metadata)[source]#
__delattr__(name)#

Implement delattr(self, name).

__eq__(other)#

Return self==value.

__hash__()#

Return hash(self).

__init__(data, metadata)#
__repr__()#

Return repr(self).

__setattr__(name, value)#

Implement setattr(self, name, value).

__str__()[source]#

Return str(self).

Return type

str

SearchResults#

This dataclass is returned by the openghg.client.search function and allows easy retrieval and querying of metadata retrieved by the search function.

class openghg.dataobjects.SearchResults(keys=None, metadata=None)[source]#

This class is used to return data from the search function. It has member functions to retrieve data from the object store.

Parameters
  • keys (Optional[Dict]) – Dictionary of keys keyed by Datasource UUID

  • metadata (Optional[Dict]) – Dictionary of metadata keyed by Datasource UUID

__init__(keys=None, metadata=None)[source]#
__repr__()[source]#

Return repr(self).

Return type

str

__str__()[source]#

Return str(self).

Return type

str

classmethod from_json(data)[source]#

Create a SearchResults object from a dictionary

Parameters

data (Union[bytes, str]) – Serialised object

Returns

SearchResults object

Return type

SearchResults

retrieve(dataframe=None, sort=True, elevate_inlet=False, **kwargs)[source]#

Retrieve data from object store using a filtered pandas DataFrame

Parameters
  • dataframe (Optional[DataFrame]) – pandas DataFrame

  • sort (bool) – Sort data by date in retrieved Dataset

  • elevate_inlet (bool) – Elevate inlet to a variable within the Dataset, useful

  • data. (for ranked) –

Returns

ObsData object(s)

Return type

ObsData / List[ObsData]

retrieve_all(sort=True, elevate_inlet=False)[source]#

Retrieves all data found during the search

Returns

ObsData object(s)

Return type

ObsData / List[ObsData]

to_data()[source]#

Convert this object to a dictionary for JSON serialisation

Returns

Dictionary of data

Return type

dict

to_json()[source]#

Serialises the object to JSON

Returns

JSON str

Return type

str

ObsData#

This dataclass is returned by data retrieval functions such as get_obs_surface and the SearchResults retrieve function.

class openghg.dataobjects.ObsData(data, metadata)[source]#

This class is used to return observations data from the get_observations function

Parameters
  • data (Dataset) – Dictionary of xarray Dataframes

  • metadata (Dict) – Dictionary of metadata

__delattr__(name)#

Implement delattr(self, name).

__eq__(other)[source]#

Return self==value.

Return type

bool

__getitem__(key)[source]#

Returns the data attribute (xarray Dataset) when the site name is specified. Included as a compatability layer for legacy format as a dictionary containing a Dataset for each site code.

key (str): Site code

Return type

Any

__hash__()#

Return hash(self).

__init__(data, metadata)#
__iter__()[source]#

Returns site code as the key for the dictionary as would be expected.

Return type

Iterator

__len__()[source]#

Returns number of key values (fixed at 1 at present)

Return type

int

__repr__()#

Return repr(self).

__setattr__(name, value)#

Implement setattr(self, name, value).

plot_timeseries(title=None, xlabel=None, ylabel=None, units=None)[source]#

Plot a timeseries

Return type

Figure

to_data()[source]#

Creates a dictionary package of this ObsData’s metadata and data.

Returns

Dictionary of metadata and bytes

Return type

dict

FluxData#

This dataclass is used to return observations data from the get_flux function

class openghg.dataobjects.FluxData(data, metadata)[source]#

This class is used to return flux/emissions data from the get_flux function

Parameters
  • data (Dataset) – xarray Dataframe

  • metadata (Dict) – Dictionary of metadata including model run parameters

__delattr__(name)#

Implement delattr(self, name).

__eq__(other)#

Return self==value.

__hash__()#

Return hash(self).

__init__(data, metadata)#
__repr__()#

Return repr(self).

__setattr__(name, value)#

Implement setattr(self, name, value).

__str__()[source]#

Return str(self).

Return type

str

FootprintData#

This dataclass is used to return observations data from the get_footprint function

class openghg.dataobjects.FootprintData(data, metadata)[source]#

This class is used to return observations data from the get_footprint function

Parameters
  • data (Dataset) – xarray Dataset

  • metadata (Dict) – Dictionary of metadata including model run parameters

__delattr__(name)#

Implement delattr(self, name).

__eq__(other)#

Return self==value.

__hash__()#

Return hash(self).

__init__(data, metadata)#
__repr__()#

Return repr(self).

__setattr__(name, value)#

Implement setattr(self, name, value).

__str__()[source]#

Return str(self).

Return type

str