DiadFit 0.0.79__py3-none-any.whl → 0.0.81__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_H2O_EOS.py CHANGED
@@ -10,6 +10,7 @@ from pathlib import Path
10
10
  from pickle import load
11
11
  import pickle
12
12
  import math
13
+ from DiadFit.CO2_EOS import *
13
14
 
14
15
 
15
16
  DiadFit_dir=Path(__file__).parent
@@ -101,7 +102,107 @@ aH2[13] = -4.13039220 / 10**1 # alpha for CO2
101
102
  aH2[14] = -8.47988634 # beta for CO2
102
103
  aH2[15] = 2.800 / 10**2 # gamma for CO2
103
104
 
105
+ ## This is for when you only feed a numpy array
106
+ # def ensure_series(a, b, c):
107
+ # # Determine the target length
108
+ # lengths = [len(a) if isinstance(a, pd.Series) else None,
109
+ # len(b) if isinstance(b, pd.Series) else None,
110
+ # len(c) if isinstance(c, pd.Series) else None]
111
+ # lengths = [l for l in lengths if l is not None]
112
+ # target_length = max(lengths) if lengths else 1
113
+ #
114
+ # # Convert each input to a Series of the target length
115
+ # if not isinstance(a, pd.Series):
116
+ # a = pd.Series([a] * target_length)
117
+ # if not isinstance(b, pd.Series):
118
+ # b = pd.Series([b] * target_length)
119
+ # if not isinstance(c, pd.Series):
120
+ # c = pd.Series([c] * target_length)
121
+ #
122
+ # return a, b, c
123
+ #
124
+ #
125
+ # def ensure_series_4(a, b, c, d):
126
+ # # Determine the target length
127
+ # lengths = [len(a) if isinstance(a, pd.Series) else None,
128
+ # len(b) if isinstance(b, pd.Series) else None,
129
+ # len(c) if isinstance(c, pd.Series) else None,
130
+ # len(d) if isinstance(d, pd.Series) else None]
131
+ # lengths = [l for l in lengths if l is not None]
132
+ # target_length = max(lengths) if lengths else 1
133
+ #
134
+ # # Convert each input to a Series of the target length
135
+ # if not isinstance(a, pd.Series):
136
+ # a = pd.Series([a] * target_length)
137
+ # if not isinstance(b, pd.Series):
138
+ # b = pd.Series([b] * target_length)
139
+ # if not isinstance(c, pd.Series):
140
+ # c = pd.Series([c] * target_length)
141
+ # if not isinstance(d, pd.Series):
142
+ # d = pd.Series([d] * target_length)
143
+ # return a, b, c, d
104
144
 
145
+ import pandas as pd
146
+ import numpy as np
147
+
148
+ def ensure_series(a, b, c):
149
+ # Determine the target length
150
+ lengths = [len(a) if isinstance(a, (pd.Series, np.ndarray)) else None,
151
+ len(b) if isinstance(b, (pd.Series, np.ndarray)) else None,
152
+ len(c) if isinstance(c, (pd.Series, np.ndarray)) else None]
153
+ lengths = [l for l in lengths if l is not None]
154
+ target_length = max(lengths) if lengths else 1
155
+
156
+ # Convert each input to a Series of the target length
157
+ if not isinstance(a, (pd.Series, np.ndarray)):
158
+ a = pd.Series([a] * target_length)
159
+ else:
160
+ a = pd.Series(a)
161
+
162
+ if not isinstance(b, (pd.Series, np.ndarray)):
163
+ b = pd.Series([b] * target_length)
164
+ else:
165
+ b = pd.Series(b)
166
+
167
+ if not isinstance(c, (pd.Series, np.ndarray)):
168
+ c = pd.Series([c] * target_length)
169
+ else:
170
+ c = pd.Series(c)
171
+
172
+ return a, b, c
173
+
174
+
175
+ def ensure_series_4(a, b, c, d):
176
+ # Determine the target length
177
+ lengths = [len(a) if isinstance(a, (pd.Series, np.ndarray)) else None,
178
+ len(b) if isinstance(b, (pd.Series, np.ndarray)) else None,
179
+ len(c) if isinstance(c, (pd.Series, np.ndarray)) else None,
180
+ len(d) if isinstance(d, (pd.Series, np.ndarray)) else None]
181
+ lengths = [l for l in lengths if l is not None]
182
+ target_length = max(lengths) if lengths else 1
183
+
184
+ # Convert each input to a Series of the target length
185
+ if not isinstance(a, (pd.Series, np.ndarray)):
186
+ a = pd.Series([a] * target_length)
187
+ else:
188
+ a = pd.Series(a)
189
+
190
+ if not isinstance(b, (pd.Series, np.ndarray)):
191
+ b = pd.Series([b] * target_length)
192
+ else:
193
+ b = pd.Series(b)
194
+
195
+ if not isinstance(c, (pd.Series, np.ndarray)):
196
+ c = pd.Series([c] * target_length)
197
+ else:
198
+ c = pd.Series(c)
199
+
200
+ if not isinstance(d, (pd.Series, np.ndarray)):
201
+ d = pd.Series([d] * target_length)
202
+ else:
203
+ d = pd.Series(d)
204
+
205
+ return a, b, c, d
105
206
 
106
207
 
107
208
 
@@ -178,7 +279,7 @@ def purevolume(i, V, P, B, C, D, E, F, Vc, TK, b, g):
178
279
  # Return the final estimated volume
