DiadFit 1.0.5__tar.gz → 1.0.9__tar.gz

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.
Files changed (56) hide show
  1. {DiadFit-1.0.5 → DiadFit-1.0.9}/PKG-INFO +1 -1
  2. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/CO2_EOS.py +7 -1
  3. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/_version.py +1 -1
  4. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/densimeter_fitting.py +1 -0
  5. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/densimeters.py +1 -1
  6. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/density_depth_crustal_profiles.py +197 -175
  7. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/diads.py +8 -47
  8. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/error_propagation.py +1 -1
  9. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/importing_data_files.py +152 -0
  10. DiadFit-1.0.9/src/DiadFit/molar_gas_proportions.py +231 -0
  11. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/ne_lines.py +5 -0
  12. DiadFit-1.0.5/src/DiadFit/relaxifi.py → DiadFit-1.0.9/src/DiadFit/relaxfi_PW.py +2 -0
  13. DiadFit-1.0.9/src/DiadFit/relaxifi.py +761 -0
  14. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit.egg-info/PKG-INFO +1 -1
  15. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit.egg-info/SOURCES.txt +1 -0
  16. DiadFit-1.0.5/src/DiadFit/molar_gas_proportions.py +0 -87
  17. {DiadFit-1.0.5 → DiadFit-1.0.9}/README.md +0 -0
  18. {DiadFit-1.0.5 → DiadFit-1.0.9}/setup.cfg +0 -0
  19. {DiadFit-1.0.5 → DiadFit-1.0.9}/setup.py +0 -0
  20. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/CO2_in_bubble_error.py +0 -0
  21. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/H2O_fitting.py +0 -0
  22. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data.pkl +0 -0
  23. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  24. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  25. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  26. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  27. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  28. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data_CCMR.pkl +0 -0
  29. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data_CMASS.pkl +0 -0
  30. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Highrho_polyfit_data_CMASS_24C.pkl +0 -0
  31. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data.pkl +0 -0
  32. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  33. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  34. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  35. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  36. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  37. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data_CCMR.pkl +0 -0
  38. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data_CMASS.pkl +0 -0
  39. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Lowrho_polyfit_data_CMASS_24C.pkl +0 -0
  40. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_data.pkl +0 -0
  41. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1117_1400.pkl +0 -0
  42. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1117_1447.pkl +0 -0
  43. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1400.pkl +0 -0
  44. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1447.pkl +0 -0
  45. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_dataUCB_1220_1567.pkl +0 -0
  46. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_data_CCMR.pkl +0 -0
  47. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Mediumrho_polyfit_data_CMASS.pkl +0 -0
  48. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/Psensor.py +0 -0
  49. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/__init__.py +0 -0
  50. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/argon_lines.py +0 -0
  51. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/cosmicray_filter.py +0 -0
  52. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/lookup_table.csv +0 -0
  53. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit/lookup_table_noneg.csv +0 -0
  54. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit.egg-info/dependency_links.txt +0 -0
  55. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit.egg-info/requires.txt +0 -0
  56. {DiadFit-1.0.5 → DiadFit-1.0.9}/src/DiadFit.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiadFit
3
- Version: 1.0.5
3
+ Version: 1.0.9
4
4
  Summary: DiadFit
5
5
  Home-page: https://github.com/PennyWieser/DiadFit
6
6
  Author: Penny Wieser
@@ -12,6 +12,9 @@ import pickle
12
12
  import math
13
13
  DiadFit_dir=Path(__file__).parent
14
14
 
15
+ ## Visualizing coexisting phases
16
+
17
+
15
18
 
16
19
 
17
20
  ## Calculating density for a given homogenization temp - Only available with Span and Wanger, but have equations
@@ -70,7 +73,7 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
70
73
  elif isinstance(T_h_C, np.ndarray):
71
74
 
72
75
  T_h_C[T_h_C > 30.9782] = 30.9782
73
- print('got into this loop')
76
+
74
77
 
75
78
 
76
79
 
@@ -167,6 +170,9 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
167
170
 
168
171
 
169
172
 
173
+
174
+
175
+
170
176
  return df
171
177
 
172
178
 
@@ -5,4 +5,4 @@
5
5
  # 1) we don't load dependencies by storing it in __init__.py
6
6
  # 2) we can import it in setup.py for the same reason
7
7
  # 3) we can import it into your module
8
- __version__ = '1.0.5'
8
+ __version__ = '1.0.9'
@@ -15,6 +15,7 @@ from scipy import stats
15
15
 
16
16
  encode="ISO-8859-1"
17
17
 
18
+ ## Files are fit using the folder UCB_cali_fitting_1117_1447
18
19
 
19
20
  def calculate_generic_std_err_values(*, pickle_str, new_x, CI=0.67):
20
21
 
@@ -994,7 +994,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
994
994
  corrected_split: pd.Series
995
995
  Corrected splitting (cm-1)
996
996
 
997
- Split_err: float, int
997
+ split_err: float, int
998
998
  Error on corrected splitting
999
999
 
1000
1000
  temp: str
