Further processing

For working with the ouput data of the plugin a special library offers the creation of so called data-containers. These data-containers allow for easy access of the data in the cloud. The plugin has also created a jupyter notebook that demonstrates the usage of such data-containers. It is very likely that the data hasn’t been processed sufficiently by the plugin, e.g unit conversion or calculating new variables is necessary. This step, which is highly individual, can be done with help of this jupyter notebook.

The notebook assumes that the data has already been processed by the freva plugin and was successfully stored in the cloud.

Creating a data container

Once the plugin output is saved to a cloud storage object the data-container holding the plugin output data can be created by applying the from_zipfile() method of the DataContainer() class

class climpact.datacontainer.DataContainer(*datasets: tuple[Dataset, ...])[source]

Class that holds information about processed data.

Attributes:
container

Overview of the content of this data container.

variables

Returns a list of all variables within the data container.

Methods

convert(variable, unit)

Convert all variables in the data container to a desired unit.

from_zipfile(*zipfile)

Create a DataContainer from a zipfile that contians the time series data.

replace(dset[, index, name])

Replace a dataset in a container

save([filetype, username, filename])

Save the dataset to a zip file and upload the zip file to swift cloud store.

select(*[, by_index, by_name])

Select a dataset from the container.

property container

Overview of the content of this data container.

convert(variable: str, unit: str) None[source]

Convert all variables in the data container to a desired unit.

dc = DataContainer.from_zipfile("output.zip")
dc.convert("tas", "degC")
Parameters:
variable:

the variable name that needs to be converted

unit:

the desired unit the variable is converted to

classmethod from_zipfile(*zipfile: str | Path)[source]

Create a DataContainer from a zipfile that contians the time series data.

dc1 = DataContainer.from_zipfile("output.zip")
dataset1 = dc1.select(by_index=0)
dc2 = DataContainer.from_zipfile("*")
dataset2 = dc2.select(by_index=0)
Parameters:
zipfile:

Path to the zip file that contains the saved data, glob pattern like ‘*’ or ‘*.zip’ are also excepted.

Returns:
Returns The DataContainer ojbect holding all nessecary information to post-process the time-series data
replace(dset: Dataset, index: int | None = None, name: str | None = None) None[source]

Replace a dataset in a container

Parameters:
dset:

The dataset that needs to be replaced

index:

The index of the dataset in the container that is replaced

name:

The name of the model member of the according dataset that is replaced

save(filetype: str = 'nc', username: str | None = None, filename: str | Path | None = None) None[source]

Save the dataset to a zip file and upload the zip file to swift cloud store.

Parameters:
filetype:

The file extension the data is saved to, should be one of [h5, hdf5, nc, csv]

username:

The username that is used to login to the swift cloud store, if None is given (default), the current system user will be taken.

filename:

The desired file name of the saved zip file, if None is given (default) an informative filename will be constructed from the metadata.

select(*, by_index: int | None = None, by_name: str | None = None) Dataset[source]

Select a dataset from the container.

dc = DataContainer.from_zipfile("output.zip")
dc.container
dataset1 = dc.select(by_index=0)
dataset2 = dc.select(by_name="foo_bar")
Parameters:
by_index:

select the dataset based on the index in the container.

by_name:

select the dataset based on the model name in the container.

Returns:
Returns xarray dataset
property variables: List[str]

Returns a list of all variables within the data container.