179
280
  return V
180
281
 
181
- def purepressure(i, V, P, B, C, D, E, F, Vc, TK, b, g):
282
+ def purepressure(i, V, P, TK):
182
283
  """ Using the pure EOS, this function solves for the best pressure using the pureEOS residual calculated above
183
284
 
184
285
  It returns the pressure.
@@ -186,6 +287,8 @@ def purepressure(i, V, P, B, C, D, E, F, Vc, TK, b, g):
186
287
  """
187
288
  for iter in range(1, 51):
188
289
  # Calculate the derivative of the pureEOS function at (V, P)
290
+ k1_temperature, k2_temperature, k3_temperature, a1, a2, g, b, Vc, B, C, D, E, F, Vguess=get_EOS_params(P, TK)
291
+
189
292
  diff = (pureEOS(i, V, P + 0.0001, B, C, D, E, F, Vc, TK, b, g) - pureEOS(i, V, P, B, C, D, E, F, Vc, TK, b, g)) / 0.0001
190
293
 
191
294
  # Update the pressure using the Newton-Raphson method
@@ -201,6 +304,9 @@ def purepressure(i, V, P, B, C, D, E, F, Vc, TK, b, g):
201
304
  # Return the final estimated pressure
202
305
  return P
203
306
 
307
+
308
+
309
+
204
310
  def mol_vol_to_density(mol_vol, XH2O):
205
311
  """ Converts molar mass to molar density for a given XH2O"""
206
312
  density=((1-XH2O)*44 + (XH2O)*18)/mol_vol
@@ -265,11 +371,14 @@ def mixvolume(V, P, BVc, CVc2, DVc4, EVc5, FVc2, bmix, gVc2, TK):
265
371
 
266
372
  return V
267
373
 
268
- def mixpressure(V, P, BVc, CVc2, DVc4, EVc5, FVc2, bmix, gVc2, TK):
374
+ def mixpressure(P, V, TK, Y):
269
375
  """ This function iterates in pressure space to get the best match to the entered volume using the mixEOS function above.
270
376
 
271
377
  """
272
378
  for iter in range(1, 51):
379
+ k1_temperature, k2_temperature, k3_temperature, a1, a2, g, b, Vc, B, C, D, E, F, Vguess=get_EOS_params(P, TK)
380
+ Bij, Vcij, BVc_prm, BVc, Cijk, Vcijk, CVc2_prm, CVc2, Dijklm, Vcijklm, DVc4_prm, DVc4, Eijklmn, Vcijklmn, EVc5_prm, EVc5, Fij, FVc2_prm, FVc2, bmix, b_prm, gijk, gVc2_prm, gVc2=mixing_rules(B, C,D, E, F, Vc, Y, b, g, k1_temperature, k2_temperature, k3_temperature)
381
+
273
382
  diff = ((mixEOS(V, P + 0.0001, BVc, CVc2, DVc4, EVc5, FVc2, bmix, gVc2, TK)
274
383
  - mixEOS(V, P, BVc, CVc2, DVc4, EVc5, FVc2, bmix, gVc2, TK)) / 0.0001)
275
384
  Pnew = P - mixEOS(V, P, BVc, CVc2, DVc4, EVc5, FVc2, bmix, gVc2, TK) / diff
@@ -280,8 +389,10 @@ def mixpressure(V, P, BVc, CVc2, DVc4, EVc5, FVc2, bmix, gVc2, TK):
280
389
  return P
281
390
 
282
391
 
392
+
283
393
  def mix_lnphi(i, Zmix, BVc_prm, CVc2_prm, DVc4_prm, EVc5_prm, FVc2_prm, FVc2, bmix, b_prm, gVc2, gVc2_prm, Vmix):
284
394
  lnph=0
395
+
285
396
  lnph = -math.log(Zmix)
286
397
  lnph += (BVc_prm[i] / Vmix)
287
398
  lnph += (CVc2_prm[i] / (2.0 * Vmix ** 2))
@@ -735,13 +846,8 @@ def calculate_molar_volume_DZ2006(*, P_kbar, T_K, XH2O):
735
846
 
736
847
 
