Skip to content

Commit e07798f

Browse files
committed
Merge release-2.0.2
1 parent 74a58ae commit e07798f

File tree

10 files changed

+721
-443
lines changed

10 files changed

+721
-443
lines changed

D47crunch/__init__.py

Lines changed: 95 additions & 95 deletions
Large diffs are not rendered by default.

build_doc.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#! /usr/bin/env python3
2+
'''
3+
Apply an arbitrary filter to each docstring
4+
'''
5+
6+
import pdoc
7+
8+
substitutions = [
9+
('δ13C_VPDB', 'δ<sup>13</sup>C<sub>VPDB</sub>'),
10+
('δ18O_VPDB', 'δ<sup>18</sup>O<sub>VPDB</sub>'),
11+
('δ18O_VSMOW', 'δ<sup>18</sup>O<sub>VSMOW</sub>'),
12+
('δ13CVPDB', 'δ<sup>13</sup>C<sub>VPDB</sub>'),
13+
('δ18OVPDB', 'δ<sup>18</sup>O<sub>VPDB</sub>'),
14+
('δ18OVSMOW', 'δ<sup>18</sup>O<sub>VSMOW</sub>'),
15+
('δ13C', 'δ<sup>13</sup>C'),
16+
('δ18O', 'δ<sup>18</sup>O'),
17+
('12C', '<sup>12</sup>C'),
18+
('13C', '<sup>13</sup>C'),
19+
('16O', '<sup>16</sup>O'),
20+
('17O', '<sup>17</sup>O'),
21+
('18O', '<sup>18</sup>O'),
22+
('δ4x', 'δ<sub>4x</sub>'),
23+
('δ45', 'δ<sub>45</sub>'),
24+
('δ46', 'δ<sub>46</sub>'),
25+
('δ47', 'δ<sub>47</sub>'),
26+
('δ48', 'δ<sub>48</sub>'),
27+
('δ49', 'δ<sub>49</sub>'),
28+
('Δ4x', 'Δ<sub>4x</sub>'),
29+
('Δ4x', 'Δ<sub>4x</sub>'),
30+
('Δ47', 'Δ<sub>47</sub>'),
31+
('Δ48', 'Δ<sub>48</sub>'),
32+
('Δ49', 'Δ<sub>49</sub>'),
33+
('χ2', 'χ<sup>2</sup>'),
34+
('χ^2', 'χ<sup>2</sup>'),
35+
('CO2', 'CO<sub>2</sub>'),
36+
]
37+
38+
def myfilter(docstr):
39+
work = docstr.split('```')
40+
for k in range(len(work)):
41+
if k:
42+
work[k] = work[k].lstrip('`')
43+
if k%2 == 0:
44+
work[k] = work[k].split('`')
45+
for j in range(len(work[k])):
46+
if not j%2:
47+
for x,y in substitutions:
48+
work[k][j] = work[k][j].replace(x,y)
49+
work[k] = '`'.join(work[k])
50+
return ('```'.join(work))
51+
52+
pdoc.render.env.filters['myfilter'] = myfilter
53+
pdoc.render.configure(template_directory = 'pdoc_templates')
54+
55+
with open('docs/index.html', 'w') as fid:
56+
fid.write(pdoc.pdoc('D47crunch'))
57+
58+
# foo = '''
59+
# Create foo δ13C bar Δ47 δ18O_VSMOW `δ13C_VPDB`, `Δ48`.
60+
#
61+
# ````py
62+
# Create foo δ13C bar `Δ47` δ18O_VSMOW.
63+
# ```
64+
# '''
65+
#
66+
# print(myfilter(foo))

docs/D47_plot_Session_03.png

49.3 KB
Loading

docs/howto.md

Lines changed: 116 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,117 @@
11
## 2. How-to
22

