Spectra : spectra¶
If you would like something that looks similar to your peak scans, you can use
spectra(), which you can also access from your
dataframe using the mz accessor:
import matplotlib.pyplot as plt
from interferences import build_table
from pyrolite.geochem.ind import REE
Here build a table based on some low-mass isotopes, and focus in on the BO+ ion:
Out:
0%| | 0/6 [00:00<?, ?it/s]
: 0%| | 0/6 [00:00<?, ?it/s]
N-N @ 6 rows : 0%| | 0/6 [00:00<?, ?it/s]
C-O @ 12 rows : 0%| | 0/6 [00:00<?, ?it/s]
C-N @ 8 rows : 0%| | 0/6 [00:00<?, ?it/s]
C-C @ 6 rows : 0%| | 0/6 [00:00<?, ?it/s]
B-O @ 12 rows : 0%| | 0/6 [00:00<?, ?it/s]
B-N @ 8 rows : 0%| | 0/6 [00:00<?, ?it/s]
B-N @ 8 rows : 100%|##########| 6/6 [00:00<00:00, 186.34it/s]
From this table, we can create our plot, limiting the labelling to the five peaks with highest estimated intensity. Note we should specify the mass resolution for the simulated peaks:

Out:
/home/docs/checkouts/readthedocs.org/user_builds/interferences/envs/latest/lib/python3.7/site-packages/numpy/core/fromnumeric.py:43: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
result = getattr(asarray(obj), method)(*args, **kwds)
Thesse peaks better show the ‘interference’ aspect of these ions at relatively low mass resolution, but are notably unnaturally square. To simulate some shoulders for your peaks (i.e. a non-zero-width image of your source, and a signal limited by a collector slit or similar ) you can specify a ratio for the image_ratio keyword argument. Here we explore the effect this parameter with a few different values (0, <1, 1, and >1):
fig, ax = plt.subplots(2, 2, sharex=True, sharey=True, figsize=(8, 8))
for a, ratio in zip(ax.flat, [0, 0.2, 1, 1.5]):
df.mz.spectra(
ax=a, window=window, mass_resolution=3000, image_ratio=ratio, max_labels=5
)
a.annotate(
"ratio={:.1f}".format(ratio),
xy=(0.9, 0.9),
xycoords=a.transAxes,
ha="right",
fontsize=12,
)
plt.show()

Total running time of the script: ( 0 minutes 24.328 seconds)