737
848
  """
738
- # Make all a panda series
739
- if not isinstance(P_kbar, pd.Series):
740
- P_kbar = pd.Series(P_kbar)
741
- if not isinstance(T_K, pd.Series):
742
- T_K = pd.Series(T_K)
743
- if not isinstance(XH2O, pd.Series):
744
- XH2O = pd.Series(XH2O)
849
+
850
+ P_kbar, T_K, XH2O=ensure_series(P_kbar, T_K, XH2O)
745
851
 
746
852
  # Check all the same length
747
853
  lengths = [len(P_kbar), len(T_K), len(XH2O)]
@@ -760,6 +866,67 @@ def calculate_molar_volume_DZ2006(*, P_kbar, T_K, XH2O):
760
866
 
761
867
  return mol_vol
762
868
 
869
+ def calculate_Pressure_ind_DZ2006(*, mol_vol, T_K, XH2O, Pguess=None):
870
+ """ This function calculates pressure for a known molar volume, T in K and XH2O (mol frac) for a single value
871
+ """
872
+ V=mol_vol
873
+ if Pguess is None:
874
+ if V>1000:
875
+ Pguess=1000
876
+ elif V<10:
877
+ Pguess=20000
878
+ else:
879
+ Pguess=200
880
+
881
+ TK=T_K
882
+
883
+ # lets do for low pressure initially
884
+
885
+
886
+ if XH2O==0:
887
+ P=purepressure(1, V, Pguess, TK)
888
+
889
+ elif XH2O==1:
890
+ P=purepressure(0, V, Pguess, TK)
891
+
892
+ else:
893
+ XCO2=1-XH2O
894
+ Y = [0] * 2
895
+ Y[0]=XH2O
896
+ Y[1]=XCO2
897
+
898
+ P=mixpressure(Pguess, V, T_K, Y)
899
+
900
+ return P
901
+
902
+ def calculate_Pressure_DZ2006(*, mol_vol=None, density=None, T_K, XH2O):
903
+ """ Used to calculate molar volume in a loop for multiple inputs
904
+
905
+
906
+ """
907
+ # Make all a panda series
908
+
909
+
910
+
911
+ if mol_vol is None and density is not None:
912
+ mol_vol=density_to_mol_vol(density=density, XH2O=XH2O)
913
+
914
+ mol_vol, T_K, XH2O=ensure_series(mol_vol, T_K, XH2O)
915
+
916
+ # Check all the same length
917
+ lengths = [len(mol_vol), len(T_K), len(XH2O)]
918
+ if len(set(lengths)) != 1:
919
+ raise ValueError("All input Pandas Series must have the same length.")
920
+
921
+ # Set up loop
922
+ P=np.empty(len(mol_vol), float)
923
+
924
+ for i in range(0, len(mol_vol)):
925
+ P[i]=calculate_Pressure_ind_DZ2006(mol_vol=mol_vol.iloc[i].astype(float), T_K=T_K.iloc[i].astype(float), XH2O=XH2O.iloc[i].astype(float))
926
+
927
+
928
+
929
+ return P
763
930
 
764
931
 
765
932
  def mix_fugacity(*, P_kbar, T_K, XH2O, Vmix):
@@ -768,14 +935,10 @@ def mix_fugacity(*, P_kbar, T_K, XH2O, Vmix):
768
935
 
769
936
  """
770
937
  # Make everything a pandas series
771
- if not isinstance(P_kbar, pd.Series):
772
- P_kbar = pd.Series(P_kbar)
773
- if not isinstance(T_K, pd.Series):
774
- T_K = pd.Series(T_K)
775
- if not isinstance(XH2O, pd.Series):
776
- XH2O = pd.Series(XH2O)
777
- if not isinstance(Vmix, pd.Series):
778
- Vmix = pd.Series(Vmix)
938
+
939
+ P_kbar, T_K, XH2O, Vmix=ensure_series_4(P_kbar, T_K, XH2O, Vmix)
940
+
941
+
779
942
 
780
943
  #Check all the same length
781
944
  lengths = [len(P_kbar), len(T_K), len(XH2O), len(Vmix)]
@@ -796,16 +959,44 @@ def mix_fugacity(*, P_kbar, T_K, XH2O, Vmix):
796
959
 
797
960
 
798
961
  def mol_vol_to_density(*, mol_vol, XH2O):
799
- """ Converts molar mass to molar density for a given XH2O"""
962
+ """ Converts molar mass to density for a given XH2O"""
800
963
  density=((1-XH2O)*44 + (XH2O)*18)/mol_vol
801
964
  return density
802
965
 
966
+ def density_to_mol_vol(*, density, XH2O):
967
+ """ Converts density in g/cm3 to molar volume for a given XH2O"""
968
+ mol_vol=((1-XH2O)*44 + (XH2O)*18)/density
969
+ return mol_vol
970
+
971
+
972
+
973
+ def calc_prop_knownP_EOS_DZ2006(*, P_kbar=1, T_K=1200, XH2O=1):
974
+ """ This function calculates molar volume, density, compressability factor, fugacity, and activity for mixed H2O-CO2 fluids
975
+ using the EOS of Span and Wanger. It assumes you know P, T, and XH2O.
976
+
977
+ Parameters
978
+ -------------------
979
+ P_kbar: float, np.array, pd.Series
980
+ Pressure in kbar
981
+ T_K: float, np.array, pd.Series
982
+ Temperature in Kelvin
983
+ XH2O: float, np.array, pd.Series
984
+ Molar fraction of H2O in the fluid phase.
985
+
986
+ Returns
987
+ -------------------
988
+ pd.DataFrame
989
+
990
+ """
991
+
803
992
 
804
993
 
994
+ # First, check all pd Series
995
+
805
996
 
806
- def H2O_CO2_EOS_DZ2006_knownP(*, P_kbar=1, T_K=1200, XH2O=1):
807
- """ Function to return a dataframe of outputs when you know P, T_K and XH2O"""
808
997
  mol_vol=calculate_molar_volume_DZ2006(P_kbar=P_kbar, T_K=T_K, XH2O=XH2O)
998
+
999
+
809
1000
  f_H2O, f_CO2, a_H2O, a_CO2, Zmix=mix_fugacity(P_kbar=P_kbar, T_K=T_K, XH2O=XH2O,
810
1001
  Vmix=mol_vol)
811
1002
  density=mol_vol_to_density(mol_vol=mol_vol, XH2O=XH2O)
@@ -831,6 +1022,62 @@ def H2O_CO2_EOS_DZ2006_knownP(*, P_kbar=1, T_K=1200, XH2O=1):
831
1022
 
