DiadFit 1.0.2__py3-none-any.whl → 1.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DiadFit/CO2_EOS.py +7 -1
- DiadFit/H2O_fitting.py +24 -16
- DiadFit/_version.py +1 -1
- DiadFit/densimeters.py +2 -2
- DiadFit/density_depth_crustal_profiles.py +197 -175
- DiadFit/diads.py +11 -1
- DiadFit/error_propagation.py +1 -1
- DiadFit/importing_data_files.py +152 -0
- DiadFit/molar_gas_proportions.py +96 -0
- DiadFit/ne_lines.py +14 -9
- DiadFit/relaxfi_PW.py +638 -0
- DiadFit/relaxifi.py +173 -33
- {DiadFit-1.0.2.dist-info → DiadFit-1.0.8.dist-info}/METADATA +4 -4
- {DiadFit-1.0.2.dist-info → DiadFit-1.0.8.dist-info}/RECORD +16 -15
- {DiadFit-1.0.2.dist-info → DiadFit-1.0.8.dist-info}/WHEEL +1 -1
- {DiadFit-1.0.2.dist-info → DiadFit-1.0.8.dist-info}/top_level.txt +0 -0
@@ -1,24 +1,14 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
import numpy as np
|
2
4
|
import matplotlib.pyplot as plt
|
3
5
|
import pandas as pd
|
4
6
|
import inspect
|
5
7
|
|
6
8
|
|
7
|
-
|
8
9
|
def rasmussen(P_kbar):
|
9
|
-
"""
|
10
|
-
overall best fit density vs. depth. Above 5.24 kbar, returns Nan
|
11
|
-
|
12
|
-
Parameters
|
13
|
-
-------------
|
14
|
-
P_kbar: int, float, pd.series
|
15
|
-
Pressure in kbar
|
16
|
-
|
17
|
-
Returns
|
18
|
-
-------------
|
19
|
-
Depth in km (same datatype as input)
|
20
|
-
|
21
|
-
"""
|
10
|
+
""" 4th degree fit to the supporting information of Rasmussen et al. 2022,
|
11
|
+
overall best fit density vs. depth. Above 5.24 kbar, returns Nan"""
|
22
12
|
P=P_kbar
|
23
13
|
if P<5.2474630296099205:
|
24
14
|
b=-0.0025915704129682504
|
@@ -32,20 +22,8 @@ def rasmussen(P_kbar):
|
|
32
22
|
return D
|
33
23
|
|
34
24
|
def hill_zucca(P_kbar):
|
35
|
-
|
36
|
-
|
37
|
-
as given in Putirka (2017) Down the Crater Elements supplement for Hawaii
|
38
|
-
|
39
|
-
Parameters
|
40
|
-
-------------
|
41
|
-
P_kbar: int, float, pd.series
|
42
|
-
Pressure in kbar
|
43
|
-
|
44
|
-
Returns
|
45
|
-
-------------
|
46
|
-
Depth in km (same datatype as input)
|
47
|
-
|
48
|
-
|
25
|
+
""" Parameterization of Hill and Zucca (1987),
|
26
|
+
as given in Putirka (2017) Down the Crater Elements supplement
|
49
27
|
"""
|
50
28
|
P=P_kbar
|
51
29
|
|
@@ -54,19 +32,8 @@ def hill_zucca(P_kbar):
|
|
54
32
|
return D
|
55
33
|
|
56
34
|
def ryan_lerner(P_kbar):
|
57
|
-
"""
|
58
|
-
After 16.88 km (455 MPa), returns
|
59
|
-
|
60
|
-
Parameters
|
61
|
-
-------------
|
62
|
-
P_kbar: int, float, pd.series
|
63
|
-
Pressure in kbar
|
64
|
-
|
65
|
-
Returns
|
66
|
-
-------------
|
67
|
-
Depth in km (same datatype as input)
|
68
|
-
|
69
|
-
|
35
|
+
""" Parameterization of Ryan 1987, actual equation from Lerner et al. 2021
|
36
|
+
After 16.88 km (455 MPa), returns Nan
|
70
37
|
"""
|
71
38
|
P=P_kbar*100
|
72
39
|
if P<455.09090909:
|
@@ -76,7 +43,6 @@ def ryan_lerner(P_kbar):
|
|
76
43
|
|
77
44
|
return D
|
78
45
|
|
79
|
-
|
80
46
|
def denlinger_lerner(P_kbar):
|
81
47
|
""" Calculates depth for a given pressure using the Parameterization of Denlinger and Flinders (2022) with the addition of 200 kg/m3 at shallow depths, from Lerner et al. (2024).
|
82
48
|
After 15 km returns NaN following Lerner
|
@@ -100,23 +66,9 @@ def denlinger_lerner(P_kbar):
|
|
100
66
|
return D
|
101
67
|
|
102
68
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
69
|
def mavko_debari(P_kbar):
|
107
|
-
"""
|
70
|
+
""" Parameterization of Mavko and Thompson (1983) and DeBari and Greene (2011)
|
108
71
|
as given in Putirka (2017) Down the Crater Elements supplement, used for Cascades
|
109
|
-
|
110
|
-
Parameters
|
111
|
-
-------------
|
112
|
-
P_kbar: int, float, pd.series
|
113
|
-
Pressure in kbar
|
114
|
-
|
115
|
-
Returns
|
116
|
-
-------------
|
117
|
-
Depth in km (same datatype as input)
|
118
|
-
|
119
|
-
|
120
72
|
"""
|
121
73
|
P=P_kbar
|
122
74
|
D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2
|
@@ -126,43 +78,9 @@ def mavko_debari(P_kbar):
|
|
126
78
|
|
127
79
|
|
128
80
|
def prezzi(P_kbar):
|
129
|
-
"""
|
130
|
-
as given in Putirka (2017) Down the Crater Elements supplement.
|
131
|
-
Used for Andes.
|
132
|
-
|
133
|
-
Parameters
|
134
|
-
-------------
|
135
|
-
P_kbar: int, float, pd.series
|
136
|
-
Pressure in kbar
|
137
|
-
|
138
|
-
Returns
|
139
|
-
-------------
|
140
|
-
Depth in km (same datatype as input)
|
141
|
-
|
142
|
-
|
143
|
-
"""
|
144
|
-
P=P_kbar
|
145
|
-
D=4.88 + 3.30*P - 0.0137*(P - 18.01)**2
|
146
|
-
|
147
|
-
return D
|
148
|
-
|
149
|
-
|
150
|
-
def prezzi(P_kbar):
|
151
|
-
"""Calculates depth for a given pressure using the parameterization of Prezzi et al. (2009),
|
81
|
+
""" Parameterization of Prezzi et al. (2009),
|
152
82
|
as given in Putirka (2017) Down the Crater Elements supplement.
|
153
83
|
Used for Andes.
|
154
|
-
|
155
|
-
Parameters
|
156
|
-
-------------
|
157
|
-
P_kbar: int, float, pd.series
|
158
|
-
Pressure in kbar
|
159
|
-
|
160
|
-
Returns
|
161
|
-
-------------
|
162
|
-
Depth in km (same datatype as input)
|
163
|
-
|
164
|
-
|
165
|
-
|
166
84
|
"""
|
167
85
|
P=P_kbar
|
168
86
|
D=4.88 + 3.30*P - 0.0137*(P - 18.01)**2
|
@@ -170,7 +88,7 @@ def prezzi(P_kbar):
|
|
170
88
|
return D
|
171
89
|
|
172
90
|
|
173
|
-
Profile_funcs={ryan_lerner,
|
91
|
+
Profile_funcs={ryan_lerner, mavko_debari, hill_zucca, prezzi, rasmussen, denlinger_lerner}
|
174
92
|
Profile_funcs_by_name= {p.__name__: p for p in Profile_funcs}
|
175
93
|
|
176
94
|
|
@@ -192,9 +110,6 @@ def convert_pressure_depth_2step(P_kbar=None, d1=None, rho1=None, rho2=None, g=9
|
|
192
110
|
rho2: int or float
|
193
111
|
Density (kg/m3) below step transition
|
194
112
|
|
195
|
-
g: float
|
196
|
-
gravitational constant
|
197
|
-
|
198
113
|
Returns
|
199
114
|
-------------
|
200
115
|
float
|
@@ -214,8 +129,6 @@ def convert_pressure_depth_2step(P_kbar=None, d1=None, rho1=None, rho2=None, g=9
|
|
214
129
|
# print(P_belowMoho)
|
215
130
|
depth_km_bm=10**(-3)*((P_belowstep1*100000000)/(g*rho2))
|
216
131
|
depth_km=d1+depth_km_bm
|
217
|
-
if np.isnan(P_kbar):
|
218
|
-
depth_km=np.nan
|
219
132
|
|
220
133
|
return depth_km
|
221
134
|
|
@@ -237,28 +150,25 @@ def loop_pressure_depth_2step(P_kbar=None, d1=14, rho1=2800, rho2=3100, g=9.81):
|
|
237
150
|
rho2: int or float
|
238
151
|
Density (kg/m3) below step transition
|
239
152
|
|
240
|
-
g: float
|
241
|
-
gravitational constant
|
242
|
-
|
243
153
|
Returns
|
244
154
|
-------------
|
245
155
|
pd.Series
|
246
156
|
Depth in km
|
247
157
|
|
248
158
|
"""
|
249
|
-
if
|
250
|
-
depth_km_loop=convert_pressure_depth_2step(P_kbar,
|
251
|
-
|
159
|
+
if np.isscalar(P_kbar): # Check if it's a scalar (int, float, or numpy scalar)
|
160
|
+
depth_km_loop = convert_pressure_depth_2step(P_kbar, d1=d1, rho1=rho1, rho2=rho2, g=g)
|
161
|
+
|
252
162
|
else:
|
253
|
-
depth_km_loop=np.
|
163
|
+
depth_km_loop=np.empty(len(P_kbar))
|
254
164
|
for i in range(0, len(P_kbar)):
|
255
165
|
depth_km_loop[i]=convert_pressure_depth_2step(P_kbar[i],
|
256
166
|
d1=d1, rho1=rho1, rho2=rho2, g=g)
|
257
167
|
return depth_km_loop
|
258
168
|
|
259
169
|
|
260
|
-
def convert_pressure_depth_3step(P_kbar=None, d1=5, d2=14,
|
261
|
-
rho1=2700, rho2=3000, rho3=3100):
|
170
|
+
def convert_pressure_depth_3step(P_kbar=None, d1=5, d2=14,
|
171
|
+
rho1=2700, rho2=3000, rho3=3100, g=9.81):
|
262
172
|
""" Converts Pressure to depth using a 3 step profile for int or float
|
263
173
|
|
264
174
|
Parameters
|
@@ -282,9 +192,6 @@ def convert_pressure_depth_3step(P_kbar=None, d1=5, d2=14, g=9.81,
|
|
282
192
|
rho3: int or float
|
283
193
|
Density (kg/m3) below 2nd step transition
|
284
194
|
|
285
|
-
g: float
|
286
|
-
gravitational constant
|
287
|
-
|
288
195
|
Returns
|
289
196
|
-------------
|
290
197
|
float
|
@@ -313,11 +220,11 @@ def convert_pressure_depth_3step(P_kbar=None, d1=5, d2=14, g=9.81,
|
|
313
220
|
depth_km_bm=10**(-3)*((P_belowstep2*100000000)/(g*rho3))
|
314
221
|
depth_km=d2+depth_km_bm
|
315
222
|
|
316
|
-
if np.isnan(P_kbar):
|
317
|
-
depth_km=np.nan
|
318
|
-
|
319
223
|
return depth_km
|
320
224
|
|
225
|
+
|
226
|
+
|
227
|
+
|
321
228
|
def loop_pressure_depth_3step(P_kbar=None, d1=5, d2=14,
|
322
229
|
rho1=2700, rho2=3000, rho3=3100, g=9.81):
|
323
230
|
|
@@ -350,23 +257,145 @@ def loop_pressure_depth_3step(P_kbar=None, d1=5, d2=14,
|
|
350
257
|
Depth in km
|
351
258
|
|
352
259
|
"""
|
353
|
-
if
|
354
|
-
depth_km_loop=convert_pressure_depth_3step(P_kbar,
|
355
|
-
d1=d1, rho1=rho1, rho2=rho2, g=g)
|
260
|
+
if np.isscalar(P_kbar):
|
261
|
+
depth_km_loop=convert_pressure_depth_3step(P_kbar=P_kbar,
|
262
|
+
d1=d1, d2=d2,rho1=rho1, rho2=rho2, rho3=rho3, g=g)
|
356
263
|
else:
|
357
264
|
|
358
|
-
depth_km_loop=np.
|
265
|
+
depth_km_loop=np.empty(len(P_kbar))
|
359
266
|
for i in range(0, len(P_kbar)):
|
360
|
-
depth_km_loop[i]=convert_pressure_depth_3step(P_kbar[i],
|
267
|
+
depth_km_loop[i]=convert_pressure_depth_3step(P_kbar=P_kbar[i],
|
361
268
|
d1=d1, d2=d2,rho1=rho1, rho2=rho2, rho3=rho3, g=g)
|
362
269
|
return depth_km_loop
|
363
270
|
|
271
|
+
########## Same for 4 step
|
272
|
+
|
273
|
+
def convert_pressure_depth_4step(*, P_kbar=None, d1=None, d2=None, d3=None,
|
274
|
+
rho1=None, rho2=None, rho3=None, rho4=None, g=9.81):
|
275
|
+
""" Converts Pressure to depth using a 3 step profile for int or float
|
364
276
|
|
277
|
+
Parameters
|
278
|
+
--------------
|
279
|
+
P_kbar: int or float
|
280
|
+
Pressure in kbar
|
281
|
+
|
282
|
+
d1: int or float
|
283
|
+
depth in km of 1st step transition in density from the surface
|
365
284
|
|
366
|
-
|
367
|
-
|
285
|
+
d2: int or float
|
286
|
+
depth in km of 2nd step transition in density from the surface
|
287
|
+
|
288
|
+
d3: int or float
|
289
|
+
depth in km of 3rd step transition in density from the surface
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
rho1: int or float
|
295
|
+
Density (kg/m3) down to first step transition
|
296
|
+
|
297
|
+
rho2: int or float
|
298
|
+
Density (kg/m3) between first and second step transition
|
299
|
+
|
300
|
+
rho3: int or float
|
301
|
+
Density (kg/m3) below 2nd step transition
|
302
|
+
|
303
|
+
rho4: int or float
|
304
|
+
Density (kg/m3) below 3rd step transition
|
305
|
+
|
306
|
+
Returns
|
307
|
+
-------------
|
308
|
+
float
|
309
|
+
Depth in km
|
310
|
+
|
311
|
+
"""
|
312
|
+
|
313
|
+
d1_SI=d1*1000
|
314
|
+
d2_SI=d2*1000
|
315
|
+
d3_SI=d3*1000
|
316
|
+
P_Step1=(g*rho1*d1_SI)/100000000 # Convert to kbar
|
317
|
+
P_Step2=P_Step1+(g*(d2_SI-d1_SI)*rho2)/100000000 # Pressure contribution from step 2
|
318
|
+
P_Step3=P_Step2+(g*(d3_SI-d2_SI)*rho3)/100000000
|
319
|
+
|
320
|
+
# If the pressure is less than Step 1, easy math, just use Rho1
|
321
|
+
if P_kbar<P_Step1:
|
322
|
+
depth_km=10**(-3)*((P_kbar*100000000))/(g*rho1)
|
323
|
+
|
324
|
+
# If the pressure is between step 1 and step 2, First, take away the pressure of step 1, then solve for height in layer 2
|
325
|
+
if P_kbar>=P_Step1 and P_kbar<P_Step2:
|
326
|
+
P_belowStep2=P_kbar-P_Step1
|
327
|
+
# print('P below Moho')
|
328
|
+
# print(P_belowMoho)
|
329
|
+
depth_km_bm=10**(-3)*((P_belowStep2*100000000)/(g*rho2))
|
330
|
+
depth_km=d1+depth_km_bm
|
331
|
+
|
332
|
+
# If the pressure is between step 2 and 3, take away the pressure of step2, and calculate the height within layer 3
|
333
|
+
if P_kbar>=P_Step2 and P_kbar<P_Step3:
|
334
|
+
P_belowstep2=P_kbar-P_Step2
|
335
|
+
# print('P below Moho')
|
336
|
+
# print(P_belowMoho)
|
337
|
+
depth_km_bm=10**(-3)*((P_belowstep2*100000000)/(g*rho3))
|
338
|
+
depth_km=d2+depth_km_bm
|
339
|
+
|
340
|
+
# If the pressure is greater than that at the base of layer 3, take away the pressure of step3, and calculate the height within layer 4
|
341
|
+
if P_kbar>=P_Step3:
|
342
|
+
P_belowstep3=P_kbar-P_Step3
|
343
|
+
# print('P below Moho')
|
344
|
+
# print(P_belowMoho)
|
345
|
+
depth_km_bm=10**(-3)*((P_belowstep3*100000000)/(g*rho4))
|
346
|
+
depth_km=d3+depth_km_bm
|
347
|
+
|
348
|
+
return depth_km
|
349
|
+
|
350
|
+
def loop_pressure_depth_4step(*, P_kbar=None, d1=5, d2=14, d3=20,
|
351
|
+
rho1=2700, rho2=3000, rho3=3100, rho4=4000, g=9.81):
|
352
|
+
|
353
|
+
""" Converts Pressure to depth using a 3 step profile for pd.Series
|
354
|
+
|
355
|
+
Parameters
|
356
|
+
--------------
|
357
|
+
P_kbar: pd.Series
|
358
|
+
Pressure in kbar
|
359
|
+
|
360
|
+
d1: int or float
|
361
|
+
depth in km of 1st step transition in density
|
362
|
+
|
363
|
+
d2: int or float
|
364
|
+
depth in km of 2nd step transition in density
|
365
|
+
|
366
|
+
rho1: int or float
|
367
|
+
Density (kg/m3) down to first step transition
|
368
|
+
|
369
|
+
rho2: int or float
|
370
|
+
Density (kg/m3) between first and second step transition
|
371
|
+
|
372
|
+
|
373
|
+
rho3: int or float
|
374
|
+
Density (kg/m3) below 2nd step transition
|
375
|
+
|
376
|
+
Returns
|
377
|
+
-------------
|
378
|
+
pd.Series
|
379
|
+
Depth in km
|
380
|
+
|
381
|
+
"""
|
382
|
+
if np.isscalar(P_kbar):
|
383
|
+
depth_km_loop=convert_pressure_depth_4step(P_kbar=P_kbar,
|
384
|
+
d1=d1, d2=d2, d3=d3, rho1=rho1, rho2=rho2, rho3=rho3, rho4=rho4, g=g)
|
385
|
+
else:
|
386
|
+
|
387
|
+
depth_km_loop=np.empty(len(P_kbar))
|
388
|
+
for i in range(0, len(P_kbar)):
|
389
|
+
depth_km_loop[i]=convert_pressure_depth_4step(P_kbar=P_kbar[i],
|
390
|
+
d1=d1, d2=d2, d3=d3, rho1=rho1, rho2=rho2, rho3=rho3, rho4=rho4, g=g)
|
391
|
+
return depth_km_loop
|
392
|
+
|
393
|
+
#######3
|
394
|
+
|
395
|
+
|
396
|
+
def convert_pressure_to_depth(*, P_kbar=None, crust_dens_kgm3=None, g=9.81,
|
397
|
+
d1=None, d2=None, d3=None, rho1=None, rho2=None, rho3=None, rho4=None, model=None):
|
368
398
|
""" Converts pressure in kbar to depth in km using a variety of crustal density profiles
|
369
|
-
or existing models for Pressure vs. depth
|
370
399
|
|
371
400
|
|
372
401
|
Parameters
|
@@ -378,14 +407,10 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
378
407
|
g: float
|
379
408
|
gravitational constant, in m/s2
|
380
409
|
|
381
|
-
Choose from:
|
382
|
-
|
383
410
|
crust_dens_kgm3: float or str
|
384
|
-
Crustal density in kg/m3
|
411
|
+
If float: Crustal density in kg/m3
|
385
412
|
|
386
|
-
|
387
|
-
|
388
|
-
model, choose from:
|
413
|
+
If model, choose from:
|
389
414
|
|
390
415
|
ryan_lerner:
|
391
416
|
Parameterization of Ryan 1987, actual equation from Lerner et al. 2021
|
@@ -395,7 +420,6 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
395
420
|
Parameterization of Denlinger and Flinders (2022) with the addition of 200 kg/m3 at shallow depths, from Lerner et al. (2024).
|
396
421
|
After 15 km returns NaN following Lerner
|
397
422
|
|
398
|
-
|
399
423
|
mavko_debari:
|
400
424
|
Parameterization of Mavko and Thompson (1983) and DeBari and Greene (2011)
|
401
425
|
as given in Putirka (2017) Down the Crater Elements supplement.
|
@@ -414,21 +438,22 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
414
438
|
overall best fit density vs. depth
|
415
439
|
|
416
440
|
two-step:
|
417
|
-
If two step, must also define
|
418
|
-
d1: Depth to first transition in km
|
419
|
-
rho1: Density between surface and 1st transition
|
420
|
-
d2: Depth to second transition in km (from surface)
|
421
|
-
rho2: Density between 1st and 2nd transition
|
441
|
+
If two step, must also define d1 (depth to 1st step), rho1 (density to 1st step), rho2 (density to 2nd step)
|
422
442
|
|
423
443
|
three-step:
|
424
|
-
If three step, must also define
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
444
|
+
If three step, must also define d1 (depth to 1st step), d2 (depth to second step), rho1 (density to 1st step), rho2 (density to 2nd step),
|
445
|
+
rho3 (density after 3rd step) in km and kg/m3 respectively.
|
446
|
+
|
447
|
+
|
448
|
+
four-step:
|
449
|
+
If four step, must also define d1 (depth to 1st step from surface), d2 (depth to second step from surface), d3 (depth to 3rd step from surface) rho1 (density to 1st step), rho2 (density to 2nd step),
|
450
|
+
rho3 (density to 3rd step), and rho4 (density below 3rd step) in km and kg/m3 respectively.
|
451
|
+
|
452
|
+
OR
|
453
|
+
|
454
|
+
|
431
455
|
|
456
|
+
Else, just enter a crustal density in kg/m3, e.g., model=2700
|
432
457
|
|
433
458
|
|
434
459
|
|
@@ -441,48 +466,49 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
441
466
|
|
442
467
|
|
443
468
|
# Check, is it an integer, If so just calculate depth
|
469
|
+
if type(crust_dens_kgm3)==int or type(crust_dens_kgm3)==float:
|
470
|
+
D=10**5*P_kbar/(g*crust_dens_kgm3)
|
471
|
+
model=None
|
444
472
|
|
445
|
-
if isinstance(crust_dens_kgm3, str):
|
446
|
-
raise TypeError('Do not enter a string for crustal density, put it as a model instead')
|
447
473
|
|
448
|
-
|
449
|
-
if
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
# Now check, is it a series of strings, or
|
458
|
-
if type(crust_dens_kgm3[0])==str:
|
459
|
-
model=crust_dens_kgm3.iloc[0]
|
460
|
-
else:
|
461
|
-
model=None
|
462
|
-
D=10**5*P_kbar/(9.81*crust_dens_kgm3)
|
474
|
+
else:
|
475
|
+
# Check if its a pandas series.
|
476
|
+
if isinstance(crust_dens_kgm3, pd.Series):
|
477
|
+
# Now check, is it a series of strings, or
|
478
|
+
if type(crust_dens_kgm3[0])==str:
|
479
|
+
model=crust_dens_kgm3.iloc[0]
|
480
|
+
else:
|
481
|
+
model=None
|
482
|
+
D=10**5*P_kbar/(g*crust_dens_kgm3)
|
463
483
|
|
464
|
-
|
465
|
-
|
466
|
-
|
484
|
+
# Check if its just a single string
|
485
|
+
elif type(crust_dens_kgm3)==str:
|
486
|
+
model=crust_dens_kgm3
|
467
487
|
|
468
488
|
|
469
489
|
|
470
|
-
|
490
|
+
if model is not None:
|
471
491
|
if model == "two-step":
|
472
|
-
|
473
492
|
if d1 is None or rho1 is None or rho2 is None:
|
474
493
|
raise Exception('You have selected the two-step model, You must enter d1 (km), rho1 and rho2 (kg/m3)')
|
475
494
|
D=loop_pressure_depth_2step(P_kbar=P_kbar,
|
476
|
-
d1=d1, rho1=rho1, rho2=rho2)
|
495
|
+
d1=d1, rho1=rho1, rho2=rho2, g=g)
|
477
496
|
|
478
497
|
if model == "three-step":
|
479
498
|
if d1 is None or d2 is None or rho1 is None or rho2 is None or rho3 is None:
|
480
|
-
raise Exception('You have selected the
|
499
|
+
raise Exception('You have selected the two-step model, You must enter d1 and d2 (km), rho1, rho2 and rho3 (kg/m3)')
|
481
500
|
|
482
501
|
D=loop_pressure_depth_3step(P_kbar=P_kbar,
|
483
|
-
d1=d1, d2=d2, rho1=rho1, rho2=rho2, rho3=rho3)
|
502
|
+
d1=d1, d2=d2, rho1=rho1, rho2=rho2, rho3=rho3, g=g)
|
484
503
|
|
485
|
-
if model
|
504
|
+
if model == "four-step":
|
505
|
+
if d1 is None or d2 is None or d3 is None or rho1 is None or rho2 is None or rho3 is None or rho4 is None:
|
506
|
+
raise Exception('You have selected the two-step model, You must enter d1 and d2 (km), rho1, rho2 and rho3 (kg/m3)')
|
507
|
+
|
508
|
+
D=loop_pressure_depth_4step(P_kbar=P_kbar,
|
509
|
+
d1=d1, d2=d2, d3=d3, rho1=rho1, rho2=rho2, rho3=rho3, rho4=rho4, g=g)
|
510
|
+
|
511
|
+
if model !="two-step" and model != "three-step" and model != "four-step":
|
486
512
|
try:
|
487
513
|
|
488
514
|
func = Profile_funcs_by_name[model]
|
@@ -495,27 +521,23 @@ d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
|
|
495
521
|
D=func(P_kbar)
|
496
522
|
|
497
523
|
if isinstance(P_kbar, pd.Series):
|
498
|
-
D=np.
|
524
|
+
D=np.empty(len(P_kbar), float)
|
499
525
|
for i in range(0, len(P_kbar)):
|
500
526
|
D[i]=func(P_kbar.iloc[i])
|
501
527
|
|
502
528
|
if isinstance(P_kbar, np.ndarray):
|
503
|
-
D=np.
|
529
|
+
D=np.empty(len(P_kbar), float)
|
504
530
|
for i in range(0, len(P_kbar)):
|
505
531
|
D[i]=func(P_kbar[i])
|
506
532
|
|
507
|
-
|
508
|
-
raise TypeError('You need to either enter a model, or a value for crust_dens_kgm3' )
|
533
|
+
|
509
534
|
|
510
535
|
|
511
536
|
D_series=pd.Series(D)
|
512
537
|
|
513
|
-
if g != 9.81:
|
514
|
-
print('You specified a g that wasnt 9.81, ive adjusted the profiles accordingly')
|
515
|
-
D_series=D_series*(9.81/g)
|
516
538
|
|
517
|
-
return D_series
|
518
539
|
|
540
|
+
return D_series
|
519
541
|
|
520
542
|
|
521
543
|
|
@@ -629,4 +651,4 @@ def convert_co2_dens_press_depth_old(T_K=None,
|
|
629
651
|
|
630
652
|
df.replace([np.inf, -np.inf], np.nan, inplace=True)
|
631
653
|
|
632
|
-
return df
|
654
|
+
return df
|
DiadFit/diads.py
CHANGED
@@ -7,6 +7,7 @@ from lmfit.models import GaussianModel, VoigtModel, LinearModel, ConstantModel,
|
|
7
7
|
from scipy.signal import find_peaks
|
8
8
|
from scipy.signal.windows import gaussian
|
9
9
|
|
10
|
+
|
10
11
|
import os
|
11
12
|
import re
|
12
13
|
from os import listdir
|
@@ -21,6 +22,7 @@ from scipy.integrate import trapezoid
|
|
21
22
|
from scipy.integrate import simpson
|
22
23
|
from scipy.interpolate import interp1d
|
23
24
|
|
25
|
+
|
24
26
|
# Allowed models
|
25
27
|
|
26
28
|
allowed_models = ["VoigtModel", "PseudoVoigtModel", "Pearson4Model", "SkewedVoigtModel"]
|
@@ -2549,7 +2551,7 @@ def fit_gaussian_voigt_generic_diad(config1, *, diad1=False, diad2=False, path=N
|
|
2549
2551
|
# Final check - that Gaussian isnt anywhere near the height of the diad
|
2550
2552
|
|
2551
2553
|
|
2552
|
-
df_out=df_out.fillna(0)
|
2554
|
+
df_out=df_out.fillna(0).infer_objects()
|
2553
2555
|
|
2554
2556
|
return result, df_out, y_best_fit, x_lin, components, xdat, ydat, ax1_xlim, ax2_xlim, residual_diad_coords, ydat_inrange, xdat_inrange
|
2555
2557
|
|
@@ -5006,4 +5008,12 @@ config_diad1: diad1_fit_config=diad1_fit_config(), config_diad2: diad2_fit_confi
|
|
5006
5008
|
|
5007
5009
|
|
5008
5010
|
|
5011
|
+
## Give nice column names
|
5012
|
+
|
5013
|
+
|
5014
|
+
|
5015
|
+
|
5016
|
+
|
5017
|
+
|
5018
|
+
|
5009
5019
|
|
DiadFit/error_propagation.py
CHANGED
@@ -109,7 +109,7 @@ def propagate_microthermometry_uncertainty(T_h_C, Sample_ID=None, error_T_h_C=0
|
|
109
109
|
else:
|
110
110
|
Sample[i]=Sample_ID.iloc[i]
|
111
111
|
|
112
|
-
Temp_MC= add_noise_to_variable(
|
112
|
+
Temp_MC= add_noise_to_variable(T_h_C_i, error_T_h_C_i,
|
113
113
|
error_type_T_h_C, error_dist_T_h_C, N_dup, True, neg_threshold=0.0000000001)
|
114
114
|
|
115
115
|
Sample2=Sample[i]
|