Advanced region selection using LaserTRAM
: region omission¶
Prior to this, please read the following tutorial. This tutorial goes over how to omit a multi-sweep region from an area that is otherwise considered "good". If you are concerned with signal de-spiking, please see that tutorial. Let's begin!
import lasertram
from lasertram import preprocessing, plotting, LaserTRAM
import pandas as pd
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
pd.set_option("display.max_rows",None)
plt.style.use("lasertram.lasertram")
print(f"lasertram {lasertram.__version__}")
lasertram 1.0.1
Load in test data¶
Here we load in some data that comes shipped with lasertram. These data are analyses of volcanic tephra utilized in Lubbers et al., (2023) and also the examples from Lubbers et al., (2025).
raw_data = preprocessing.load_test_rawdata()
raw_data.head()
timestamp | Time | 7Li | 29Si | 31P | 43Ca | 45Sc | 47Ti | 51V | 55Mn | ... | 153Eu | 157Gd | 163Dy | 166Er | 172Yb | 178Hf | 181Ta | 208Pb | 232Th | 238U | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SampleLabel | |||||||||||||||||||||
GSD-1G_-_1 | 2022-05-10 23:08:59 | 13.24 | 100.0004 | 188916.876574 | 5901.392729 | 200.0016 | 1800.129609 | 0.0 | 300.0036 | 1500.090005 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
GSD-1G_-_1 | 2022-05-10 23:08:59 | 379.06 | 0.0000 | 178769.261758 | 4600.846556 | 100.0004 | 800.025601 | 0.0 | 0.0000 | 1300.067604 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
GSD-1G_-_1 | 2022-05-10 23:08:59 | 745.03 | 0.0000 | 182928.794765 | 6101.488763 | 100.0004 | 1000.040002 | 0.0 | 100.0004 | 1000.040002 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
GSD-1G_-_1 | 2022-05-10 23:08:59 | 1110.96 | 0.0000 | 182319.996777 | 5701.299896 | 200.0016 | 1000.040002 | 0.0 | 0.0000 | 1400.078404 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
GSD-1G_-_1 | 2022-05-10 23:08:59 | 1476.94 | 0.0000 | 175625.161124 | 5801.345912 | 100.0004 | 1300.067604 | 0.0 | 300.0036 | 1200.057603 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
5 rows × 34 columns
Visualize raw data¶
While lasertram
is primarily used for calculations, there are some basic plotting capabilities for easy and quick viewing of time-series data and other things specific to laser ablation datasets.
Below we pick a sample to look at in our raw data:
samples = raw_data.index.unique().dropna().tolist()
print(samples)
['GSD-1G_-_1', 'GSD-1G_-_2', 'GSE-1G_-_1', 'GSE-1G_-_2', 'BCR-2G_-_1', 'BCR-2G_-_2', 'ATHO-G_-_1', 'ATHO-G_-_2', 'NIST-612_-_1', 'NIST-612_-_2', 'AT-3214-2_shard1_-_1', 'AT-3214-2_shard1_-_2', 'AT-3214-2_shard1_-_3', 'AT-3214-2_shard2_-_1', 'AT-3214-2_shard2_-_2', 'AT-3214-2_shard2_-_3', 'AT-3214-2_shard3_-_1', 'AT-3214-2_shard3_-_2', 'AT-3214-2_shard3_-_3', 'AT-3214-2_shard4_-_1', 'AT-3214-2_shard4_-_2', 'AT-3214-2_shard4_-_3', 'AT-3214-2_shard5_-_1', 'AT-3214-2_shard5_-_2', 'AT-3214-2_shard5_-_3', 'GSD-1G_-_3', 'GSE-1G_-_3', 'AT-3214-2_shard6_-_1', 'AT-3214-2_shard6_-_2', 'AT-3214-2_shard6_-_3', 'AT-3214-2_shard7_-_1', 'AT-3214-2_shard7_-_2', 'AT-3214-2_shard7_-_3', 'AT-3214-2_shard8_-_1', 'AT-3214-2_shard8_-_2', 'AT-3214-2_shard8_-_3', 'AT-5846_shard1_-_1', 'AT-5846_shard1_-_2', 'AT-5846_shard1_-_3', 'AT-5846_shard1_-_4', 'AT-5846_shard2_-_1', 'AT-5846_shard2_-_2', 'GSD-1G_-_4', 'GSE-1G_-_4', 'AT-5846_shard2_-_3', 'AT-5846_shard2_-_4', 'AT-5846_shard2_-_5', 'AT-5846_shard3_-_1', 'AT-5846_shard3_-_2', 'AT-5846_shard3_-_3', 'AT-5846_shard3_-_4', 'AT-5846_shard3_-_5', 'AT-5846_shard4_-_1', 'AT-5846_shard4_-_2', 'AT-5846_shard4_-_3', 'AT-5846_shard4_-_4', 'AT-5846_shard4_-_5', 'AT-5846_shard5_-_1', 'AT-5846_shard5_-_2', 'GSD-1G_-_5', 'GSE-1G_-_5', 'AT-5846_shard5_-_3', 'AT-5846_shard5_-_4', 'AT-5846_shard5_-_5', 'AT-5846_shard6_-_1', 'AT-5846_shard6_-_2', 'AT-5846_shard6_-_3', 'AT-5846_shard6_-_4', 'AT-5846_shard6_-_5', 'AT-5846_shard7_-_1', 'AT-5846_shard7_-_2', 'AT-5846_shard7_-_3', 'AT-5846_shard7_-_4', 'AT-5846_shard7_-_5', 'AT-5846_shard8_-_1', 'AT-5846_shard8_-_2', 'GSE-1G_-_6', 'AT-5846_shard8_-_3', 'AT-5846_shard8_-_4', 'AT-5846_shard8_-_5', 'AT-5846_shard9_-_1', 'AT-5846_shard9_-_2', 'AT-5846_shard9_-_3', 'AT-5846_shard9_-_4', 'AT-5846_shard9_-_5', 'AT-5846_shard10_-_1', 'AT-5846_shard10_-_2', 'AT-5846_shard10_-_3', 'AT-5846_shard11_-_1', 'AT-5846_shard11_-_2', 'AT-5846_shard11_-_3', 'AT-5846_shard11_-_4', 'GSD-1G_-_7', 'GSE-1G_-_7', 'AT-5846_shard11_-_5', 'AT-5844_shard1_-_1', 'AT-5844_shard1_-_2', 'AT-5844_shard1_-_3', 'AT-5844_shard1_-_4', 'AT-5844_shard1_-_5', 'AT-5844_shard2_-_1', 'AT-5844_shard2_-_2', 'AT-5844_shard2_-_3', 'AT-5844_shard3_-_1', 'AT-5844_shard3_-_2', 'AT-5844_shard3_-_3', 'AT-5844_shard3_-_4', 'AT-5844_shard4_-_1', 'AT-5844_shard4_-_2', 'GSD-1G_-_8', 'GSE-1G_-_8', 'AT-5844_shard4_-_3', 'AT-5844_shard4_-_4', 'AT-5844_shard4_-_5', 'AT-5844_shard5_-_1', 'AT-5844_shard5_-_2', 'AT-5844_shard5_-_3', 'AT-5844_shard6_-_1', 'AT-5844_shard6_-_2', 'AT-5844_shard6_-_3', 'AT-5844_shard7_-_1', 'AT-5844_shard7_-_2', 'AT-5844_shard7_-_3', 'AT-5844_shard7_-_4', 'AT-5844_shard8_-_1', 'AT-5844_shard8_-_2', 'GSD-1G_-_9', 'GSE-1G_-_9', 'AT-5844_shard8_-_3', 'AT-5844_shard8_-_4', 'AT-5844_shard9_-_1', 'AT-5844_shard9_-_2', 'AT-5844_shard9_-_3', 'AT-5844_shard10_-_1', 'AT-5844_shard10_-_2', 'AT-5844_shard10_-_3', 'AT-5844_shard10_-_4', 'AT-5843_shard1_-_1', 'AT-5843_shard1_-_2', 'AT-5843_shard1_-_3', 'AT-5843_shard1_-_4', 'AT-5843_shard2_-_1', 'AT-5843_shard2_-_2', 'GSD-1G_-_10', 'GSE-1G_-_10', 'AT-5843_shard2_-_3', 'AT-5843_shard2_-_4', 'AT-5843_shard2_-_5', 'AT-5843_shard3_-_1', 'AT-5843_shard3_-_2', 'AT-5843_shard3_-_3', 'AT-5843_shard3_-_4', 'AT-5843_shard3_-_5', 'AT-5843_shard4_-_1', 'AT-5843_shard4_-_2', 'AT-5843_shard4_-_3', 'AT-5843_shard5_-_1', 'AT-5843_shard5_-_2', 'AT-5843_shard5_-_3', 'AT-5843_shard5_-_4', 'GSD-1G_-_11', 'GSE-1G_-_11', 'AT-5843_shard5_-_5', 'AT-5843_shard6_-_1', 'AT-5843_shard6_-_2', 'AT-5843_shard6_-_3', 'AT-5843_shard6_-_4', 'AT-5843_shard7_-_1', 'AT-5843_shard7_-_2', 'AT-5843_shard7_-_3', 'AT-5843_shard7_-_4', 'AT-5843_shard7_-_5', 'AT-5843_shard8_-_1', 'AT-5843_shard8_-_2', 'AT-5843_shard8_-_3', 'AT-5843_shard8_-_4', 'AT-5843_shard9_-_1', 'GSD-1G_-_12', 'GSE-1G_-_12', 'AT-5843_shard9_-_2', 'AT-5843_shard9_-_3', 'AT-5843_shard9_-_4', 'AT-5843_shard10_-_1', 'AT-5843_shard10_-_2', 'AT-5843_shard10_-_3', 'GSD-1G_-_13', 'GSD-1G_-_14', 'GSE-1G_-_13', 'GSE-1G_-_14', 'BCR-2G_-_3', 'BCR-2G_-_4', 'ATHO-G_-_3', 'ATHO-G_-_4', 'NIST-612_-_3', 'NIST-612_-_4']
sample = "AT-3214-2_shard6_-_3"
ax = plotting.plot_timeseries_data(raw_data.loc[sample,:])
ax[0].set_title(sample)
ax[0].set_ylabel("cps")
ax[0].set_xlabel("Time (ms)")
Text(0.5, 0, 'Time (ms)')
Start the LaserTRAM process¶
A quick inspection of our data loaded in:
spot = LaserTRAM(name=sample)
spot.get_data(raw_data.loc[sample, :])
spot.data.head()
timestamp | Time | 7Li | 29Si | 31P | 43Ca | 45Sc | 47Ti | 51V | 55Mn | ... | 153Eu | 157Gd | 163Dy | 166Er | 172Yb | 178Hf | 181Ta | 208Pb | 232Th | 238U | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SampleLabel | |||||||||||||||||||||
AT-3214-2_shard6_-_3 | 2022-05-10 23:38:19 | 0.01330 | 0.0000 | 202121.010504 | 6601.742860 | 100.0004 | 600.014400 | 100.0004 | 0.0000 | 1200.057603 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
AT-3214-2_shard6_-_3 | 2022-05-10 23:38:19 | 0.37916 | 0.0000 | 196431.379031 | 4400.774536 | 200.0016 | 700.019601 | 0.0000 | 0.0000 | 1900.144411 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
AT-3214-2_shard6_-_3 | 2022-05-10 23:38:19 | 0.74500 | 100.0004 | 218187.760504 | 5301.123838 | 400.0064 | 900.032401 | 0.0000 | 0.0000 | 1500.090005 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
AT-3214-2_shard6_-_3 | 2022-05-10 23:38:19 | 1.11086 | 0.0000 | 204966.789936 | 4300.739727 | 0.0000 | 900.032401 | 0.0000 | 0.0000 | 1300.067604 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
AT-3214-2_shard6_-_3 | 2022-05-10 23:38:19 | 1.47670 | 100.0004 | 205983.295491 | 6301.588000 | 200.0016 | 1000.040002 | 0.0000 | 100.0004 | 1600.102407 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
5 rows × 34 columns
Region selection¶
The assign_intervals
method has everything we need to complete our region omission task but including the omit
argument. This defaults to None
, however, just like with the bkgd
and keep
arguments, it accepts a tuple for the start and stop time of that region. Below we utilize this to choose background, overall good interval to keep, and a region within that to omit. On the created figure, red is background and green is the region chosen as the interval to be used in calculating concentrations. Note how the omitted region is missing from that!
bkgd_interval = (5, 10)
keep_interval = (23, 40)
omit_interval = (30, 33) # arbitrary for example
spot.assign_int_std("29Si")
spot.assign_intervals(
bkgd=bkgd_interval,
keep=keep_interval,
omit=omit_interval
)
ax = plotting.plot_timeseries_data(spot.data)
ax[0].set_title(sample)
ax[0].set_ylabel("cps")
ax[0].set_xlabel("Time (ms)")
ax[0].axvspan(bkgd_interval[0], bkgd_interval[1], facecolor="r", alpha=0.3)
ax[0].axvspan(keep_interval[0], omit_interval[0], facecolor="g", alpha=0.3)
ax[0].axvspan(omit_interval[1], keep_interval[1], facecolor="g", alpha=0.3)
<matplotlib.patches.Polygon at 0x1a249ca4c40>
Finish off the LaserTRAM process¶
spot.get_bkgd_data()
spot.subtract_bkgd()
spot.get_detection_limits()
spot.normalize_interval()
spot.make_output_report()
We can see that the omitted region is recorded in the output report along with all the other important data/metadata
spot.output_report.T
0 | |
---|---|
timestamp | 2022-05-10 23:38:19 |
Spot | AT-3214-2_shard6_-_3 |
despiked | None |
omitted_region | (30.01922, 33.31252) |
bkgd_start | 5.13589 |
bkgd_stop | 10.25886 |
int_start | 23.06676 |
int_stop | 40.26503 |
norm | 29Si |
norm_cps | 2288974.705871 |
7Li | 0.006197 |
29Si | 1.0 |
31P | 0.038606 |
43Ca | 0.013767 |
45Sc | 0.006963 |
47Ti | 0.11815 |
51V | 0.013501 |
55Mn | 0.612665 |
65Cu | 0.000348 |
66Zn | 0.006856 |
85Rb | 0.047391 |
88Sr | 0.128631 |
89Y | 0.019142 |
90Zr | 0.049193 |
93Nb | 0.002092 |
133Cs | 0.003186 |
137Ba | 0.069197 |
139La | 0.01154 |
140Ce | 0.029607 |
141Pr | 0.005364 |
146Nd | 0.003968 |
147Sm | 0.000722 |
153Eu | 0.000836 |
157Gd | 0.000748 |
163Dy | 0.001354 |
166Er | 0.000953 |
172Yb | 0.000727 |
178Hf | 0.001267 |
181Ta | 0.000196 |
208Pb | 0.005802 |
232Th | 0.003203 |
238U | 0.002106 |
7Li_se | 2.132192 |
29Si_se | 0.0 |
31P_se | 0.753684 |
43Ca_se | 1.404552 |
45Sc_se | 1.278036 |
47Ti_se | 0.856179 |
51V_se | 1.279816 |
55Mn_se | 0.876139 |
65Cu_se | 6.112 |
66Zn_se | 1.843486 |
85Rb_se | 2.053037 |
88Sr_se | 1.933305 |
89Y_se | 1.73638 |
90Zr_se | 1.514595 |
93Nb_se | 2.617226 |
133Cs_se | 2.242604 |
137Ba_se | 1.448926 |
139La_se | 1.477327 |
140Ce_se | 1.5518 |
141Pr_se | 1.5594 |
146Nd_se | 2.118911 |
147Sm_se | 3.911019 |
153Eu_se | 3.316869 |
157Gd_se | 3.933527 |
163Dy_se | 3.449319 |
166Er_se | 4.116724 |
172Yb_se | 3.608729 |
178Hf_se | 3.221462 |
181Ta_se | 7.097878 |
208Pb_se | 2.596553 |
232Th_se | 2.47981 |
238U_se | 2.931448 |