eradiate.srf_tools#

Spectral response function (SRF) filtering algorithms.

Trimming algorithms#

eradiate.srf_tools.trim(srf)[source]#

Trim all leading zeros except last and all trailing zeros except first.

Parameters

srf (path-like, Dataset) – Data set to trim.

Returns

Dataset – Trimmed data set.

eradiate.srf_tools.trim_and_save(srf, path, verbose=False, interactive=False, dry_run=False)[source]#

Wraps around trim() to save the filtered dataset.

Parameters
  • srf (path-like, Dataset) – Data set to trim.

  • verbose (bool) – If True, display a summary of the trimming operation.

  • path (path-like) – Path to which to save the filtered dataset.

  • interactive (bool) – If True, display a figure illustrating the filtered region and prompt for confirmation before proceeding to saving the dataset to the disk.

  • dry_run (bool) – If True, displays where the trimmed data set would be saved but does not save it.

See also

trim()

Filtering algorithms#

eradiate.srf_tools.integral_filter(srf, percentage=99.0)[source]#

Keep only data that contribute to the integrated spectral response value to the amount of the specified percentage.

The integrated spectral reponse is computed from the cumulative sum of the spectral response function interpolated on a regular grid with the smallest wavelength step of the initial data set.

Parameters
  • ds (Dataset) – Dataset to filter.

  • percentage (float) – Keep data that contribute to this percentage of the integrated spectral response.

Raises

ValueError

Returns

Dataset – Filtered data set.

eradiate.srf_tools.spectral_filter(srf, wmin=None, wmax=None)[source]#

Drop points falling out of wavelength range specified by wmin and wmax.

Parameters
  • srf (Dataset) – Spectral response function data set to filter.

  • wmin (quantity) – Minimum wavelength.

  • wmax (quantity) – Maximum wavelength.

Returns

Dataset – Filtered data set.

eradiate.srf_tools.threshold_filter(srf, value=0.001)[source]#

Drop data points where response is smaller or equal than a threshold value.

Parameters
  • srf (Dataset) – Spectral response function data set to filter.

  • value (float) – Spectral response threshold value.

Raises

ValueError

Returns

Dataset – Filtered data set.

eradiate.srf_tools.filter(srf, path, verbose=False, interactive=False, dry_run=False, trim_prior=True, threshold=None, wmin=None, wmax=None, percentage=None)[source]#

Filter a spectral response function data set.

Parameters
  • srf (path-like, Dataset) – Spectral response function data set to filter.

  • path (path-like) – Path to which to save the filtered data set.

  • verbose (bool) – If True, display afiltering summary table and the path to which filtered data set is saved.

  • interactive (bool) – If True, display a figure emphasizing the filtered region.

  • dry_run (bool) – If True, display the path to which the filtered data set would be saved, but does not write the data set to the disk.

  • trim_prior (bool) – Trim the data set prior to filtering.

  • threshold (float, optional) – Threshold value for the threshold filter. See threshold_filter(). If None, disable the threshold filter.

  • wmin (quantity, optional) – Lower wavelength bound for the spectral filter. See spectral_filter(). If both wmin and wmax are None, disable the spectral filter.

  • wmax (quantity, optional) – Upper wavelength bound for the spectral filter. See spectral_filter(). If both wmin and wmax are None, disable the spectral filter.

  • percentage (float, optional) – Percentage value for the integral filter. See integral_filter(). If None, disable the integral filter.

Notes

Select the filtering algorithms corresponding to the specified parameters.

If multiple filters are selected, they are applied in this order:

  • integral filter

  • spectral filter

  • threshold filter

Plotting#

eradiate.srf_tools.show(ds, title, trim_prior=True, threshold=None, wmin=None, wmax=None, percentage=None)[source]#

Show filtered region on spectral response function plot.

Parameters
  • ds (path-like, Dataset) – Spectral response function to be filtered.

  • title (str) – Figure title.

  • trim_prior (bool) – If True, trim spectral response function prior to filter.

  • threshold (float, optional) – Threshold value for the threshold filter.

  • wmin (quantity, optional) – Lower wavelength value for the spectral filter.

  • wmax (quantity, optional) – Upper wavelength value for the spectral filter.

  • percentage (float, optional) – Percentage value for the integral filter.

Raises

ValueError: – If the threshold value is not in [0, 1[.

Utilities#

eradiate.srf_tools.summarize(srf, filtered)[source]#

Produce a summary table of the spectral response function filtering operation.

Parameters
  • srf (Dataset) – Initial spectral response function data set.

  • filtered (Dataset) – Filtered spectral response function data set.

Returns

Table – Summary table.