epsproc.util.selectors module

epsproc.util.selectors.dataGroupSel(data, dInd)[source]
epsproc.util.selectors.matEleSelector(da, thres=None, inds=None, dims=None, sq=False, drop=True)[source]

Select & threshold raw matrix elements in an Xarray. Wraps Xarray.sel(), plus some additional options.

See Xarray docs for more: http://xarray.pydata.org/en/stable/user-guide/indexing.html

Parameters
  • da (Xarray) – Set of matrix elements to sub-select

  • thres (float, optional, default None) – Threshold value for abs(matElement), keep only elements > thres. This is element-wise.

  • inds (dict, optional, default None) – Dicitonary of additional selection criteria, in name:value format. These correspond to parameter dimensions in the Xarray structure. E.g. inds = {‘Type’:’L’,’Cont’:’A2’} Slices are also acceptable, e.g. inds = {‘Eke’:slice(1,5,4)}

  • dims (str or list of strs, dimensions to look for max & threshold, default None) – Set for dimension-wise thresholding. If set, this is used instead of element-wise thresholding. List of dimensions, which will be checked vs. threshold for max value, according to abs(dim.max) > threshold This allows for consistent selection of continuous parameters over a dimension, by a threshold.

  • sq (bool, optional, default False) – Squeeze output singleton dimensions.

  • drop (bool, optional, default True) – Passed to da.where() for thresholding, drop coord labels for values below threshold.

Returns

Xarray structure of selected matrix elements. Note that Nans are dropped if possible.

Return type

daOut

Example

>>> daOut = matEleSelector(da, inds = {'Type':'L','Cont':'A2'})

Notes

xr.sel(inds) is used here. For single values xr.sel({name:[value]}) or xr.sel({name:value}) is different! Automatically squeeze out dim in latter case. (Tested on xr v0.15)

E.g., for selecting a single Eke value: da.sel({‘Eke’:[1.1]}) # Keeps Eke dim da.sel({‘Eke’:1.1}) # Drops Eke to non-dimension coord. da.sel({‘Eke’:1.1}, drop=True) # Drops Eke completely da.sel({‘Eke’:[1.1]}, drop=True) # Keeps Eke da.sel({‘Eke’:[1.1]}, drop=True).squeeze() # Drops Eke to non-dim coord

epsproc.util.selectors.setXSfromCoords(data, verbose=True)[source]

Set (l,m)=(0,0) data to cross section.

Data taken from coords, either data.XS (MF case) or data.XSrescaled (AF case).

Returns copy.