pyccapt.calibration.leap_tools package
Submodules
pyccapt.calibration.leap_tools.ccapt_tools module
- pyccapt.calibration.leap_tools.ccapt_tools.apt_to_ccapt(file_path)[source]
Convert APT data to PyCCAPT format.
- Parameters:
file_path – APT data file path.
- Returns:
CCAPT data.
- Return type:
pandas.DataFrame
- pyccapt.calibration.leap_tools.ccapt_tools.ccapt_to_epos(data, path=None, name=None, chunk_size=1000000)[source]
Convert CCAPT data to EPOS format, processing in chunks to avoid memory errors.
- pyccapt.calibration.leap_tools.ccapt_tools.ccapt_to_pos(data, path=None, name=None)[source]
Convert CCAPT data to POS format.
- pyccapt.calibration.leap_tools.ccapt_tools.epos_lazy_to_ccapt_chunks(epos_table, chunk_size: int = 1048576)[source]
Stream a memory-mapped EPOS table as PyCCAPT-format DataFrame chunks.
- Parameters:
epos_table –
LazyTablefrompyccapt.calibration.leap_tools.leap_tools.read_epos_lazy().chunk_size – Number of rows per yielded DataFrame.
- Yields:
pandas.DataFrame – A PyCCAPT-format chunk with the standard 15 columns.
The conversion is the same as
epos_to_ccapt()but never holds the whole file in RAM; peak resident memory is bounded bychunk_sizerows (about 60 bytes/row).
pyccapt.calibration.leap_tools.leap_tools module
- class pyccapt.calibration.leap_tools.leap_tools.ByteFormat(*values)[source]
Bases:
Enum- CHAR = 1
- INT_32 = 4
- INT_64 = 8
- TIME_STAMP = 8
- WIDE_CHAR = 2
- class pyccapt.calibration.leap_tools.leap_tools.DataCategory(*values)[source]
Bases:
Enum- CONSTANT = 1
- INDEXED_VARIABLE = 3
- UNSPECIFIED = 0
- VARIABLE = 2
- class pyccapt.calibration.leap_tools.leap_tools.DataFormat(*values)[source]
Bases:
Enum- CUSTOM = 5
- DECIMAL = 3
- INTEGER = 1
- TEXT = 4
- UNSIGNED_INT = 2
- UNSPECIFIED = 0
- class pyccapt.calibration.leap_tools.leap_tools.RelationKind(*values)[source]
Bases:
Enum- INDEPENDENT = 3
- INDEXED = (2,)
- MULTIPLE = 4
- SINGLE = 1
- UNSPECIFIED = 0
- pyccapt.calibration.leap_tools.leap_tools.deconvolve(lpos)[source]
Takes a composition-labelled pos file and deconvolves the complex ions. Produces a DataFrame of the same input format with the extra columns: ‘element’: element name ‘n’: stoichiometry For complex ions, the location of the different components is not altered - i.e. xyz position will be the same for several elements.
Parameters: - lpos (DataFrame): A composition-labelled pos file DataFrame.
Returns: - out (DataFrame): A deconvolved DataFrame with additional ‘element’ and ‘n’ columns.
- pyccapt.calibration.leap_tools.leap_tools.label_ions(pos, rrngs)[source]
Labels ions in a .pos or .epos DataFrame (anything with a ‘Da’ column) with composition and color, based on an imported .rrng file.
Parameters: - pos (DataFrame): A DataFrame containing ion positions, with a ‘Da’ column. - rrngs (DataFrame): A DataFrame containing range data imported from a .rrng file.
Returns: - pos (DataFrame): The modified DataFrame with added ‘comp’ and ‘colour’ columns.
- pyccapt.calibration.leap_tools.leap_tools.parse_rng(file_path)[source]
Load a legacy IVAS/LEAP .rng file and return raw ion and range tables.
- Returns:
(ions, ranges) in a normalized raw schema.
- Return type:
tuple[pd.DataFrame, pd.DataFrame]
- pyccapt.calibration.leap_tools.leap_tools.parse_rrng(file_path)[source]
Load a .rrng file produced by IVAS and return the raw ion and range tables.
- Returns:
(ions, rrngs) in the IVAS schema.
- Return type:
tuple[pd.DataFrame, pd.DataFrame]
- pyccapt.calibration.leap_tools.leap_tools.read_apt(file_path: str, debug: bool = False) DataFrame[source]
Load data from an APT file into a pandas DataFrame.
- pyccapt.calibration.leap_tools.leap_tools.read_epos(file_path)[source]
Loads an APT .epos file as a pandas DataFrame.
- Columns:
x: Reconstructed x position y: Reconstructed y position z: Reconstructed z position Da: Mass/charge ratio of ion ns: Ion Time Of Flight DC_kV: Potential pulse_kV: Size of voltage pulse (voltage pulsing mode only) det_x: Detector x position det_y: Detector y position pslep: Pulses since last event pulse (i.e. ionisation rate) ipp: Ions per pulse (multihits)
Note
For low-memory environments use
read_epos_lazy(), which returns apyccapt.calibration.data_tools.lazy_io.LazyTableview that reads columns on demand. The eagerread_epos()itself now reads the memmap field-by-field with a single byte-order conversion per column instead of the previous 11-foldnp.asarraycascade.
- pyccapt.calibration.leap_tools.leap_tools.read_epos_lazy(file_path)[source]
Open an APT
.eposfile as a memory-mappedLazyTable.Returns a column-oriented view that reads on demand. Suited for the low-memory case (e.g. correcting a 2 GB EPOS on an 8 GB machine). Use
with read_epos_lazy(path) as table: ...so the memmap is released promptly on Windows.
- pyccapt.calibration.leap_tools.leap_tools.read_pos(file_path)[source]
Loads an APT .pos file as a pandas DataFrame.
- Columns:
x: Reconstructed x position y: Reconstructed y position z: Reconstructed z position Da: Mass/charge ratio of ion
Note
For low-memory environments use
read_pos_lazy(), which returns apyccapt.calibration.data_tools.lazy_io.LazyTableview that reads columns on demand instead of materializing the full DataFrame.
- pyccapt.calibration.leap_tools.leap_tools.read_pos_lazy(file_path)[source]
Open an APT
.posfile as a memory-mappedLazyTable.Returns a column-oriented view that reads on demand. Use this in low-memory contexts; the caller is responsible for closing the table (preferred:
with read_pos_lazy(path) as table: ...).
- pyccapt.calibration.leap_tools.leap_tools.read_rng(file_path, return_tables: bool = False)[source]
Load a legacy .rng file produced by older IVAS/LEAP workflows.
Parameters: - file_path (str): The path to the .rng file. - return_tables (bool): When True, return the raw (ions, ranges)
tables. Otherwise return the normalized PyCCAPT range dataframe.
- pyccapt.calibration.leap_tools.leap_tools.read_rrng(file_path, return_tables: bool = False)[source]
Load a .rrng file produced by IVAS.
Parameters: - file_path (str): The path to the .rrng file. - return_tables (bool): When True, return the raw (ions, rrngs)
IVAS tables. Otherwise return the normalized PyCCAPT range dataframe.
- pyccapt.calibration.leap_tools.leap_tools.volvis(pos, size=2, alpha=1)[source]
Displays a 3D point cloud in an OpenGL viewer window. If points are not labelled with colors, point brightness is determined by Da values (higher = whiter).
Parameters: - pos (DataFrame): A DataFrame containing 3D point cloud data. - size (int): The size of the markers representing the points. Default is 2. - alpha (float): The transparency of the markers. Default is 1.
Returns: - None
- pyccapt.calibration.leap_tools.leap_tools.write_rrng(file_path, ions, rrngs)[source]
Write ion and range DataFrames to an IVAS-style
.rrngfile.Parameters: - file_path (str): Destination path for the
.rrngfile. - ions (DataFrame): Ion table with at least thenamecolumn. - rrngs (DataFrame): Range table withlower,upper,vol,comp, andcolorcolumns.Returns: - None
Module contents
LEAP format readers, converters, and visualization helpers.