spectrochempy.PeakTable#

class PeakTable(peaks, properties=None, rows=None, *, sample_index=None, sample_position=None, sample_height=None, columns=None, history_entries=None, history=None)[source]#

Dependency-light tabular view of detected peaks.

Parameters:
  • peaks (NDDataset, PeakTable or None) – Dataset containing identified peaks for 1D results, or a table-backed representation for 2D results.

  • properties (dict or None) – Peak properties returned by scipy.signal.find_peaks.

  • columns (sequence of str, optional) – Explicit stable column schema for row-backed multidimensional results.

  • history_entries (list of dict, optional) – Detached structured history entries for row-backed results.

Notes

PeakTable uses user-facing singular column names such as peak_height, prominence and width. The raw SciPy property dictionary remains available on PeakFindingResult.

Text and HTML displays show at most ten peaks, with compatible units in column headers and six significant digits. Stored values and exports retain their original precision. Use top or head to select an explicit subset for display.

Attributes Summary

peaks

properties

sample_index

sample_position

sample_height

columns

Return stable base columns plus currently available optional columns.

history

Return the read-only rendered history for the result table.

history_entries

Return detached structured history entries for the result table.

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 PeakTable sorted 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#
sample_index#
sample_position#
sample_height#
columns#

Return stable base columns plus currently available optional columns.

history#

Return the read-only rendered history for the result table.

history_entries#

Return detached structured history entries for the result table.

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 PeakTable sorted 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, height, available discrete sample fields and 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