eradiate.srf_tools
Contents
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.
- 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
verbose (
bool
) – IfTrue
, display a summary of the trimming operation.path (path-like) – Path to which to save the filtered dataset.
interactive (
bool
) – IfTrue
, display a figure illustrating the filtered region and prompt for confirmation before proceeding to saving the dataset to the disk.dry_run (
bool
) – IfTrue
, displays where the trimmed data set would be saved but does not save it.
See also
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
- Raises
- 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
andwmax
.
- eradiate.srf_tools.threshold_filter(srf, value=0.001)[source]#
Drop data points where response is smaller or equal than a threshold value.
- Parameters
- Raises
- 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
) – IfTrue
, display afiltering summary table and the path to which filtered data set is saved.interactive (
bool
) – IfTrue
, display a figure emphasizing the filtered region.dry_run (
bool
) – IfTrue
, 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. Seethreshold_filter()
. IfNone
, disable the threshold filter.wmin (
quantity
, optional) – Lower wavelength bound for the spectral filter. Seespectral_filter()
. If bothwmin
andwmax
areNone
, disable the spectral filter.wmax (
quantity
, optional) – Upper wavelength bound for the spectral filter. Seespectral_filter()
. If bothwmin
andwmax
areNone
, disable the spectral filter.percentage (
float
, optional) – Percentage value for the integral filter. Seeintegral_filter()
. IfNone
, 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
See also
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
) – IfTrue
, 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[.