832
1023
 
833
1024
 
1025
+ def calculate_entrapment_P_XH2O(*, XH2O, CO2_dens_gcm3, T_K):
1026
+ """" This function calculates pressure for a measured CO$_2$ density, temperature and estimate of initial XH2O.
1027
+ It first corrects the density to obtain a bulk density for a CO2-H2O mix, assuming that H2O was lost from the inclusion.
1028
+ correcting for XH2O. It assumes that H2O has been lost from the inclusion (see Hansteen and Klugel, 2008 for method). It also calculates using other
1029
+ pure CO2 equation of states for comparison
1030
+
1031
+ Parameters
1032
+ ----------------------
1033
+ XH2O: float, pd.Series.
1034
+ The molar fraction of H2O in the fluid. Should be between 0 and 1. Can get an estimate from say VESical.
1035
+
1036
+ CO2_dens_gcm3: float, pd.Series
1037
+ Measured CO2 density in g/cm3
1038
+
1039
+ T_K: float, pd.Series
1040
+ Temperature in Kelvin.
1041
+
1042
+ Returns
1043
+ -----------------------------
1044
+ pd.DataFrame:
1045
+ Columns showing:
1046
+ P_kbar_pureCO2_SW96: Pressure calculated for the measured CO$_2$ density using the pure CO2 EOS from Span and Wanger (1996)
1047
+ P_kbar_pureCO2_SP94: Pressure calculated for the measured CO$_2$ density using the pure CO2 EOS from Sterner and Pitzer (1994)
1048
+ P_kbar_pureCO2_DZ06: Pressure calculated from the measured CO$_2$ density using the pure CO2 EOs from Duan and Zhang (2006)
1049
+ P_kbar_mixCO2_DZ06: Pressure calculated from the reconstructed mixed fluid density using the mixed EOS from Duan and Zhang (2006)
1050
+ P Mix/P Pure DZ06: Correction factor - e.g. how much deeper the pressure is from the mixed EOS
1051
+ rho_mix_calc: Bulk density calculated (C+H) at time of entrapment
1052
+ CO2_dens_gcm3: Input CO2 density
1053
+ T_K: input temperature
1054
+ XH2O: input molar fraction of H2O
1055
+
1056
+ """
1057
+ XH2O, rho_meas, T_K=ensure_series(a=XH2O, b=CO2_dens_gcm3, c=T_K)
1058
+ alpha=XH2O/(1-XH2O)
1059
+ # This gets the bulk density of the CO2-H2O fluid
1060
+ rho_orig=rho_meas*(1+alpha*(18/44))
1061
+ # Lets calculate the pressure using SW96
1062
+ P_SW=calculate_P_for_rho_T(T_K=T_K, CO2_dens_gcm3=rho_meas, EOS='SW96')
1063
+ P_SP=calculate_P_for_rho_T(T_K=T_K, CO2_dens_gcm3=rho_meas, EOS='SP94')
1064
+ # Same for DZ2006
1065
+ P_DZ=calculate_Pressure_DZ2006(density=rho_meas, T_K=T_K, XH2O=XH2O*0)
1066
+ # Now doing it with XH2O
1067
+ P_DZ_mix=calculate_Pressure_DZ2006(density=rho_orig, T_K=T_K, XH2O=XH2O)
1068
+
1069
+ df=pd.DataFrame(data={
1070
+ 'P_kbar_pureCO2_SW96': P_SW['P_kbar'],
1071
+ 'P_kbar_pureCO2_SP94': P_SW['P_kbar'],
1072
+ 'P_kbar_pureCO2_DZ06': P_DZ/1000,
1073
+ 'P_kbar_mixCO2_DZ06': P_DZ_mix/1000,
1074
+ 'P Mix/P Pure DZ06': P_DZ_mix/P_DZ,
1075
+ 'rho_mix_calc': rho_orig,
1076
+ 'CO2_dens_gcm3': rho_meas,
1077
+ 'T_K': T_K,
1078
+ 'XH2O': XH2O})
1079
+
1080
+ return df
834
1081
 
835
1082
 
836
1083
 
DiadFit/H2O_fitting.py CHANGED
@@ -305,8 +305,8 @@ def make_evaluate_mixed_spectra(*, path, filename, smoothed_host_y, smoothed_MI_
305
305
  X_min=0, X_max=1, plot_figure=True, dpi=200):
306
306
 
