xarray.Dataset.dts.ufunc_per_section

Dataset.dts.ufunc_per_section(sections=None, func=None, label=None, subtract_from_label=None, temp_err=False, x_indices=False, ref_temp_broadcasted=False, calc_per='stretch', suppress_section_validation=False, **func_kwargs)

Functions applied to parts of the cable.

Super useful,many options and slightlycomplicated.

The function func is taken over all the timesteps and calculated per calc_per. This is returned as a dictionary

Parameters:
  • sections (Dict[str, List[slice]], optional) – If None is supplied, ds.sections is used. Define calibration sections. Each section requires a reference temperature time series, such as the temperature measured by an external temperature sensor. They should already be part of the DataStore object. sections is defined with a dictionary with its keywords of the names of the reference temperature time series. Its values are lists of slice objects, where each slice object is a fiber stretch that has the reference temperature. Afterwards, sections is stored under ds.sections.

  • func (callable, str) – A numpy function, or lambda function to apple to each ‘calc_per’.

  • label

  • subtract_from_label

  • temp_err (bool) – The argument of the function is label minus the reference temperature.

  • x_indices (bool) – To retreive an integer array with the indices of the x-coordinates in the section/stretch. The indices are sorted.

  • ref_temp_broadcasted (bool)

  • calc_per ({‘all’, ‘section’, ‘stretch’})

  • func_kwargs (dict) – Dictionary with options that are passed to func

  • TODO (Spend time on creating a slice instead of appendng everything to a list and concatenating after.)

  • Returns

  • ——–

  • dict – A dictionary with the keys of the sections and the values are the result of the function applied to the data in the section.

  • Examples

  • ———

  • 1. Calculate the variance of the residuals in the along ALL the reference sections wrt the temperature of the water baths

  • >>> tmpf_var = d.ufunc_per_section(

  • >>> sections=sections,

  • >>> func=’var’,

  • >>> calc_per=’all’,

  • >>> label=’tmpf’,

  • >>> temp_err=True)

  • 2. Calculate the variance of the residuals in the along PER reference section wrt the temperature of the water baths

  • >>> tmpf_var = d.ufunc_per_section(

  • >>> sections=sections,

  • >>> func=’var’,

  • >>> calc_per=’stretch’,

  • >>> label=’tmpf’,

  • >>> temp_err=True)

  • 3. Calculate the variance of the residuals in the along PER water bath wrt the temperature of the water baths

  • >>> tmpf_var = d.ufunc_per_section(

  • >>> sections=sections,

  • >>> func=’var’,

  • >>> calc_per=’section’,

  • >>> label=’tmpf’,

  • >>> temp_err=True)

  • 4. Obtain the coordinates of the measurements per section

  • >>> locs = d.ufunc_per_section(

  • >>> sections=sections,

  • >>> func=None,

  • >>> label=’x’,

  • >>> temp_err=False,

  • >>> ref_temp_broadcasted=False,

  • >>> calc_per=’stretch’)

  • 5. Number of observations per stretch

  • >>> nlocs = d.ufunc_per_section(

  • >>> sections=sections,

  • >>> func=len,

  • >>> label=’x’,

  • >>> temp_err=False,

  • >>> ref_temp_broadcasted=False,

  • >>> calc_per=’stretch’)

  • 6. broadcast the temperature of the reference sections to stretch/section/all dimensions. The value of the reference temperature (a timeseries) is broadcasted to the shape of self[ label]. The self[label] is not used for anything else.

  • >>> temp_ref = d.ufunc_per_section(

  • >>> label=’st’,

  • >>> ref_temp_broadcasted=True,

  • >>> calc_per=’all’)

  • 7. x-coordinate index

  • >>> ix_loc = d.ufunc_per_section(sections=sections, x_indices=True)

  • Notes

  • ——

  • If `self[label]` or `self[subtract_from_label]` is a Dask array, a Dask

  • array is returned else a numpy array is returned