Data objects#
DataHandler#
This dataclass
is used to modify metadata stored in Datasource objects and the metadata store.
DataHandler
instances are created by the data_handler_lookup function.
- class openghg.dataobjects.DataHandler(metadata=None)[source]#
-
- delete_datasource(uuid)[source]#
Delete a Datasource in the object store. At the moment we only support deleting the complete Datasource.
NOTE: Make sure you really want to delete the Datasource(s)
- Parameters:
uuid (
Union
[List
,str
]) – UUID(s) of objects to delete- Return type:
None
- Returns:
None
- refresh()[source]#
Force refresh the internal metadata store with data from the object store.
- Return type:
None
- Returns:
None
- restore(uuid, version='latest')[source]#
Restore a backed-up version of a Datasource’s metadata.
- Parameters:
uuid (
str
) – UUID of Datasource to retrieveversion (
Union
[str
,int
]) – Version of metadata to restore
- Return type:
None
- Returns:
None
- update_metadata(uuid, to_update=None, to_delete=None)[source]#
Update the metadata associated with data. This takes UUIDs of Datasources and updates the associated metadata. If you want to delete some metadata
- Parameters:
uuid (
Union
[List
,str
]) – UUID(s) of Datasources to be updated.to_update (
Optional
[Dict
]) – Dictionary of metadata to add/update. New key/value pairs will be added.updated. (If the key already exists in the metadata the value will be) –
to_delete (
Union
[str
,List
,None
]) – Key(s) to delete from the metadata
- Return type:
None
- Returns:
None
SearchResults#
This dataclass
is returned by the OpenGHG search functions and allows easy retrieval and querying of metadata retrieved
by the search
function.
- class openghg.dataobjects.SearchResults(keys=None, metadata=None, start_result=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 UUIDmetadata (
Optional
[Dict
]) – Dictionary of metadata keyed by Datasource UUID
- classmethod from_json(data)[source]#
Create a SearchResults object from a dictionary
- Parameters:
data (
Union
[bytes
,str
]) – Serialised object- Returns:
SearchResults object
- Return type:
- retrieve(dataframe=None, sort=False, elevate_inlet=False, **kwargs)[source]#
Retrieve data from object store using a filtered pandas DataFrame
- Parameters:
dataframe (
Optional
[DataFrame
]) – pandas DataFramesort (
bool
) – Sort data by date in retrieved Datasetelevate_inlet (
bool
) – Elevate inlet to a variable within the Dataset, usefuldata. (for ranked) –
- Returns:
ObsData object(s)
- Return type:
ObsData / List[ObsData]
- retrieve_all(sort=False, elevate_inlet=False)[source]#
Retrieves all data found during the search
- Parameters:
sort (
bool
) – Sort by time. Note that this may be very memory hungry for large Datasets.elevate_inlet (
bool
) – Elevate inlet to a variable within the Dataset, usefuldata. (for ranked) –
- Returns:
ObsData object(s)
- Return type:
ObsData / List[ObsData]
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 Dataframesmetadata (
Dict
) – Dictionary of metadata
- __delattr__(name)#
Implement delattr(self, name).
- __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
- __repr__()#
Return repr(self).
- __setattr__(name, value)#
Implement setattr(self, name, value).
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 Dataframemetadata (
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).
ObsColumnData#
This dataclass
is used to return observations data from the get_obs_column function
- class openghg.dataobjects.ObsColumnData(data, metadata)[source]#
This class is used to return observations data from the get_obs_column function
- Parameters:
data (
Dataset
) – xarray Datasetmetadata (
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).
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 Datasetmetadata (
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).
BoundaryConditionsData#
This dataclass
is used to return observations data from the get_bc function
- class openghg.dataobjects.BoundaryConditionsData(data, metadata)[source]#
This class is used to return boundary conditions data from the get_bc function
- Parameters:
data (
Dataset
) – xarray Dataframemetadata (
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).