Mobilogram#

class pyopenms.Mobilogram(*args, **kwargs)#

Bases: Mobilogram

Mobilogram with DataFrame export capabilities.

This class extends Mobilogram with a get_df() method that converts mobilogram data to a pandas DataFrame.

__init__(*args, **kwargs)#

Overload:

__init__(self) None

Overload:

__init__(self, in_0: Mobilogram) None

Methods

__init__(*args, **kwargs)

calculateTIC(self)

Compute the total ion count (sum of all peak intensities)

clear(self)

Clears all data and ranges

clearRanges(self)

Resets all range dimensions as empty

findNearest(self, in_0)

Binary search for the peak nearest to a specific mobility :note: Make sure the mobilogram is sorted with respect to mobility! Otherwise the result is undefined

getDriftTimeUnit(self)

Returns the ion mobility drift time unit

getDriftTimeUnitAsString(self)

Returns the ion mobility drift time unit as string

getFloatDataArrays(self)

Returns a reference to the float meta data arrays

getIntegerDataArrays(self)

Returns a reference to the integer meta data arrays

getMaxIntensity(self)

Returns the maximum intensity

getMaxMobility(self)

Returns the maximum mobility

getMinIntensity(self)

Returns the minimum intensity

getMinMobility(self)

Returns the minimum mobility

getRT(self)

Returns the retention time (in seconds)

getStringDataArrays(self)

Returns a reference to the string meta data arrays

get_data_dict

Returns a dictionary of NumPy arrays with mobility, intensities, and metadata.

get_df([columns])

Returns a pandas DataFrame representation of the Mobilogram.

get_df_columns

Returns a list of column names that get_df() would produce for this mobilogram.

get_peaks

isSorted(self)

Checks if all peaks are sorted with respect to ascending mobility

push_back(self, in_0)

Append a peak

reserve(self, n)

resize(self, n)

Resize the peak array

setDriftTimeUnit(self, dt)

Sets the ion mobility drift time unit

setFloatDataArrays(self, fda)

Sets the float meta data arrays

setIntegerDataArrays(self, ida)

Sets the integer meta data arrays

setRT(self, in_0)

Sets the retention time (in seconds)

setStringDataArrays(self, sda)

Sets the string meta data arrays

set_peaks

size(self)

Returns the number of peaks in the mobilogram

sortByIntensity(self, reverse)

Lexicographically sorts the peaks by their intensity

sortByPosition(self)

Lexicographically sorts the peaks by their position (mobility)

updateRanges(self)

calculateTIC(self) float#

Compute the total ion count (sum of all peak intensities)

clear(self) None#

Clears all data and ranges

Will delete (clear) all peaks contained in the mobilogram

clearRanges(self) None#

Resets all range dimensions as empty

findNearest(self, in_0: float) int#

Binary search for the peak nearest to a specific mobility :note: Make sure the mobilogram is sorted with respect to mobility! Otherwise the result is undefined

Parameters:

mb – The searched for mobility value

Returns:

Returns the index of the peak.

Raises:

Exception: Precondition is thrown if the mobilogram is empty (not only in debug mode)

getDriftTimeUnit(self) int#

Returns the ion mobility drift time unit

getDriftTimeUnitAsString(self) bytes | str | String#

Returns the ion mobility drift time unit as string

getFloatDataArrays(self) List[FloatDataArray]#

Returns a reference to the float meta data arrays

getIntegerDataArrays(self) List[IntegerDataArray]#

Returns a reference to the integer meta data arrays

getMaxIntensity(self) float#

Returns the maximum intensity

getMaxMobility(self) float#

Returns the maximum mobility

getMinIntensity(self) float#

Returns the minimum intensity

getMinMobility(self) float#

Returns the minimum mobility

getRT(self) float#

Returns the retention time (in seconds)

getStringDataArrays(self) List[StringDataArray]#

Returns a reference to the string meta data arrays

get_data_dict()#

Returns a dictionary of NumPy arrays with mobility, intensities, and metadata.

This method extracts mobilogram data including peaks into a dictionary format suitable for conversion to a pandas DataFrame.

Args:
columns (list or None): List of column names to include. If None, includes

all default columns. Use get_df_columns() to see all available columns.

Returns:
dict: Dictionary with requested columns as keys and numpy arrays as values.
  • ‘mobility’: numpy array of mobility values (float64)

  • ‘intensity’: numpy array of intensity values (float32)

  • ‘rt’: retention time (float64)

  • ‘drift_time_unit’: drift time unit string

Example:
>>> data = mobilogram.get_data_dict()
>>> data = mobilogram.get_data_dict(columns=['mobility', 'intensity'])
get_df(columns: None | List[str] = None) DataFrame#

Returns a pandas DataFrame representation of the Mobilogram.

This method converts the mobilogram data (peaks, metadata) into a pandas DataFrame format.

Note: Mobilogram does not support meta values (no MetaInfoInterface).

Args:
columns (list or None): List of column names to include. If None,

includes all default columns. Use get_df_columns() to discover available columns.

Returns:
pd.DataFrame: DataFrame with requested columns. Default columns include:
  • mobility: mobility values of peaks

  • intensity: intensity values of peaks

  • rt: retention time (replicated for each peak)

  • drift_time_unit: drift time unit string

Example:
>>> # Get all default columns
>>> df = mobilogram.get_df()
>>> # Discover available columns
>>> print(mobilogram.get_df_columns())
>>> # Get only specific columns (faster)
>>> df = mobilogram.get_df(columns=['mobility', 'intensity'])
get_df_columns()#

Returns a list of column names that get_df() would produce for this mobilogram.

Useful for discovering available columns before export.

Args:
columns (str): ‘default’ for standard columns, ‘all’ for all available

columns including non-default ones.

Returns:

list: List of column name strings.

Example:
>>> cols = mobilogram.get_df_columns()
['mobility', 'intensity', 'rt', 'drift_time_unit']
get_peaks()#
isSorted(self) bool#

Checks if all peaks are sorted with respect to ascending mobility

push_back(self, in_0: MobilityPeak1D) None#

Append a peak

reserve(self, n: int) None#
resize(self, n: int) None#

Resize the peak array

setDriftTimeUnit(self, dt: int) None#

Sets the ion mobility drift time unit

setFloatDataArrays(self, fda: List[FloatDataArray]) None#

Sets the float meta data arrays

setIntegerDataArrays(self, ida: List[IntegerDataArray]) None#

Sets the integer meta data arrays

setRT(self, in_0: float) None#

Sets the retention time (in seconds)

setStringDataArrays(self, sda: List[StringDataArray]) None#

Sets the string meta data arrays

set_peaks()#
size(self) int#

Returns the number of peaks in the mobilogram

sortByIntensity(self, reverse: bool) None#

Lexicographically sorts the peaks by their intensity

Sorts the peaks according to ascending intensity. Meta data arrays will be sorted accordingly

sortByPosition(self) None#

Lexicographically sorts the peaks by their position (mobility)

The mobilogram is sorted with respect to position (mobility). Meta data arrays will be sorted accordingly

updateRanges(self) None#