objects
ChannelChromatograms
dataclass
¶
ChannelChromatograms(
channel: str,
chromatograms: dict[int, Chromatogram] = dict(),
integrals: DataFrame | None = None,
)
Contains data of a single channel with multiple chromatograms
Parameters:
-
channel(str) –Name of the channel (e.g., 'FID', 'TCD')
-
chromatograms(dict[int, Chromatogram], default:dict()) –Dictionary mapping chromatogram number to Chromatogram objects
-
integrals(DataFrame | None, default:None) –DataFrame containing integrated peak areas for each chromatogram (optional)
Methods:
-
add_chromatogram–Add a chromatogram to the channel
-
plot–Plot all chromatograms in the channel
-
integrate_peaks–Integrate peaks for all chromatograms in the channel, requieres dict of peak limits
chromatograms
class-attribute
instance-attribute
¶
chromatograms: dict[int, Chromatogram] = field(
default_factory=dict
)
add_chromatogram ¶
add_chromatogram(
injection_num: int, chromatogram: Chromatogram
)
apply_baseline ¶
Apply baseline correction to all chromatograms in the channel
Parameters:
-
correction_func–Function that takes a pandas DataFrame and returns corrected Series
-
inplace(bool, default:False) –If True, modify the original data. If False, add new column
-
suffix(str, default:'_BLcorr') –Suffix to add to the new column name when inplace=False
-
**kwargs–Additional arguments to pass to the correction function
Returns:
-
None–Modifies chromatograms in place
Source code in src/chromstream/objects.py
integrate_peaks ¶
Integrate peaks for all chromatograms in the channel
Parameters:
-
peaklist(dict) –Dictionary defining the peaks to integrate. Example:
-
Peaks_TCD = {"N2"–[20, 26], "H2": [16, 19]}
-
column(None | str, default:None) –Optional column name to use for integration. If None, uses second column.
Returns:
-
DataFrame–DataFrame with integrated peak areas for each injection
Source code in src/chromstream/objects.py
plot ¶
Plotting all chromatograms of a channel channel
Source code in src/chromstream/objects.py
Chromatogram
dataclass
¶
Chromatogram(
data: DataFrame,
injection_time: Timestamp,
metadata: dict,
channel: str,
path: Path | str | None,
)
Single chromatogram data for one injection on one channel
apply_baseline ¶
Apply baseline correction to the chromatogram data
Parameters:
-
correction_func–Function that takes a pandas DataFrame and returns corrected Series
-
inplace(bool, default:False) –If True, modify the original data. If False, add new column
-
suffix(str, default:'_BLcorr') –Suffix to add to the new column name when inplace=False
Returns:
-
–
pd.DataFrame: The corrected data (same as self.data if inplace=True)
Source code in src/chromstream/objects.py
integrate_peaks ¶
Integrate peaks for this chromatogram
Parameters:
-
peaklist(dict) –Dictionary defining the peaks to integrate. Example:
-
Peaks_TCD = {"N2"–[20, 26], "H2": [16, 19]}
-
column(None | str, default:None) –Optional column name to use for integration. If None, uses second column.
Returns:
-
dict–Dictionary with integrated peak areas and timestamp
Source code in src/chromstream/objects.py
plot ¶
Plot the chromatogram data
Source code in src/chromstream/objects.py
Experiment
dataclass
¶
Experiment(
name: str,
channels: dict[str, ChannelChromatograms] = dict(),
experiment_starttime: Timestamp | None = None,
experiment_endtime: Timestamp | None = None,
log: DataFrame | None = None,
)
Data for a single experiment containing multiple on-line GC channels
channels
class-attribute
instance-attribute
¶
channels: dict[str, ChannelChromatograms] = field(
default_factory=dict
)
experiment_starttime
class-attribute
instance-attribute
¶
add_channel ¶
add_channel(
channel_name: str, channel_data: ChannelChromatograms
)
add_chromatogram ¶
add_chromatogram(
chromatogram: Path | str | Chromatogram,
channel_name: str | None = None,
)
Add a chromatogram to the experiment, automatically creating the channel if it does not exist
Parameters:
-
chromatogram(Path | str | Chromatogram) –Path to the chromatogram file or a Chromatogram object
-
channel_name(Optional[str], default:None) –Optional channel name to override
Source code in src/chromstream/objects.py
add_log ¶
Adds a log dataframe to the experiment, either from a dataframe or from a path to the log file.
Parameters:
Source code in src/chromstream/objects.py
add_mult_chromatograms ¶
add_mult_chromatograms(
chromatograms: list[Path | str | Chromatogram]
| Path
| str,
channel_name: str | None = None,
)
Add multiple chromatograms to the experiment
Parameters:
-
chromatograms(list[Path | str | Chromatogram] | Path | str) –Either: - A list of Chromatogram objects - A list of paths to chromatogram files - A path to a .d directory containing .ch files - A path to a .dx archive containing .ch files
-
channel_name(str | None, default:None) –Optional channel name to override for all chromatograms
Source code in src/chromstream/objects.py
plot_chromatograms ¶
Source code in src/chromstream/objects.py
plot_log ¶
Plots specified colums of the experiment log. If use_exp_time is True, the x-axis will be the time since the start of the experiment in minutes. Args: columns (str | list): Column name or list of column names to plot ax (matplotlib.axes.Axes, optional): Axes to plot on. If None, a new figure and axes will be created. use_exp_time (bool, optional): Whether to use time since start of experiment as x-axis. Defaults to False.