pyku.magic#

Pyku magic module

This modules redefines default parameters to fit the most common use when working with climate data.

pyku.magic.open_mfdataset(files, option='auto')[source]#

The xarray.open_mfdataset with default options for climate data

Parameters:
  • files (List[str]) – The files to be open

  • option (str) – standardized optional parameters. Defaults to ‘auto’

Returns

:classe:xarray.Dataset: Dataset

pyku.magic.sorcery(ds)[source]#

Evil-magically makes datasets good. The evil_magic function attempts to auto-magically:

  • process datetimes reference to the lower bound of the time boundaries

  • process variable names towards CMOR standard

  • process units to SI units

  • sort geographical and projection coordinates from top to bottom and left to right

Parameters:

ds (xarray.Dataset) – The input dataset.

Returns:

Magicked dataset

Return type:

xarray.Dataset

pyku.magic.to_netcdf(ds, output_file, encoding='auto', complevel=None)[source]#

Write netcdf with climate data custom encoding

Parameters:
  • ds (xarray.Dataset) – The input dataset.

  • output_file (str) – Output file.

  • encoding – Optional, defaults to auto. one of {'auto', 'cmor'}. If set to 'cmor', the time encoding 'units' key is set to 'units': 'days since 1949-12-01T00:00:00Z' in conformance with the CMOR standar. If set to auto, a pyku-default uncompressed encoding is used. http://is-enes-data.github.io/cordex_archive_specifications.pdf

pyku.magic.to_zarr(ds, output_file, encoding='auto')[source]#

Write netcdf with climate data custom encoding

Parameters: