rainbow.datafile.DataFile

class DataFile(path, detector, xlabels, ylabels, data, metadata)[source]

Bases: object

Class representing a chromatogram data file.

Parameters:
  • path (str) – Path of the file.

  • detector (str) – Detector for the file.

  • xlabels (numpy.ndarray) – 1D array with retention times (in minutes).

  • ylabels (numpy.ndarray) – 1D array with y-axis labels (e.g. mz, wavelength).

  • data (numpy.ndarray) – 2D array with data values (e.g. intensity).

  • metadata (dict) – Metadata for the file.

Attributes:
  • name (str) – Name of the file.

  • detector (str) – Name of the detector. Options: UV, MS, FID, CAD, ELSD.

  • xlabels (numpy.ndarray) – 1D array with retention times (in minutes).

  • ylabels (numpy.ndarray) – 1D array with y-axis labels (e.g. mz, wavelength).

  • data (numpy.ndarray) – 2D array with data values (e.g. intensity). The rows correspond to the retention times and the columns correspond to the y-axis labels.

  • metadata (dict) – Depends on the vendor and file format.

get_info()[source]

Returns a string summary of the DataFile.

extract_traces(labels=None)[source]

Extracts data corresponding to the specified labels.

Raises an exception if any labels are invalid.

Parameters:

labels (int/float/list, optional) – Ylabel(s) to extract.

Returns:

2D numpy array containing data for the specified ylabel(s). The rows correspond to the ylabels and the columns corrrespond to the retention times.

export_csv(filename, labels=None, delim=',')[source]

Outputs a CSV containing data for the specified labels.

Parameters:
  • filename (str) – Filename for the output CSV.

  • labels (int/float/list, optional) – Ylabel(s) to export.

  • delim (str, optional) – Delimiter used in the output CSV.

to_csvstr(labels=None, delim=',')[source]

Returns a string representation of a CSV containing data for the specified labels.

Parameters:
  • labels (int/float/list, optional) – Ylabel(s) to return.

  • delim (str, optional) – Delimiter used in the CSV representation.

plot(label, **kwargs)[source]

Shows a basic matplotlib plot for the specified label.

Parameters:
  • label (int/float) – Ylabel to be plotted.

  • **kwargs (optional) – Keyword arguments for matplotlib.