3-
### 2.1 Use a different set of anchors, change anchor nominal values, and/or change <sup>17</sup>O correction parameters
3+
### 2.1 Simulate a virtual data set to play with
4+
5+
It is sometimes convenient to quickly build a virtual data set of analyses, for instance to assess the final analytical precision achievable for a given combination of anchor and unknown analyses (see also Fig. 6 of [Daëron, 2021](https://doi.org/10.1029/2020GC009592)).
6+
7+
This can be achieved with `virtual_data()`. The example below creates a dataset with four sessions, each of which comprises four analyses of anchor ETH-1, five of ETH-2, six of ETH-3, and two analyses of an unknown sample named `FOO` with an arbitrarily defined isotopic composition. Analytical repeatabilities for Δ47 and Δ48 are also specified arbitrarily. See the `virtual_data()` documentation for additional configuration parameters.
8+
9+
```py
10+
from D47crunch import *
11+
12+
args = dict(
13+
samples = [
14+
dict(Sample = 'ETH-1', N = 4),
15+
dict(Sample = 'ETH-2', N = 5),
16+
dict(Sample = 'ETH-3', N = 6),
17+
dict(
18+
Sample = 'FOO',
19+
N = 2,
20+
d13C_VPDB = -5.,
21+
d18O_VPDB = -10.,
22+
D47 = 0.3,
23+
D48 = 0.15
24+
),
25+
],
26+
rD47 = 0.010,
27+
rD48 = 0.030,
28+
)
29+
30+
session1 = virtual_data(session = 'Session_01', **args)
31+
session2 = virtual_data(session = 'Session_02', **args)
32+
session3 = virtual_data(session = 'Session_03', **args)
33+
session4 = virtual_data(session = 'Session_04', **args)
34+
35+
D = D47data(session1 + session2 + session3 + session4)
36+
37+
D.crunch()
38+
D.standardize()
39+
40+
D.table_of_sessions(verbose = True, save_to_file = False)
41+
D.table_of_samples(verbose = True, save_to_file = False)
42+
D.table_of_analyses(verbose = True, save_to_file = False)
43+
```
44+
45+
### 2.2 Control data quality
46+
47+
`D47crunch` offers several tools to visualize processed data. The examples below use the same virtual data set, generated with:
48+
49+
```py
50+
from D47crunch import *
51+
from random import shuffle
52+
53+
# generate virtual data:
54+
args = dict(
55+
samples = [
56+
dict(Sample = 'ETH-1', N = 8),
57+
dict(Sample = 'ETH-2', N = 8),
58+
dict(Sample = 'ETH-3', N = 8),
59+
dict(Sample = 'FOO', N = 4,
60+
d13C_VPDB = -5., d18O_VPDB = -10.,
61+
D47 = 0.3, D48 = 0.15),
62+
dict(Sample = 'BAR', N = 4,
63+
d13C_VPDB = -15., d18O_VPDB = -15.,
64+
D47 = 0.5, D48 = 0.2),
65+
])
66+
67+
sessions = [
68+
virtual_data(session = f'Session_{k+1:02.0f}', seed = int('1234567890'[:k+1]), **args)
69+
for k in range(10)]
70+
71+
# shuffle the data:
72+
data = [r for s in sessions for r in s]
73+
shuffle(data)
74+
data = sorted(data, key = lambda r: r['Session'])
75+
76+
# create D47data instance:
77+
data47 = D47data(data)
78+
79+
# process D47data instance:
80+
data47.crunch()
81+
data47.standardize()
82+
```
83+
84+
#### 2.1.1 Plotting the distribution of analyses through time
85+
86+
```py
87+
data47.plot_distribution_of_analyses(filename = 'time_distribution.pdf')
88+
```
89+
90+
![time_distribution.png](time_distribution.png)
91+
92+
The plot above shows the succession of analyses as if they were all distributed at regular time intervals. See `D4xdata.plot_distribution_of_analyses()` for how to plot analyses as a function of “true” time (based on the `TimeTag` for each analysis).
93+
94+
#### 2.1.2 Generating session plots
95+
96+
```py
97+
data47.plot_sessions()
98+
```
99+
100+
Below is one of the resulting sessions plots. Each cross marker is an analysis. Anchors are in red and unknowns in blue. Short horizontal lines show the nominal Δ47 value for anchors, in red, or the average Δ47 value for unknowns, in blue (overall average for all sessions). Curved grey contours correspond to Δ47 standardization errors in this session.
101+
102+
![D47_plot_Session_03.png](D47_plot_Session_03.png)
103+
104+
#### 2.1.3 Plotting Δ47 or Δ48 residuals
105+
106+
```py
107+
data47.plot_residuals(filename = 'residuals.pdf')
108+
```
109+
110+
![residuals.png](residuals.png)
111+
112+
Again, note that this plot only shows the succession of analyses as if they were all distributed at regular time intervals.
113+
114+
### 2.3 Use a different set of anchors, change anchor nominal values, and/or change 17O correction parameters
4115

5116
Nominal values for various carbonate standards are defined in four places:
6117

@@ -9,7 +120,7 @@ Nominal values for various carbonate standards are defined in four places:
9120
* `D47data.Nominal_D4x` (also accessible through `D47data.Nominal_D47`)
10121
* `D48data.Nominal_D4x` (also accessible through `D48data.Nominal_D48`)
11122

12-
<sup>17</sup>O correction parameters are defined by:
123+
17O correction parameters are defined by:
13124

14125
* `D4xdata.R13_VPDB`
15126
* `D4xdata.R18_VSMOW`
@@ -119,51 +230,9 @@ foo.table_of_samples(verbose = True, save_to_file = False)
119230
bar.table_of_samples(verbose = True, save_to_file = False)
120231
```
121232

122-
### 2.2 Simulate a virtual data set to play with
123-
124-
It is sometimes convenient to quickly build a virtual data set of analyses, for instance to assess the final analytical precision achievable for a given combination of anchor and unknown analyses (see also Fig. 6 of [Daëron, 2021]).
125-
126-
This can be achieved with `virtual_data()`. The example below creates a dataset with four sessions, each of which comprises four analyses of anchor ETH-1, five of ETH-2, six of ETH-3, and two analyses of an unknown sample named `FOO` with an arbitrarily defined isotopic composition. Analytical repeatabilities for Δ<sub>47</sub> and Δ<sub>48</sub> are also specified arbitrarily. See the `virtual_data()` documentation for additional configuration parameters.
127-
128-
```py
129-
from D47crunch import *
130-
131-
args = dict(
132-
samples = [
133-
dict(Sample = 'ETH-1', N = 4),
134-
dict(Sample = 'ETH-2', N = 5),
135-
dict(Sample = 'ETH-3', N = 6),
136-
dict(
137-
Sample = 'FOO',
138-
N = 2,
139-
d13C_VPDB = -5.,
140-
d18O_VPDB = -10.,
141-
D47 = 0.3,
142-
D48 = 0.15
143-
),
144-
],
145-
rD47 = 0.010,
146-
rD48 = 0.030,
147-
)
148-
149-
session1 = virtual_data(session = 'Session_01', **args)
150-
session2 = virtual_data(session = 'Session_02', **args)
151-
session3 = virtual_data(session = 'Session_03', **args)
152-
session4 = virtual_data(session = 'Session_04', **args)
153-
154-
D = D47data(session1 + session2 + session3 + session4)
155-
156-
D.crunch()
157-
D.standardize()
158-
159-
D.table_of_sessions(verbose = True, save_to_file = False)
160-
D.table_of_samples(verbose = True, save_to_file = False)
161-
D.table_of_analyses(verbose = True, save_to_file = False)
162-
```
163-
164-
### 2.3 Process paired Δ<sub>47</sub> and Δ<sub>48</sub> values
233+
### 2.4 Process paired Δ47 and Δ48 values
165234

166-
Purely in terms of data processing, it is not obvious why Δ<sub>47</sub> and Δ<sub>48</sub> data should not be handled separately. For now, `D47crunch` uses two independent classes — `D47data` and `D48data` — which crunch numbers and deal with standardization in very similar ways. The following example demonstrates how to print out combined outputs for `D47data` and `D48data`.
235+
Purely in terms of data processing, it is not obvious why Δ47 and Δ48 data should not be handled separately. For now, `D47crunch` uses two independent classes — `D47data` and `D48data` — which crunch numbers and deal with standardization in very similar ways. The following example demonstrates how to print out combined outputs for `D47data` and `D48data`.
167236

168237
```py
169238
from D47crunch import *
@@ -251,4 +320,4 @@ UID Session Sample d13Cwg_VPDB d18Owg_VSMOW d45 d46
251320
23 Session_02 FOO -4.000 26.000 -0.840413 2.828738 1.297658 5.325854 4.665655 -5.000000 28.907344 -0.612794 -0.337727 -0.000006 0.287767 0.126473
252321
24 Session_02 FOO -4.000 26.000 -0.840413 2.828738 1.310185 5.339898 4.665655 -5.000000 28.907344 -0.600291 -0.323761 -0.000006 0.300082 0.136830
253322
––– –––––––––– –––––– ––––––––––– –––––––––––– ––––––––– ––––––––– –––––––––– –––––––––– –––––––––– –––––––––– –––––––––– ––––––––– ––––––––– ––––––––– –––––––– ––––––––
254-
```
323+
```

0 commit comments

Comments
 (0)