307
307
  """
308
- This function unmixes glass and host spectra, and fits the best fit proportion
309
- where the host peak and trough disapears. Specifically, it calculates the mixed spectra by
308
+ This function unmixes glass and host spectra, and fits the best fit proportion
309
+ where the host peak and trough disapears. Specifically, it calculates the mixed spectra by
310
310
  taking the measured MI spectra and subtracting X*Ol spectra, where X is the mixing proportions
311
311
 
312
312
  Parameters
@@ -355,7 +355,7 @@ def make_evaluate_mixed_spectra(*, path, filename, smoothed_host_y, smoothed_MI_
355
355
  Dist: float
356
356
  Vertical distance between the host peak and trough (in intensity units)
357
357
  MI_Mix: np.array
358
- Umixed spectra for each of the N_steps
358
+ Ubmixed spectra for each of the N_steps
359
359
  X: np.array
360
360
  X coordinates of unmixed spectra (along with MI_Mix and X allows plots of unmixing)
361
361
 
@@ -428,7 +428,7 @@ def make_evaluate_mixed_spectra(*, path, filename, smoothed_host_y, smoothed_MI_
428
428
  ax3.set_xlim([775, 900])
429
429
 
430
430
 
431
- ax4.plot(MI_spectra[:, 0],MI_Mix_Best[:, 1], '-k', label='Umixed glass')
431
+ ax4.plot(MI_spectra[:, 0],MI_Mix_Best[:, 1], '-k', label='Unmixed glass')
432
432
  ax4.plot(MI_spectra[:, 0],MI_spectra[:, 1], '-', color='salmon',label='Measured MI')
433
433
  ax4.plot(Host_spectra[:, 0],Host_spectra[:, 1], '-', color='g', label='Measured Host')
434
434
  ax4.legend()
@@ -456,7 +456,7 @@ override=False, flip=False, plot_figure=True, dpi=200):
456
456
  """
457
457
  This function checks if the unmixed specta is negative, based on two tie points.
458
458
  The first tie point is the mean y coordinate of the peak position of host +5 wavenumbers,
459
- and the second tie point (tie_x_cord) is an optional input. If the specta is inverted,
459
+ and the second tie point (tie_x_cord) is an optional input. If the specta is inverted,
460
460
  this function inverts it.
461
461
 
462
462
 
DiadFit/_version.py CHANGED
@@ -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__ = '0.0.79'
8
+ __version__ = '0.0.81'
DiadFit/diads.py CHANGED
@@ -154,7 +154,7 @@ class diad_id_config:
154
154
 
155
155
 
156
156
 
