spcal.datafile¶
File import and data access.
- class spcal.datafile.SPCalDataFile(format: str, path: Path, times: ndarray)¶
A base class for data files.
- exclusion_regions¶
array of start, end times to exclude from processing. These regions are set to NaN, shape (…, 2)
- dataForExpression(expr: SPCalIsotopeExpression) ndarray¶
Calculate the result for expr.
- dataForIsotope(isotope: SPCalIsotope) ndarray¶
Access signals for isotope.
- property event_time: float¶
The time of a single acuqisition. Sometimes called the ‘dwell time’.
- isTOF() bool¶
Returns True is file is ‘suspected’ of being from a ToF.
- property isotopes: list[SPCalIsotope]¶
The number of isotopes. This may be differetn from the number of masses due to isobars.
- property masses: ndarray¶
Masses (m/z) in the data file.
- property num_events: int¶
The number of events (e.g. acquisitions).
- property preferred_isotopes: list[SPCalIsotope]¶
Returns the default isotope for each element.
- property selected_isotopes: list[SPCalIsotope]¶
Currently selected isotopes.
- property signals: ndarray¶
Signal intensities in the data file. Has the shape (num_events, masses).
- spectra(regions: ndarray) ndarray¶
Access the entire mass spectra between regions.
- Parameters:
regions – array start, end points of shape (N, 2)
- Returns:
array of spectra shape (N, masses)
- property total_time: float¶
The total time in seconds, excluding NaN regions.
- class spcal.datafile.SPCalNuDataFile(path: Path, signals: ndarray, times: ndarray, masses: ndarray, info: dict, cycle_number: int | None, segment_number: int | None, integ_files: tuple[int, int | None], autoblanking: str = 'regions', max_mass_diff: float = 0.05)¶
Data file for data from a Nu Instruments Vitesse.
Create using the SPCalNuDataFile.load function.
- isotope_table¶
dict of isotopes to their index in signals
- dataForIsotope(isotope: SPCalIsotope) ndarray¶
Access signals for isotope.
- property event_time: float¶
The time of a single acuqisition. Sometimes called the ‘dwell time’.
- generateIsotopeTable()¶
Populates isotope_table with all available isotopes.
Multiple isotopes may map to the same index in signals if they are isobars.
- property isotopes: list[SPCalIsotope]¶
The number of isotopes. This may be differetn from the number of masses due to isobars.
- classmethod load(path: Path | str, max_mass_diff: float = 0.05, cycle_number: int | None = None, segment_number: int | None = None, first_integ_file: int = 0, last_integ_file: int | None = None, autoblank: str = 'regions') SPCalNuDataFile¶
Import Nu Instruments Vitesse data.
- Parameters:
path – Path to the ‘run.info’ file or the containing directory.
max_mass_diff – maximum difference (in Da) used for match m/z value to isotopes
cycle_number – limit import to a cycle, default to all
segment_number – limit import to a segment, default to all
first_integ_file – import .integ files starting from this number
last_integ_file – import .integ files ending at this number, None for all
autoblank – apply autoblanking to overrange regions or to all masses, one of ‘off’, ‘regions’, ‘all’
- property masses: ndarray¶
Masses (m/z) in the data file.
- property num_events: int¶
The number of events (e.g. acquisitions).
- property signals: ndarray¶
Signal intensities in the data file. Has the shape (num_events, masses).
- class spcal.datafile.SPCalTOFWERKDataFile(path: Path, signals: ndarray, times: ndarray, peak_table: ndarray, attrs: dict[str, str] | None = None)¶
Data file for TOFWERK style data.
Create using the SPCalTOFWERKDataFile.load function.
- isotope_table¶
dict of isotopes to signal indicies
- dataForIsotope(isotope: SPCalIsotope) ndarray¶
Access signals for isotope.
- property event_time: float¶
The time of a single acuqisition. Sometimes called the ‘dwell time’.
- property isotopes: list[SPCalIsotope]¶
The number of isotopes. This may be differetn from the number of masses due to isobars.
- classmethod load(path: Path | str, max_size: int | None = None) SPCalTOFWERKDataFile¶
Import a TOFWERK .h5 file.
- Parameters:
path – Path to the .h5
max_size – maximum number of events to read
- Returns:
data file
- property masses: ndarray¶
Masses (m/z) in the data file.
- property num_events: int¶
The number of events (e.g. acquisitions).
- property signals: ndarray¶
Signal intensities in the data file. Has the shape (num_events, masses).
- class spcal.datafile.SPCalTextDataFile(path: Path, signals: ndarray, times: ndarray, isotope_table: dict[SPCalIsotope, str], delimiter: str = ',', skip_rows: int = 1, cps: bool = False, drop_fields: list[str] | None = None, override_event_time: float | None = None)¶
Import and access to data stored as a text file, such as a CSV.
Create using the SPCalTextDataFile.load function.
- dataForIsotope(isotope: SPCalIsotope) ndarray¶
Access signals for isotope.
- isTOF() bool¶
Returns True is file is ‘suspected’ of being from a ToF.
- property isotopes: list[SPCalIsotope]¶
The number of isotopes. This may be differetn from the number of masses due to isobars.
- classmethod load(path: Path | str, isotope_table: dict[SPCalIsotope, str] | None = None, delimiter: str = ',', skip_rows: int = 1, cps: bool = False, drop_fields: list[str] | None = None, override_event_time: float | None = None) SPCalTextDataFile¶
Imports single particle data stored in a text file.
If a column with ‘time’ in the header is present then the ‘event_time’ can be automatically determined, otherwise override_event_time is required. If more than one isotopes are imported, the file is assumed to be from a ToF.
- Parameters:
path – path to the file
isotope_table – dictionary mmaping an SPCalIsotope to a column name. Note that this uses the name post import via np.genfromtxt.
delimiter – the text / column delimiter
skip_rows – number of rows to skip, including the header
cps – convert counts-per-second into counts, required if file is CPS
drop_fields – names in the file to skip. By default names containing ‘index’ or ‘time’ are skipped.
override_event_time – override any automatically determined event-time
- Returns:
data file
- Raises:
ValueError is event time cannot be read and is not provided –
- property masses: ndarray¶
Masses (m/z) in the data file.
- property num_events: int¶
The number of events (e.g. acquisitions).
- property signals: ndarray¶
Signal intensities in the data file. Has the shape (num_events, masses).