Multiple events
MultipleEventExtractor
- class apav.core.multipleevent.MultipleEventExtractor(roi, multiplicity, extents=((0, 200), (0, 200)))[source]
Handle extraction and access of multiple-event related data from an Roi
This class is responsible for extracting arbitrary multiple event data from Rois. The output is formatted in as pairs, i.e. a 6th order multiple event of the composition ABCDEF is formatted into the 15 ion pairs:
AB AC AD AE AF BC BD BE BF CD CE CF DE DF EF
The number of ion pairs generated from any nth order multiplicity can be calculated using
pairs_per_multiplicity().This class supports any multiplicity > 1, and also supports extracting the combined pairs all multiple events. For example, all of these are valid:
>>> roi = Roi.from_epos("path_to_epos_file.epos") >>> mevents = MultipleEventExtractor(roi, multiplicity=2) # Ion pairs from 2nd order multiple events >>> mevents = MultipleEventExtractor(roi, multiplicity=11) # Ion pairs from 11th order multiple events >>> mevents = MultipleEventExtractor(roi, multiplicity="multiples") # Ion pairs from all multiple events
The pairs can be access from
>>> mevents.pairs
More broadly, the indices of the pairs are accessed via
>>> mevents.pair_indices
Which allows for performing arbitrary analysis of multiple events on any data set attached to the Roi. For example, to form a plot of the difference in mass/charge ratio to distance between the ion pair in detector coordinates (to look at orientational properties of molecular dissociation):
>>> roi = Roi.from_epos("path_to_epos_file.epos") >>> mevents = MultipleEventExtractor(roi, multiplicity="multiples") # Use all multiple events >>> mass = roi.mass[mevents.pair_indices] >>> det_x = roi.misc["det_x"][mevents.pair_indices] >>> det_y = roi.misc["det_y"][mevents.pair_indices] >>> dx = np.diff(det_x) >>> dy = np.diff(det_y) >>> diff_det = np.linalg.norm([dx, dy], axis=0) >>> diff_mass = np.diff(mass) >>> plt.hist2d(diff_det, diff_mass, bins=100) >>> plt.plot()
- Parameters:
roi – region of interest
multiplicity (
Union[int,str]) – multiplicity order (int > 1 or “multiples”)extents (
Tuple[Tuple,Tuple]) – two dimensional range to extract events from (think correlation histograms)
- property extents: Tuple[Tuple[Number, Number], Tuple[Number, Number]]
Get the 2-dimensional boundary that was used to extract the ion pairs
- property multiplicity: Union[int, str]
int>1 or “multiples
- Type:
Get the multiplicity of multiple events in the
MultipleEventExtractor. Either
- property n_pairs: int
Get the number of pairs extracted
- property pair_indices: ndarray
Get the array of indices for the pairs. This is the same shape as
MultipleEventExtractor.pairs()but this is used to index map ion pairs to other positional data in theRoi.
- property pairs: ndarray
Get the array of all ion pairs. These are ion pairs regardless of the multiplicity so the arrays is Mx2
- property roi: Roi
Get the
Roiused in theMultipleEventExtractor
pairs_per_multiplicity
- apav.core.multipleevent.pairs_per_multiplicity(multiplicity)[source]
The number of unique ion pairs produced from a single multiple event of given multiplicity.
A 6th-order multiple event composed of ions ABCDEF produces the 15 ion pairs:
AB AC AD AE AF BC BD BE BF CD CE CF DE DF EF
>>> pairs_per_multiplicity(6) 15
- Parameters:
multiplicity (
int) – integer multiplicity order
get_mass_indices
- apav.core.multipleevent.get_mass_indices(ipp, multiplicity)[source]
Get the array indices corresponding to multi-event events of a specific multiplicity
- Parameters:
ipp (
ndarray) – array of ions per pulsemultiplicity (
Union[int,str]) – vent multiplicity
- Return type:
ndarray- Returns:
array of indices into ipp