spectrochempy.PeakTable
- class PeakTable(peaks, properties=None, rows=None)[source]
Dependency-light tabular view of detected peaks.
- Parameters:
peaks (NDDataset or None) – Dataset containing identified peak positions and heights.
properties (dict or None) – Peak properties returned by
scipy.signal.find_peaks.
Notes
PeakTableuses user-facing singular column names such aspeak_height,prominenceandwidth. The raw SciPy property dictionary remains available onPeakFindingResult.Attributes Summary
Return stable base columns plus currently available optional columns.
Methods Summary
column(name, *[, unit, as_float])Return a column as a list of values.
head(n)Return the first n rows as a new
PeakTable.sort_by(name, *[, reverse, unit])Return a new
PeakTablesorted by the given column.to_csv(path, *[, delimiter])Write peak information to a CSV file.
to_dict()Return peak information as a list of dictionaries.
top(n, *, by[, reverse, unit])Return the top n rows according to a given column.
Attributes Documentation
- peaks
- properties
- columns
Return stable base columns plus currently available optional columns.
Methods Documentation
- column(name, *, unit=None, as_float=False)[source]
Return a column as a list of values.
- Parameters:
name (str) – Column name.
unit (str or Quantity, optional) – Target unit for unit-aware values.
as_float (bool, default=False) – If True, return plain floats.
- head(n)[source]
Return the first n rows as a new
PeakTable.- Parameters:
n (int) – Number of rows to keep.
- sort_by(name, *, reverse=False, unit=None)[source]
Return a new
PeakTablesorted by the given column.- Parameters:
name (str) – Column name used as sorting key.
reverse (bool, default=False) – If True, sort in descending order.
unit (str or Quantity, optional) – Target unit for unit-aware values before comparison.
- to_csv(path, *, delimiter=',')[source]
Write peak information to a CSV file.
- Parameters:
path (str or pathlib.Path) – Destination path.
delimiter (str, default=’,’) – CSV delimiter.
- Returns:
pathlib.Path – The written path.
- to_dict()[source]
Return peak information as a list of dictionaries.
Each dictionary contains
index,position,heightand any available per-peak properties. Values keep their native units when they are unit-bearing quantities.
- top(n, *, by, reverse=True, unit=None)[source]
Return the top n rows according to a given column.
- Parameters:
n (int) – Number of rows to keep.
by (str) – Column name used as ranking key.
reverse (bool, default=True) – If True, keep the largest values first.
unit (str or Quantity, optional) – Target unit for unit-aware values before comparison.
Examples using spectrochempy.PeakTable