@@ -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
- """ Calculates Depth for a given pressure using a 4th degree fit to the supporting information of Rasmussen et al. 2022,
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
- """Calculates Depth for a given pressure using the parameterization of Hill and Zucca (1987),
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
- """ Calculates depth for a given pressure using the Parameterization of Ryan 1987, actual equation from Lerner et al. 2021
58
- After 16.88 km (455 MPa), returns NaN
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
- """ Calculates depth for a given pressure using the parameterization of Mavko and Thompson (1983) and DeBari and Greene (2011)
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
- """Calculates depth for a given pressure using the parameterization of Prezzi et al. (2009),
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, denlinger_lerner, mavko_debari, hill_zucca, prezzi, rasmussen}
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 type(P_kbar) is int or type(P_kbar) is float:
250
- depth_km_loop=convert_pressure_depth_2step(P_kbar,
251
- d1=d1, rho1=rho1, rho2=rho2, g=g)
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.zeros(len(P_kbar))
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, g=9.81,
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 type(P_kbar) is int or type(P_kbar) is float:
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.zeros(len(P_kbar))
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
- def convert_pressure_to_depth(P_kbar=None, crust_dens_kgm3=None, g=9.81,
367
- d1=None, d2=None,rho1=None, rho2=None, rho3=None, model=None):
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
- OR
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
- d1: Depth to first transition in km
426
- rho1: Density between surface and 1st transition
427
- d2: Depth to second transition in km (from surface)
428
- rho2: Density between 1st and 2nd transition
429
- d3: Depth to third transition in km (from surface)
430
- rho3: Density between 2nd and 3rd transition depth.
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
- if crust_dens_kgm3 is not None:
449
- if type(crust_dens_kgm3)==int or type(crust_dens_kgm3)==float:
450
- D=10**5*P_kbar/(9.81*crust_dens_kgm3)
451
- model=None
452
-
453
-
454
- else:
455
- # Check if its a pandas series.
456
- if isinstance(crust_dens_kgm3, pd.Series):
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
- # Check if its just a single string
465
- elif type(crust_dens_kgm3)==str:
466
- model=crust_dens_kgm3
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
- elif model is not None:
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 three-step model, You must enter d1 and d2 (km), rho1, rho2 and rho3 (kg/m3)')
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 !="two-step" and model != "three-step":
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.zeros(len(P_kbar), float)
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.zeros(len(P_kbar), float)
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
- else:
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
@@ -33,54 +33,7 @@ allowed_models = ["VoigtModel", "PseudoVoigtModel", "Pearson4Model", "SkewedVoig
33
33
  #warnings.simplefilter('error')
34
34
 
35
35
  encode="ISO-8859-1"
36
- ## Ratio of different peaks
37
36
 
38
-
39
- def calculate_SO2_CO2_ratio(SO2_area, diad1_area, diad2_area, SO2_cross_sec=5.3, diad1_cross_sec=0.89, diad2_cross_sec=1.4):
40
- """ Calculates SO2:CO2 ratio using the parameters from Marie-Camille Caumons lab"""
41
-
42
-
43
- A_CO2_star=( diad1_area + diad2_area)/(diad2_cross_sec+diad1_cross_sec)
44
- A_SO2_star=(SO2_area)/(SO2_cross_sec)
45
- Ratio=A_SO2_star/(A_SO2_star+A_CO2_star)
46
-
47
- return Ratio
48
-
49
- def calculate_mole_fraction_2comp(peak_area_a, peak_area_b, cross_section_a, cross_section_b, instrument_eff_a, instrument_eff_b):
50
- """ This function calculates the molar ration of 2 components a and b based on peak areas,
51
- cross section and instrument efficiency
52
-
53
- Parameters
54
- ------------
55
-
56
- peak_area_a: int, float, pd.Series, np.array
57
- Peak area of component a
58
-
59
- peak_area_b: int, float, pd.Series, np.array
60
- Peak area of component b
61
-
62
- cross_section_a, cross_section_a: int, float
63
- Raman cross section for component a and b
64
-
65
- instrument_eff_a, instrument_eff_b: int, float
66
- Instrument effeciency of a and b.
67
-
68
- Returns
69
- ------------
70
- pd.DataFrame
71
- Molar ratio of a/b
72
-
73
-
74
- """
75
-
76
- Sum_phase_a=peak_area_a/(cross_section_a*instrument_eff_a)
77
- Sum_phase_b=peak_area_b/(cross_section_b*instrument_eff_b)
78
-
79
- df=pd.DataFrame(data={'% A': 100*Sum_phase_a/(Sum_phase_b+Sum_phase_a),
80
- '% B': 100-100*Sum_phase_a/(Sum_phase_b+Sum_phase_a)}
81
- )
82
-
83
- return df
84
37
  def plot_diad(*,path=None, filename=None, filetype='Witec_ASCII', Spectra_x=None, Spectra_y=None):
85
38
  """This function makes a plot of the spectra for a specific file to allow visual inspectoin
86
39
 
@@ -5008,4 +4961,12 @@ config_diad1: diad1_fit_config=diad1_fit_config(), config_diad2: diad2_fit_confi
5008
4961
 
5009
4962
 
5010
4963
 
4964
+ ## Give nice column names
4965
+
4966
+
4967
+
4968
+
4969
+
4970
+
4971
+
5011
4972