Mass Spectrometry

Source: https://github.com/ixdat/ixdat/tree/user_ready/src/ixdat/techniques/ms

Mass spectrometry is commonly used in catalysis and electrocatalysis for two different types of data - spectra, where intensity is taken while scanning over m/z, and mass intensity detection (MID) where the intensity of a small set of m/z values are tracked in time.

The main TechniqueMeasurement class for MID data is the MSMeasurement.

Classes dealing with spectra are under development.

The ms module

Module for representation and analysis of MS measurements

class ixdat.techniques.ms.MSCalResult(name=None, mol=None, mass=None, cal_type=None, F=None)[source]

A class for a mass spec calibration result.

TODO: How can we generalize calibration? I think that something inheriting directly
from saveable belongs in a top-level module and not in a technique module
class ixdat.techniques.ms.MSInlet(*, l_cap=0.001, w_cap=6e-06, h_cap=6e-06, gas='He', T=298.15, p=100000.0, verbose=True)[source]

A class for describing the inlet to the mass spec

Every MSInlet describes the rate and composition of the gas entering a mass spectrometer. The default is a Spectro Inlets EC-MS chip.

calc_l_cap_eff(n_dot_measured, gas=None, w_cap=None, h_cap=None, T=None, p=None)[source]
Calculate gas specific effective length of the capillary in [m]
and add {gas:value} to l_cap_eff (dict)
Parameters:
  • w_cap (float) – capillary width [m], defaults to self.w_cap
  • h_cap (float) – capillary height [m], defaults to self.h_cap
  • n_dot (float) – direct measure of flux through capillary with gas, defaults to calculated flux
  • gas (dict or str) – the gas in the chip, defaults to self.gas
  • T (float) – Temperature [K], if to be updated
  • p (float) – pressure [Pa], if to be updated
Returns:

gas specific effective length in [m]

Return type:

float

calc_n_dot_0(gas=None, w_cap=None, h_cap=None, l_cap=None, T=None, p=None)[source]

Calculate the total molecular flux through the capillary in [s^-1]

Uses Equation 4.10 of Daniel’s Thesis.

Parameters:
  • w_cap (float) – capillary width [m], defaults to self.w_cap
  • h_cap (float) – capillary height [m], defaults to self.h_cap
  • l_cap (float) – capillary length [m], defaults to self.l_cap
  • gas (dict or str) – the gas in the chip, defaults to self.gas
  • T (float) – Temperature [K], if to be updated
  • p (float) – pressure [Pa], if to be updated
Returns:

the total molecular flux in [s^-1] through the capillary

Return type:

float

gas_flux_calibration(measurement, mol, mass, tspan=None, tspan_bg=None, ax=None, carrier_mol=None, mol_conc_ppm=None)[source]
Parameters:
  • measurement (MSMeasurement) – The measurement with the calibration data
  • mol (str) – The name of the molecule to calibrate
  • mass (str) – The mass to calibrate at
  • tspan (iter) – The timespan to average the signal over. Defaults to all
  • tspan_bg (iter) – Optional timespan at which the signal is at its background.
  • ax (matplotlib axis) – the axis on which to indicate what signal is used with a thicker line. Defaults to none
  • carrier_mol (str) – The name of the molecule of the carrier gas if a dilute analyte is used. Calibration assumes total flux of the capillary is the same as the flux of pure carrier gas. Defaults to None.
  • mol_conc_ppm (float) – concentration of the dilute analyte in the carrier gas in ppm. Defaults to None.
Returns MSCalResult: a calibration result containing the sensitivity factor for
mol at mass
update_l_cap(gases=[])[source]

Update self.l_cap from average of values in dict l_cap_eff

Parameters:gases (list) – list of gases to average l_cap, default all
Returns:averaged effective capilllary length in [m]
Return type:float
class ixdat.techniques.ms.MSMeasurement(name, mass_aliases=None, signal_bgs=None, tspan_bg=None, calibration=None, **kwargs)[source]

Class implementing raw MS functionality

get_flux_series(mol, tspan=None)[source]

Return a ValueSeries with the calibrated flux of mol during tspan

grab_cal_signal(signal_name, tspan=None, tspan_bg=None)[source]

Returns a calibrated signal for a given signal name. Only works if calibration dict is not None.

Parameters:
  • signal_name (str) – Name of the signal.
  • tspan (list) – Timespan for which the signal is returned.
  • tspan_bg (list) – Timespan that corresponds to the background signal. If not given, no background is subtracted.
grab_flux(mol, tspan=None, tspan_bg=None, removebackground=True, include_endpoints=False)[source]

Return the flux of mol (calibrated signal) in [mol/s]

Parameters:
  • mol (str or MSCalResult) – Name of the molecule or a calibration thereof
  • tspan (list) – Timespan for which the signal is returned.
  • tspan_bg (list) – Timespan that corresponds to the background signal. If not given, no background is subtracted.
  • removebackground (bool) – Whether to remove a pre-set background if available Defaults to True.
grab_flux_for_t(mol, t, tspan_bg=None, removebackground=False, include_endpoints=False)[source]

Return the flux of mol (calibrated signal) in [mol/s] for a given time vec

Parameters:
  • mol (str) – Name of the molecule.
  • t (np.array) – The time vector along which to give the flux
  • tspan_bg (tspan) – Timespan that corresponds to the background signal. If not given, no background is subtracted.
  • removebackground (bool) – Whether to remove a pre-set background if available
grab_signal(signal_name, tspan=None, tspan_bg=None, removebackground=False, include_endpoints=False)[source]

Returns t, S where S is raw signal in [A] for a given signal name (ie mass)

Parameters:
  • signal_name (str) – Name of the signal.
  • tspan (list) – Timespan for which the signal is returned.
  • tspan_bg (list) – Timespan that corresponds to the background signal. If not given, no background is subtracted.
  • removebackground (bool) – Whether to remove a pre-set background if available Defaults to False. (Note in grab_flux it defaults to True.)
  • include_endpoints (bool) – Whether to ensure tspan[0] and tspan[-1] are in t
integrate_signal(mass, tspan, tspan_bg, ax=None)[source]

Integrate a ms signal with background subtraction and evt. plotting

TODO: Should this, like grab_signal does now, have the option of using a
background saved in the object rather than calculating a new one?
Parameters:
  • mass (str) – The mass for which to integrate the signal
  • tspan (tspan) – The timespan over which to integrate
  • tspan_bg (tspan) – Timespan at which the signal is at its background value
  • ax (Axis) – axis to plot on. Defaults to None
mass_list

List of the masses for which ValueSeries are contained in the measurement

plotter

The default plotter for MSMeasurement is MSPlotter

reset_bg(mass_list=None)[source]

Reset background values for the masses in mass_list

set_bg(tspan_bg=None, mass_list=None)[source]

Set background values for mass_list to the average signal during tspan_bg.

class ixdat.techniques.ms.MSSpectrum(name, technique='spectrum', metadata=None, sample_name=None, reader=None, tstamp=None, field=None, field_id=None)[source]

Nothing to add to normal spectrum yet. TODO: Methods for co-plotting ref spectra from a database