index_calculator.preprocessing

class index_calculator.preprocessing(ds=None, project='N/A', var_name=None, freq='year', ifreq='day', time_range=None, crop_time_axis=True, check_time_axis=True, **kwargs)

Class for pre-processing xarray datasets.

Parameters:
  • ds (xr.Dataset) – xarray Dataset.

  • project ({“CORDEX”, “CMIP5”, “CMIP6”, “EOBS”, “ERA5”, “N/A”}) – (default: “N/A), optional Project name

  • var_name (str or list, optional) – CF variable(s) contained in ds. If None (default) var_name is read from ds with pyhomogenize.

  • freq (str (default=”year”), optional) – Climate indicator output frequency

  • ifreq (str (default=”day”), optional) – Climate indicator input frequency

  • time_range (list, optional) – List of two strings representing the left and right time bounds. Select time slice with those limits from ds.

  • crop_time_axis (bool, optional) – If True (default) select time slice from ds. The left and the right bounds depends on freq. For example: If freq is year the left bound has to be January, 1st and the right bound has to be the last day of December.

  • check_time_axis (bool, optional) – If True (default) check the time axis on duplicated, redundant and/or missing time steps.

Example

Do some preprocessing with a netcdf file on disk:

from pyhomogenize import open_xrdataset
from index_calculator import preprocessing

netcdf_file = "tas_EUR-11_MPI-M-MPI-ESM-LR_historical_r3i1p1_"
              "GERICS-REMO2015_v1_day_20010101-20051231.nc"
ds = open_xrdataset(netcdf_file)

preproc = preprocessing(ds)

preproc_ds = preproc.preproc
__init__(ds=None, project='N/A', var_name=None, freq='year', ifreq='day', time_range=None, crop_time_axis=True, check_time_axis=True, **kwargs)

Methods

__init__([ds, project, var_name, freq, ...])