DiadFit 1.0.1__py3-none-any.whl → 1.0.2__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 +20 -4
- DiadFit/_version.py +1 -1
- DiadFit/diads.py +91 -1
- DiadFit/error_propagation.py +12 -4
- {DiadFit-1.0.1.dist-info → DiadFit-1.0.2.dist-info}/METADATA +1 -1
- {DiadFit-1.0.1.dist-info → DiadFit-1.0.2.dist-info}/RECORD +8 -8
- {DiadFit-1.0.1.dist-info → DiadFit-1.0.2.dist-info}/WHEEL +0 -0
- {DiadFit-1.0.1.dist-info → DiadFit-1.0.2.dist-info}/top_level.txt +0 -0
DiadFit/CO2_EOS.py
CHANGED
@@ -1028,7 +1028,7 @@ def ensure_series(a, b, c):
|
|
1028
1028
|
else:
|
1029
1029
|
c = pd.Series(c)
|
1030
1030
|
|
1031
|
-
return a, b, c
|
1031
|
+
return a.reset_index(drop=True), b.reset_index(drop=True), c.reset_index(drop=True)
|
1032
1032
|
|
1033
1033
|
|
1034
1034
|
def ensure_series_4(a, b, c, d):
|
@@ -1061,7 +1061,7 @@ def ensure_series_4(a, b, c, d):
|
|
1061
1061
|
else:
|
1062
1062
|
d = pd.Series(d)
|
1063
1063
|
|
1064
|
-
return a, b, c, d
|
1064
|
+
return a.reset_index(drop=True), b.reset_index(drop=True), c.reset_index(drop=True), d.reset_index(drop=True)
|
1065
1065
|
|
1066
1066
|
|
1067
1067
|
|
@@ -2064,9 +2064,13 @@ def calculate_entrapment_P_XH2O(*, XH2O, CO2_dens_gcm3, T_K, T_K_ambient=37+273.
|
|
2064
2064
|
|
2065
2065
|
|
2066
2066
|
"""
|
2067
|
+
|
2067
2068
|
XH2O, rho_meas, T_K=ensure_series(a=XH2O, b=CO2_dens_gcm3, c=T_K)
|
2068
2069
|
alpha=XH2O/(1-XH2O)
|
2069
2070
|
|
2071
|
+
# All inputs 194 up to here
|
2072
|
+
|
2073
|
+
|
2070
2074
|
# IF water is lost
|
2071
2075
|
rho_orig_H_loss=rho_meas*(1+alpha*(18/44))
|
2072
2076
|
# IF water isnt lost
|
@@ -2083,11 +2087,23 @@ def calculate_entrapment_P_XH2O(*, XH2O, CO2_dens_gcm3, T_K, T_K_ambient=37+273.
|
|
2083
2087
|
|
2084
2088
|
# calculate density of H2O using EOS
|
2085
2089
|
H2O_dens=calculate_rho_for_P_T_H2O(P_kbar=P_H2O,T_K=T_K_ambient)
|
2090
|
+
H2O_dens=H2O_dens.reset_index(drop=True)
|
2086
2091
|
|
2087
2092
|
# Calculate the bulk density by re-arranging the two volume equations
|
2088
2093
|
nan_mask = H2O_dens==0
|
2089
|
-
|
2090
|
-
|
2094
|
+
|
2095
|
+
# Debugging
|
2096
|
+
|
2097
|
+
|
2098
|
+
|
2099
|
+
|
2100
|
+
rho_orig_no_H_loss=(rho_meas*H2O_dens)/((1-XH2O_mass)*H2O_dens+XH2O_mass*rho_meas)
|
2101
|
+
|
2102
|
+
|
2103
|
+
|
2104
|
+
|
2105
|
+
rho_orig_no_H_loss = np.where(nan_mask, rho_meas, rho_orig_no_H_loss)
|
2106
|
+
|
2091
2107
|
|
2092
2108
|
|
2093
2109
|
|
DiadFit/_version.py
CHANGED
DiadFit/diads.py
CHANGED
@@ -17,7 +17,7 @@ from dataclasses import dataclass
|
|
17
17
|
import matplotlib.patches as patches
|
18
18
|
import warnings as w
|
19
19
|
from tqdm import tqdm
|
20
|
-
from
|
20
|
+
from scipy.integrate import trapezoid
|
21
21
|
from scipy.integrate import simpson
|
22
22
|
from scipy.interpolate import interp1d
|
23
23
|
|
@@ -832,6 +832,96 @@ def filter_splitting_prominence(*, fit_params, data_y_all,
|
|
832
832
|
|
833
833
|
return fit_params_filt.reset_index(drop=True), data_y_filt, fit_params_disc.reset_index(drop=True), data_y_disc
|
834
834
|
|
835
|
+
def filter_by_string(*, fit_params, data_y_all,
|
836
|
+
x_cord,
|
837
|
+
str_filt=None):
|
838
|
+
""" Filters Spectra based on approximate splitting, draws a plot showing spectra to discard and those to keep
|
839
|
+
|
840
|
+
Parameters
|
841
|
+
--------------
|
842
|
+
fit_params: pd.dataframe
|
843
|
+
dataframe of fit parameters from loop_approx_diad_fits
|
844
|
+
|
845
|
+
data_y_all: np.array
|
846
|
+
y coordinates of each spectra from loop_approx_diad_fits, used for plotting visualizatoins
|
847
|
+
|
848
|
+
x_cord: np.array
|
849
|
+
x coordinates of 1 spectra. Assumes all x coordinates the same length
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
str_filt: str
|
854
|
+
Filters just based on string in filename. Keeps files with string in, discards those without.
|
855
|
+
|
856
|
+
Returns
|
857
|
+
--------------
|
858
|
+
fit_params_filt: pd.DataFrame
|
859
|
+
dataframe of fit parameters for spectra to keep
|
860
|
+
data_y_filt: np.array
|
861
|
+
y coordinates of spectra to keep
|
862
|
+
fit_params_disc: pd.DataFrame
|
863
|
+
dataframe of fit parameters for spectra to discard
|
864
|
+
data_y_disc: np.array
|
865
|
+
y coordinates of spectra to discard
|
866
|
+
|
867
|
+
|
868
|
+
"""
|
869
|
+
|
870
|
+
filt=fit_params['filename'].str.contains(str_filt)
|
871
|
+
|
872
|
+
|
873
|
+
fit_params_filt=fit_params.loc[filt].reset_index(drop=True)
|
874
|
+
fit_params_disc=fit_params.loc[~(filt)].reset_index(drop=True)
|
875
|
+
|
876
|
+
print('Keeping N='+str(len(fit_params_filt)))
|
877
|
+
print('Discarding N='+str(len(fit_params_disc)))
|
878
|
+
|
879
|
+
|
880
|
+
|
881
|
+
# Then apply to get data
|
882
|
+
data_y_filt=data_y_all[:, (filt)]
|
883
|
+
data_y_disc=data_y_all[:, ~(filt)]
|
884
|
+
|
885
|
+
intc=800
|
886
|
+
prom_filt=0
|
887
|
+
prom_disc=0
|
888
|
+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12,5))
|
889
|
+
ax1.set_title('Samples')
|
890
|
+
ax2.set_title('Standards')
|
891
|
+
if sum(~filt)>0:
|
892
|
+
for i in range(0, np.shape(data_y_disc)[1]):
|
893
|
+
av_prom_disc=np.abs(np.nanmedian(fit_params_disc['Diad1_abs_prom'])/intc)
|
894
|
+
Diff=np.nanmax(data_y_disc[:, i])-np.nanmin(data_y_disc[:, i])
|
895
|
+
av_prom_Keep=fit_params_disc['Diad1_abs_prom'].iloc[i]
|
896
|
+
prom_disc=prom_disc+av_prom_disc
|
897
|
+
ax1.plot(x_cord+i*5, (data_y_disc[:, i]-np.nanmin(data_y_disc[:, i]))/Diff+i/3, '-r', lw=0.5)
|
898
|
+
yplot=np.quantile((data_y_disc[:, i]-np.nanmin(data_y_disc[:, i]))/Diff+i/3, 0.65)
|
899
|
+
file=fit_params_disc['filename'].iloc[i]
|
900
|
+
file = file.replace("_CRR_DiadFit", "")
|
901
|
+
ax1.annotate(str(file), xy=(1450+i*5, yplot),
|
902
|
+
xycoords="data", fontsize=8, bbox=dict(facecolor='white', edgecolor='none', pad=2))
|
903
|
+
|
904
|
+
ax1.set_xlim([1250, 1500+i*5])
|
905
|
+
ax1.set_xticks([])
|
906
|
+
ax1.set_yticks([])
|
907
|
+
if sum(filt)>0:
|
908
|
+
for i in range(0, np.shape(data_y_filt)[1]):
|
909
|
+
Diff=np.nanmax(data_y_filt[:, i])-np.nanmin(data_y_filt[:, i])
|
910
|
+
av_prom_Keep=fit_params_filt['Diad1_abs_prom'].iloc[i]
|
911
|
+
prom_filt=prom_filt+av_prom_Keep
|
912
|
+
file=fit_params_filt['filename'].iloc[i]
|
913
|
+
ax2.plot(x_cord+i*5, (data_y_filt[:, i]-np.nanmin(data_y_filt[:, i]))/Diff+i/3, '-b', lw=0.5)
|
914
|
+
yplot=np.quantile((data_y_filt[:, i]-np.nanmin(data_y_filt[:, i]))/Diff+i/3, 0.65)
|
915
|
+
ax2.annotate(str(file), xy=(1450+i*5, yplot),
|
916
|
+
xycoords="data", fontsize=8, bbox=dict(facecolor='white', edgecolor='none', pad=2))
|
917
|
+
|
918
|
+
|
919
|
+
ax2.set_xlim([1250, 1450+i*5])
|
920
|
+
ax2.set_xticks([])
|
921
|
+
ax2.set_yticks([])
|
922
|
+
|
923
|
+
return fit_params_filt.reset_index(drop=True), data_y_filt, fit_params_disc.reset_index(drop=True), data_y_disc
|
924
|
+
|
835
925
|
|
836
926
|
def identify_diad_group(*, fit_params, data_y, x_cord, filter_bool,y_fig_scale=0.1, grp_filter='Weak', str_filt=None):
|
837
927
|
|
DiadFit/error_propagation.py
CHANGED
@@ -331,6 +331,8 @@ error_CO2_dens=0, error_type_CO2_dens='Abs', error_dist_CO2_dens='normal',
|
|
331
331
|
|
332
332
|
# Check for panda Series
|
333
333
|
|
334
|
+
|
335
|
+
|
334
336
|
def convert_inputs_to_series(T_K, error_T_K, CO2_dens_gcm3, error_CO2_dens_gcm3, XH2O, error_XH2O):
|
335
337
|
# Create a list of all inputs
|
336
338
|
inputs = [T_K, error_T_K, CO2_dens_gcm3, error_CO2_dens_gcm3, XH2O, error_XH2O]
|
@@ -341,11 +343,17 @@ def convert_inputs_to_series(T_K, error_T_K, CO2_dens_gcm3, error_CO2_dens_gcm3,
|
|
341
343
|
# Unpack the converted inputs back to their respective variables
|
342
344
|
T_K, error_T_K, CO2_dens_gcm3, error_CO2_dens_gcm3, XH2O, error_XH2O = converted_inputs
|
343
345
|
|
344
|
-
#
|
345
|
-
|
346
|
-
|
347
|
-
|
346
|
+
# Reset index only if the input is a pandas Series
|
347
|
+
T_K = T_K.reset_index(drop=True) if isinstance(T_K, pd.Series) else T_K
|
348
|
+
error_T_K = error_T_K.reset_index(drop=True) if isinstance(error_T_K, pd.Series) else error_T_K
|
349
|
+
CO2_dens_gcm3 = CO2_dens_gcm3.reset_index(drop=True) if isinstance(CO2_dens_gcm3, pd.Series) else CO2_dens_gcm3
|
350
|
+
error_CO2_dens_gcm3 = error_CO2_dens_gcm3.reset_index(drop=True) if isinstance(error_CO2_dens_gcm3, pd.Series) else error_CO2_dens_gcm3
|
351
|
+
XH2O = XH2O.reset_index(drop=True) if isinstance(XH2O, pd.Series) else XH2O
|
352
|
+
error_XH2O = error_XH2O.reset_index(drop=True) if isinstance(error_XH2O, pd.Series) else error_XH2O
|
348
353
|
|
354
|
+
# Return the possibly converted inputs
|
355
|
+
return T_K, error_T_K, CO2_dens_gcm3, error_CO2_dens_gcm3, XH2O, error_XH2O
|
356
|
+
|
349
357
|
|
350
358
|
|
351
359
|
def propagate_FI_uncertainty(sample_ID, CO2_dens_gcm3, T_K, multiprocess='default', cores='default',
|
@@ -1,4 +1,4 @@
|
|
1
|
-
DiadFit/CO2_EOS.py,sha256=
|
1
|
+
DiadFit/CO2_EOS.py,sha256=H2_th8DP5m9oJ-IZCg9XncuOogQy_AE8ihiT-4zlIOo,74170
|
2
2
|
DiadFit/CO2_in_bubble_error.py,sha256=Nq5YEf2oa2rWRreEPXl2lEA86NXOGvll0Gca2AOu_RE,21224
|
3
3
|
DiadFit/H2O_fitting.py,sha256=ZOLWL8j7HQYKlx1-ISm1twvH34jhrGFwukU8ElRj0Dw,43920
|
4
4
|
DiadFit/Highrho_polyfit_data.pkl,sha256=7t6uXxI-HdfsvreAWORzMa9dXxUsnXqKBSo1O3EgiBw,1213
|
@@ -29,21 +29,21 @@ DiadFit/Mediumrho_polyfit_data_CCMR.pkl,sha256=U6ODSdurqS0-lynm1MG1zktg8NuhYRbrY
|
|
29
29
|
DiadFit/Mediumrho_polyfit_data_CMASS.pkl,sha256=SBy1pIdqCAF9UtB9FLNTuD0-tFyD7swwJppdE2U_FsY,1557
|
30
30
|
DiadFit/Psensor.py,sha256=C2xSlgxhUJIKIBDvUp02QaYRs5QsIqjGGRMP25ZLRZ0,10435
|
31
31
|
DiadFit/__init__.py,sha256=F-HjhCYKL_U8PfiH8tZ9DUCkxPvo6lAslJS4fyvxkbY,1148
|
32
|
-
DiadFit/_version.py,sha256=
|
32
|
+
DiadFit/_version.py,sha256=X0PLLhZnpIdwlS5nJADl6Y4cVKJ40aHv2hvu4kkgAGQ,295
|
33
33
|
DiadFit/argon_lines.py,sha256=vtzsuDdEgrAmEF9xwpejpFqKV9hKPS1JUYhIl4AfXZ0,7675
|
34
34
|
DiadFit/cosmicray_filter.py,sha256=a45x2_nmpi9Qcjc_L39UA9JOd1NMorIjtTRGnCdG3MU,23634
|
35
35
|
DiadFit/densimeter_fitting.py,sha256=zEyCwq1zDV3z6-MIu-eZqgp3YQPUGqwZiKczN3-22LQ,8247
|
36
36
|
DiadFit/densimeters.py,sha256=p3jY9709vKegCfWZIwoU4Rt5jFfwJJQobLb71AXUxAY,55250
|
37
37
|
DiadFit/density_depth_crustal_profiles.py,sha256=b072IJaoGDydKpqWWKoJHeXKIkcIXxKf82whpvLAPpw,17761
|
38
|
-
DiadFit/diads.py,sha256=
|
39
|
-
DiadFit/error_propagation.py,sha256=
|
38
|
+
DiadFit/diads.py,sha256=RWFesTt_W52u_-N9Cr2VtHuKrR038XKf3-dDLx5CNYY,180888
|
39
|
+
DiadFit/error_propagation.py,sha256=ipYI-Nwjv4f0sBdUiGeYV4wLcLGUXzKRrquNnc72d3c,50620
|
40
40
|
DiadFit/importing_data_files.py,sha256=0Cx_CKJZR8efssMzQit0aPRh_rsjQFGXgLtI285FW_k,41961
|
41
41
|
DiadFit/lookup_table.csv,sha256=Hs1tmSQ9ArTUDv3ymEXbvnLlPBxYUP0P51dz7xAKk-Q,2946857
|
42
42
|
DiadFit/lookup_table_noneg.csv,sha256=HelvewKbBy4cqT2GAqsMo-1ps1lBYqZ-8hCJZWPGfhI,3330249
|
43
43
|
DiadFit/molar_gas_proportions.py,sha256=_oEZn_vndHGDaXAjZ6UU8ycujBx_qB2KGCGqZSzotQU,3389
|
44
44
|
DiadFit/ne_lines.py,sha256=6z9oo4lgh0iYv1mkSscgzCt_Pe4gQTnquG99pR6cJS8,63811
|
45
45
|
DiadFit/relaxifi.py,sha256=hHzRsJPQIVohYi3liy9IQJpaomgsa2zbLQmhqkpdfrI,31549
|
46
|
-
DiadFit-1.0.
|
47
|
-
DiadFit-1.0.
|
48
|
-
DiadFit-1.0.
|
49
|
-
DiadFit-1.0.
|
46
|
+
DiadFit-1.0.2.dist-info/METADATA,sha256=EjFCY1urZhZ_wc2Wxb8f0NC8gNgV-JaFY1ShqDBpnoQ,1174
|
47
|
+
DiadFit-1.0.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
48
|
+
DiadFit-1.0.2.dist-info/top_level.txt,sha256=yZC6OFLVznaFA5kcPlFPkvhKotcVd-YO4bKxZZw3LQE,8
|
49
|
+
DiadFit-1.0.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|