157
- def identify_diad_peaks(*, config: diad_id_config=diad_id_config(), path=None, filename,
157
+ def identify_diad_peaks(*, config: diad_id_config=diad_id_config(), path=None, filename=None, diad_array=None,
158
158
  filetype='Witec_ASCII', plot_figure=True):
159
159
 
160
160
  """ This function fits a spline to the spectral data. It then uses Scipy find peaks to identify the diad,
@@ -205,10 +205,11 @@ def identify_diad_peaks(*, config: diad_id_config=diad_id_config(), path=None, f
205
205
 
206
206
 
207
207
  """
208
- Diad_df=get_data(path=path, filename=filename, filetype=filetype)
209
-
210
-
211
- Diad=np.array(Diad_df)
208
+ if diad_array is None:
209
+ Diad_df=get_data(path=path, filename=filename, filetype=filetype)
210
+ Diad=np.array(Diad_df)
211
+ else:
212
+ Diad=diad_array
212
213
 
213
214
 
214
215
 
@@ -1037,7 +1038,7 @@ def plot_diad_groups(*, x_cord, Weak_np=None, Medium_np=None, Strong_np=None, y
1037
1038
  return fig
1038
1039
 
1039
1040
 
1040
- def remove_diad_baseline(*, path=None, filename=None, Diad_files=None, filetype='Witec_ASCII',
1041
+ def remove_diad_baseline(*, path=None, filename=None, Diad_files=None, filetype='Witec_ASCII', diad_array=None,
1041
1042
  exclude_range1=None, exclude_range2=None,N_poly=1, x_range_baseline=10,
1042
1043
  lower_bck=[1200, 1250], upper_bck=[1320, 1330], sigma=4,
1043
1044
  plot_figure=True):
@@ -1100,11 +1101,12 @@ def remove_diad_baseline(*, path=None, filename=None, Diad_files=None, filetype=
1100
1101
 
1101
1102
  """
1102
1103
 
1103
- Diad_df=get_data(path=path, filename=filename, filetype=filetype)
1104
-
1105
-
1104
+ if diad_array is None:
1105
+ Diad_df=get_data(path=path, filename=filename, filetype=filetype)
1106
+ Diad=np.array(Diad_df)
1107
+ else:
1108
+ Diad=diad_array
1106
1109
 
1107
- Diad=np.array(Diad_df)
1108
1110
 
1109
1111
 
1110
1112
  if exclude_range1 is not None and exclude_range2 is None:
@@ -2280,7 +2282,7 @@ def fit_gaussian_voigt_generic_diad(config1, *, diad1=False, diad2=False, path=N
2280
2282
 
2281
2283
 
2282
2284
  def fit_diad_2_w_bck(*, config1: diad2_fit_config=diad2_fit_config(), config2: diad_id_config=diad_id_config(),
2283
- path=None, filename=None, peak_pos_voigt=None,filetype=None,
2285
+ path=None, filename=None, peak_pos_voigt=None,filetype=None, diad_array=None,
2284
2286
  plot_figure=True, close_figure=False, Diad_pos=None, HB_pos=None, C13_pos=None):
2285
2287
  """ This function fits the background (using the function remove_diad_baseline) and then
2286
2288
  fits the peaks using fit_gaussian_voigt_generic_diad()
@@ -2390,8 +2392,11 @@ def fit_diad_2_w_bck(*, config1: diad2_fit_config=diad2_fit_config(), config2: d
2390
2392
 
2391
2393
  # Check number of peaks makes sense
2392
2394
  fit_peaks=config1.fit_peaks
2393
- Diad_df=get_data(path=path, filename=filename, filetype=filetype)
2394
- Diad=np.array(Diad_df)
2395
+ if diad_array is None:
2396
+ Diad_df=get_data(path=path, filename=filename, filetype=filetype)
2397
+ Diad=np.array(Diad_df)
2398
+ else:
2399
+ Diad=diad_array
2395
2400
 
2396
2401
 
2397
2402
  if fit_peaks==2:
@@ -2433,7 +2438,7 @@ def fit_diad_2_w_bck(*, config1: diad2_fit_config=diad2_fit_config(), config2: d
2433
2438
 
2434
2439
  y_corr_diad2, Py_base_diad2, x_diad2, Diad_short_diad2, Py_base_diad2, Pf_baseline_diad2, Baseline_ysub_diad2, Baseline_x_diad2, Baseline_diad2, span_diad2=remove_diad_baseline(
2435
2440
  path=path, filename=filename, filetype=filetype, exclude_range1=config2.exclude_range1, exclude_range2=config2.exclude_range2, N_poly=config1.N_poly_bck_diad2,
2436
- lower_bck=config1.lower_bck_diad2, upper_bck=config1.upper_bck_diad2, plot_figure=False)
2441
+ lower_bck=config1.lower_bck_diad2, upper_bck=config1.upper_bck_diad2, plot_figure=False, diad_array=diad_array)
2437
2442
 
2438
2443
 
2439
2444
 
@@ -2544,8 +2549,8 @@ def fit_diad_2_w_bck(*, config1: diad2_fit_config=diad2_fit_config(), config2: d
2544
2549
  ybase_xlin=Pf_baseline_diad2(x_lin)
2545
2550
 
2546
2551
  # We extract the full spectra to plot at the end, and convert to a dataframe
2547
- Spectra_df=get_data(path=path, filename=filename, filetype=filetype)
2548
- Spectra=np.array(Spectra_df)
2552
+ #Spectra_df=get_data(path=path, filename=filename, filetype=filetype)
2553
+ Spectra=Diad
2549
2554
 
2550
2555
 
2551
2556
 
@@ -2749,9 +2754,9 @@ def fit_diad_2_w_bck(*, config1: diad2_fit_config=diad2_fit_config(), config2: d
2749
2754
 
2750
2755
  # Lets calculate peak skewness here.
2751
2756
  Skew50=assess_diad2_skewness(config1=diad2_fit_config(), int_cut_off=0.5, path=path, filename=filename, filetype=filetype,
2752
- skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False)
2757
+ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False, diad_array=diad_array)
2753
2758
  Skew80=assess_diad2_skewness(config1=diad2_fit_config(), int_cut_off=0.3, path=path, filename=filename, filetype=filetype,
2754
- skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False)
2759
+ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False, diad_array=diad_array)
2755
2760
  df_out['Diad2_Asym50']=Skew50['Skewness_diad2']
2756
2761
  df_out['Diad2_Asym70']=Skew80['Skewness_diad2']
2757
2762
  df_out['Diad2_Yuan2017_sym_factor']=(df_out['Diad2_fwhm'])*(df_out['Diad2_Asym50']-1)
@@ -2767,7 +2772,7 @@ def fit_diad_2_w_bck(*, config1: diad2_fit_config=diad2_fit_config(), config2: d
2767
2772
 
2768
2773
 
2769
2774
  def fit_diad_1_w_bck(*, config1: diad1_fit_config=diad1_fit_config(), config2: diad_id_config=diad_id_config(),
2770
- path=None, filename=None, filetype=None, plot_figure=True, close_figure=True, Diad_pos=None, HB_pos=None):
2775
+ path=None, filename=None, filetype=None, plot_figure=True, close_figure=True, Diad_pos=None, HB_pos=None, diad_array=None):
2771
2776
  """ This function fits the background (using the function remove_diad_baseline) and then fits the peaks
2772
2777
  using fit_gaussian_voigt_generic_diad()
2773
2778
  It then checks if any parameters are right at the permitted edge (meaning fitting didnt converge),
@@ -2876,13 +2881,16 @@ def fit_diad_1_w_bck(*, config1: diad1_fit_config=diad1_fit_config(), config2: d
2876
2881
  config1.fit_gauss=False
2877
2882
  #print('Either no hb position, or prominence<-50, using 1 fit')
2878
2883
 
2879
- Diad_df=get_data(path=path, filename=filename, filetype=filetype)
2880
- Diad=np.array(Diad_df)
2884
+ if diad_array is None:
2885
+ Diad_df=get_data(path=path, filename=filename, filetype=filetype)
2886
+ Diad=np.array(Diad_df)
2887
+ else:
2888
+ Diad=diad_array
2881
2889
  # First, we feed data into the remove baseline function, which returns corrected data
2882
2890
 
2883
2891
  y_corr_diad1, Py_base_diad1, x_diad1, Diad_short_diad1, Py_base_diad1, Pf_baseline_diad1, Baseline_ysub_diad1, Baseline_x_diad1, Baseline_diad1, span_diad1=remove_diad_baseline(
2884
2892
  path=path, filename=filename, filetype=filetype, exclude_range1=config2.exclude_range1, exclude_range2=config2.exclude_range2, N_poly=config1.N_poly_bck_diad1,
2885
- lower_bck=config1.lower_bck_diad1, upper_bck=config1.upper_bck_diad1, plot_figure=False)
2893
+ lower_bck=config1.lower_bck_diad1, upper_bck=config1.upper_bck_diad1, plot_figure=False, diad_array=diad_array)
2886
2894
 
2887
2895
 
2888
2896
 
@@ -2997,8 +3005,9 @@ def fit_diad_1_w_bck(*, config1: diad1_fit_config=diad1_fit_config(), config2: d
2997
3005
  ybase_xlin=Pf_baseline_diad1(x_lin)
2998
3006
 
2999
3007
  # We extract the full spectra to plot at the end, and convert to a dataframe
3000
- Spectra_df=get_data(path=path, filename=filename, filetype=filetype)
3001
- Spectra=np.array(Spectra_df)
3008
+
3009
+
3010
+ Spectra=Diad
3002
3011
 
3003
3012
 
3004
3013
 
@@ -3193,9 +3202,9 @@ def fit_diad_1_w_bck(*, config1: diad1_fit_config=diad1_fit_config(), config2: d
3193
3202
 
3194
3203
  # Lets calculate peak skewness here.
3195
3204
  Skew50=assess_diad1_skewness(config1=diad1_fit_config(), int_cut_off=0.5, path=path, filename=filename, filetype=filetype,
3196
- skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False)
3205
+ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False, diad_array=diad_array)
3197
3206
  Skew80=assess_diad1_skewness(config1=diad1_fit_config(), int_cut_off=0.3, path=path, filename=filename, filetype=filetype,
3198
- skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False)
3207
+ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=False, diad_array=diad_array)
3199
3208
 
3200
3209
  df_out['Diad1_Asym50']=Skew50['Skewness_diad1']
3201
3210
  df_out['Diad1_Asym70']=Skew80['Skewness_diad1']
@@ -4181,7 +4190,7 @@ encode="ISO-8859-1"
4181
4190
 
4182
4191
 
4183
4192
  def assess_diad1_skewness(*, config1: diad1_fit_config=diad1_fit_config(), int_cut_off=0.3, path=None, filename=None, filetype=None,
4184
- skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, peak_fit_routine=False, peak_pos=None, peak_height=None, dpi=200):
4193
+ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, peak_fit_routine=False, peak_pos=None, peak_height=None, dpi=200, diad_array=None):
4185
4194
  """ Assesses Skewness of Diad peaks. Useful for identifying mixed L + V phases
4186
4195
  (see DeVitre et al. in review)
4187
4196
 
@@ -4243,7 +4252,7 @@ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, peak_fit_ro
4243
4252
 
4244
4253
  y_corr_diad1, Py_base_diad1, x_diad1, Diad_short, Py_base_diad1, Pf_baseline, Baseline_ysub_diad1, Baseline_x_diad1, Baseline, span=remove_diad_baseline(
4245
4254
  path=path, filename=filename, filetype=filetype, N_poly=config1.N_poly_bck_diad1,
4246
- lower_bck=config1.lower_bck_diad1, upper_bck=config1.upper_bck_diad1, plot_figure=False)
4255
+ lower_bck=config1.lower_bck_diad1, upper_bck=config1.upper_bck_diad1, plot_figure=False, diad_array=diad_array)
4247
4256
 
4248
4257
 
4249
4258
 
@@ -4434,7 +4443,7 @@ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, peak_fit_ro
4434
4443
 
4435
4444
 
4436
4445
  def assess_diad2_skewness(*, config1: diad2_fit_config=diad1_fit_config(), int_cut_off=0.3, path=None, filename=None, filetype=None,
4437
- skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, dpi=200, peak_fit_routine=False, peak_pos=None, peak_height=None):
4446
+ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, dpi=200, peak_fit_routine=False, peak_pos=None, peak_height=None, diad_array=None):
4438
4447
 
4439
4448
  """ Assesses Skewness of Diad peaks. Useful for identifying mixed L + V phases
4440
4449
  (see DeVitre et al. in review)
@@ -4498,7 +4507,7 @@ skewness='abs', height=1, prominence=5, width=0.5, plot_figure=True, dpi=200, pe
4498
4507
  # First, do the background subtraction
4499
4508
  y_corr_diad2, Py_base_diad2, x_diad2, Diad_short, Py_base_diad2, Pf_baseline, Baseline_ysub_diad2, Baseline_x_diad2, Baseline, span=remove_diad_baseline(
4500
4509
  path=path, filename=filename, filetype=filetype, N_poly=config1.N_poly_bck_diad2,
4501
- lower_bck=config1.lower_bck_diad2, upper_bck=config1.upper_bck_diad2, plot_figure=False)
4510
+ lower_bck=config1.lower_bck_diad2, upper_bck=config1.upper_bck_diad2, plot_figure=False, diad_array=diad_array)
4502
4511
 
4503
4512
 
4504
4513
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiadFit
3
- Version: 0.0.79
3
+ Version: 0.0.81
4
4
  Summary: DiadFit
5
5
  Home-page: https://github.com/PennyWieser/DiadFit
6
6
  Author: Penny Wieser
@@ -1,7 +1,7 @@
1
1
  DiadFit/CO2_EOS.py,sha256=AeiM_s0cIVip5i5q1Shy8QXTUWz4XHG0VnfuBH5qRDY,28034
2
- DiadFit/CO2_H2O_EOS.py,sha256=A1dT-9gnckhhssipYatDwtZwQyhe3egQXwlSwYNws5c,29225
2
+ DiadFit/CO2_H2O_EOS.py,sha256=TLU2goWB6yGFbN4RBS0dRXG0oDQuuG0JftW32DZHmn4,37722
3
3
  DiadFit/CO2_in_bubble_error.py,sha256=Ga_hNA63m-OZg2hBOqM7VvpJhnvvTCg6L3Qixh1Bh7A,14196
4
- DiadFit/H2O_fitting.py,sha256=pbEa0JivZFAmWxEGY5VMetD95BGNCzkaatfXRVAV4fs,43889
4
+ DiadFit/H2O_fitting.py,sha256=E3xD9VkYNDdmsQ3wZNkMOHhPkNO0F-al_Vb9Q8ZR6oI,43888
5
5
  DiadFit/Highrho_polyfit_data.pkl,sha256=7t6uXxI-HdfsvreAWORzMa9dXxUsnXqKBSo1O3EgiBw,1213
6
6
  DiadFit/Highrho_polyfit_dataUCB_1117_1400.pkl,sha256=B7nX560JpBBBssSgr50oDDG-UKsNxAjp235eytquVaI,1213
7
7
  DiadFit/Highrho_polyfit_dataUCB_1220_1400.pkl,sha256=0_eZVQ3Byh9u5xW9TnvlUJg_-bTDSjG3EpVhCutZZkk,1213
@@ -22,19 +22,19 @@ DiadFit/Mediumrho_polyfit_data_CCMR.pkl,sha256=U6ODSdurqS0-lynm1MG1zktg8NuhYRbrY
22
22
  DiadFit/Mediumrho_polyfit_data_CMASS.pkl,sha256=SBy1pIdqCAF9UtB9FLNTuD0-tFyD7swwJppdE2U_FsY,1557
23
23
  DiadFit/Psensor.py,sha256=C2xSlgxhUJIKIBDvUp02QaYRs5QsIqjGGRMP25ZLRZ0,10435
24
24
  DiadFit/__init__.py,sha256=wXZHfLvkI9ye1TFrdykATP8Kn7I-UdNFBTmHZI1V9EQ,1181
25
- DiadFit/_version.py,sha256=fugtEQoTmHhSLhTkoRHaKUgjmjg0g4gxy5aLvJXcutU,296
25
+ DiadFit/_version.py,sha256=CzVjNKXoNSWVxQixpm86PR7oeqLxOVySxo9al2Crl2M,296
26
26
  DiadFit/argon_lines.py,sha256=vtzsuDdEgrAmEF9xwpejpFqKV9hKPS1JUYhIl4AfXZ0,7675
27
27
  DiadFit/cosmicray_filter.py,sha256=SqowmxChJG4Is6_K5E5OqJ1WaSWSaGKg-hSDBOJIVA0,23626
28
28
  DiadFit/densimeter_fitting.py,sha256=Uel9a4qUVz6r-my09uuHFRjD9oPFF-kd5ZBPYfYfOQM,8086
29
29
  DiadFit/densimeters.py,sha256=hcgcymwPf0POP5xT29mADM4L80arqW6ZKJ3Yq3EYJIE,48086
30
30
  DiadFit/density_depth_crustal_profiles.py,sha256=XPauKf62hMp-iw701XfphaVe3o6LRJSwuQXAcSDXv6s,16983
31
- DiadFit/diads.py,sha256=61B5qFSsTO81k6T9Qy3wLFOv7oR5tubIySrtXUmdCWM,173053
31
+ DiadFit/diads.py,sha256=C8sq9Fd-jSu2SAhBpEgcsI87Sg2WDNvXkQfrxbb2TEE,173514
32
32
  DiadFit/error_propagation.py,sha256=_x82UIXz46-Qjvvz2tDAblyDkOe_51JI27wvSDkSOms,35080
33
33
  DiadFit/importing_data_files.py,sha256=zghBVGWLLQaG9dWKSIa7KaDmqUBmyhm7ZgBmV5f4SuI,38926
34
34
  DiadFit/molar_gas_proportions.py,sha256=_oEZn_vndHGDaXAjZ6UU8ycujBx_qB2KGCGqZSzotQU,3389
35
35
  DiadFit/ne_lines.py,sha256=-Xv62LJ2OOGSCeKsQjmXZ7yD3g2ZOG1okxvVp8PYzXM,67144
36
36
  DiadFit/relaxifi.py,sha256=hHzRsJPQIVohYi3liy9IQJpaomgsa2zbLQmhqkpdfrI,31549
37
- DiadFit-0.0.79.dist-info/METADATA,sha256=fp3BVv4Wh2MjjjdhoHQPBB8tVjG2OaiWMBoIMhddeu0,1159
38
- DiadFit-0.0.79.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
- DiadFit-0.0.79.dist-info/top_level.txt,sha256=yZC6OFLVznaFA5kcPlFPkvhKotcVd-YO4bKxZZw3LQE,8
40
- DiadFit-0.0.79.dist-info/RECORD,,
37
+ DiadFit-0.0.81.dist-info/METADATA,sha256=HlqIL0pJNlGoLV-3qV7B0WuWWPXRzb7aYu1n_3_hxsM,1159
38
+ DiadFit-0.0.81.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
+ DiadFit-0.0.81.dist-info/top_level.txt,sha256=yZC6OFLVznaFA5kcPlFPkvhKotcVd-YO4bKxZZw3LQE,8
40
+ DiadFit-0.0.81.dist-info/RECORD,,