Writers#

Module that handle some attributes generation.

Also handle saving of file.

class ccres_weather_station.writers.write.ConfigWriter(config: ccres_weather_station.config.config.Config)[source]#

Bases: object

add_config_meta(ds: xarray.core.dataset.Dataset) xarray.core.dataset.Dataset[source]#

Add the metadata to the xarray dataset.

Add : - Variables metadata - Coordinates metadata - Global attributes

Parameters

ds (xr.Dataset) – xarray dataset

Returns

The dataset with metadata added

Return type

xr.Dataset

get_encoding(ds: xarray.core.dataset.Dataset) Dict[str, Dict[str, str]][source]#

Parse the config file to extract the encoding for netcdf.

Parse both coordinates and variables

Parameters

ds (xr.Dataset) – xarray dataset

Returns

Dictionnary of encoding terms

Return type

Dict[str, Dict[str, str]]

ccres_weather_station.writers.write.add_created_date(ds: xarray.core.dataset.Dataset) xarray.core.dataset.Dataset[source]#

Add created_date field into the dataset.

Add the datetime.now() string representation

ccres_weather_station.writers.write.add_date_metadata_modified(ds: xarray.core.dataset.Dataset) xarray.core.dataset.Dataset[source]#

Add metadata_modified field into the dataset.

Add the datetime.now() string representation

ccres_weather_station.writers.write.add_history(ds: xarray.core.dataset.Dataset) xarray.core.dataset.Dataset[source]#
ccres_weather_station.writers.write.add_time_coverage_attributes(ds: xarray.core.dataset.Dataset, dim_time: str) xarray.core.dataset.Dataset[source]#
ccres_weather_station.writers.write.write_nc(ds: xarray.core.dataset.Dataset, config: ccres_weather_station.config.config.Config, output_path: Union[str, pathlib.Path]) None[source]#