API reference

This page provides an auto-generated summary of the pyhomogenize API.

Useful functions for reading and writing large netCDF files

read_write.open_xrdataset(use_cftime=True, decode_cf=False, decode_times=False, parallel=False, data_vars='minimal', chunks={'time': 1}, coords='minimal', compat='override', combine='by_coords', **kwargs)

Optimized function for opening large cf datasets.

based on [open_xrdataset]. decode_timedelta=False is added to leave variables and coordinates with time units in {“days”, “hours”, “minutes”, “seconds”, “milliseconds”, “microseconds”} encoded as numbers.

Parameters
  • files (str or list) – See [open_mfdataset]

  • use_cftime (bool, optional) – See [decode_cf]

  • parallel (bool, optional) – See [open_mfdataset]

  • data_vars ({“minimal”, “different”, “all”} or list of str, optional) – See [open_mfdataset]

  • chunks (int or dict, optional) – See [open_mfdataset]

  • coords ({“minimal”, “different”, “all”} or list of str, optional) – See [open_mfdataset]

  • compat (str (see coords), optional) – See [open_mfdataset]

Returns

xarray.Dataset

References

open_xrdataset

https://github.com/pydata/xarray/issues/1385#issuecomment-561920115

open_mfdataset(1,2)

https://docs.xarray.dev/en/stable/generated/xarray.open_mfdataset.html

decode_cf

https://docs.xarray.dev/en/stable/generated/xarray.decode_cf.html

read_write.get_var_name()

List of CF variables in xr.Dataset

Parameters

ds (xr.Dataset) – xarray Dataset

Returns

list – List of CF variables

read_write.save_xrdataset(name=None, encoding_dict={}, format='NETCDF4', unlimited_dims={'time': True}, compute=True)

Save dataset as netCDF file.

Parameters
  • ds (xr.Dataset) – Dataset to save on disk.

  • name (str, optional) – name of the netcdf output file

  • encoding_dict (dict or None, optional) – Encoding dictionary for get_encoding. If dict call get_encoding with dict values as parameters. If empty call get_encoding with default values. If None encoding = {}.

  • format (str, optional) – File format for the resulting netCDF file

  • unlimited_dims (dict) – Dimension(s) that should be serialized as unlimited dimensions. Skip if key not in ds coordinates.

  • compute (bool, optional) – If true compute immediately, otherwise return a dask.delayed.Delayed object that can be computed later.

Returns

  • * bytes if name is None

  • * dask.delayed.Delayed if compute is False

  • * xr.Dataset otherwise

Pyhomogenize time creating and manipulating classes

Methods for creating, reading and manipulating CF time axes

pyhomogenize’s attributes