DiadFit 0.0.90__py3-none-any.whl → 1.0.1__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 +1320 -5
- DiadFit/CO2_in_bubble_error.py +91 -19
- DiadFit/H2O_fitting.py +11 -11
- DiadFit/__init__.py +1 -1
- DiadFit/_version.py +1 -1
- DiadFit/densimeters.py +17 -5
- DiadFit/diads.py +36 -14
- DiadFit/error_propagation.py +358 -143
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.1.dist-info}/METADATA +3 -3
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.1.dist-info}/RECORD +12 -13
- DiadFit/CO2_H2O_EOS.py +0 -1255
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.1.dist-info}/WHEEL +0 -0
- {DiadFit-0.0.90.dist-info → DiadFit-1.0.1.dist-info}/top_level.txt +0 -0
DiadFit/CO2_in_bubble_error.py
CHANGED
@@ -90,10 +90,16 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
90
90
|
"""
|
91
91
|
# Constant for sphere calcs
|
92
92
|
|
93
|
+
|
93
94
|
# Lets check what they entered for volume - if they didnt enter a volume % Bubble, lets calculate it
|
94
95
|
if vol_perc_bub is None:
|
95
|
-
|
96
|
-
|
96
|
+
if VB_z is None:
|
97
|
+
VB_z=(VB_x+VB_y)/2
|
98
|
+
if MI_z is None:
|
99
|
+
MI_z=(MI_x+MI_y)/2
|
100
|
+
|
101
|
+
Vol_VB_sphere=const*VB_x*VB_y*VB_z*(0.5)**3
|
102
|
+
Vol_MI_sphere=const*MI_x*MI_y*MI_z*(0.5)**3
|
97
103
|
vol_perc_bub=100* Vol_VB_sphere/Vol_MI_sphere
|
98
104
|
|
99
105
|
# Now lets check how they entered error in volume
|
@@ -128,6 +134,7 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
128
134
|
|
129
135
|
|
130
136
|
|
137
|
+
|
131
138
|
#This loops through each sample
|
132
139
|
for i in range(0, len_loop):
|
133
140
|
if i % 20 == 0:
|
@@ -153,6 +160,7 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
153
160
|
# This is the function doing the work to actually make the simulations for each variable.
|
154
161
|
if error_vol_perc_bub is not None:
|
155
162
|
|
163
|
+
|
156
164
|
df_synthetic=propagate_CO2_in_bubble_ind(
|
157
165
|
N_dup=N_dup,
|
158
166
|
vol_perc_bub=vol_perc_bub_i,
|
@@ -169,15 +177,27 @@ plot_figure=True, fig_i=0, neg_values=True):
|
|
169
177
|
error_dist_melt_dens_kgm3=error_dist_melt_dens_kgm3,
|
170
178
|
len_loop=1, neg_values=neg_values)
|
171
179
|
|
180
|
+
|
181
|
+
|
172
182
|
else:
|
173
183
|
|
184
|
+
|
174
185
|
# This is the more complex one where we have to account for x-y-z errors on all of them.
|
175
186
|
MI_x_i = get_value(MI_x, i)
|
176
187
|
MI_y_i = get_value(MI_y, i)
|
177
|
-
|
188
|
+
|
189
|
+
|
190
|
+
|
178
191
|
VB_x_i = get_value(VB_x, i)
|
179
192
|
VB_y_i = get_value(VB_y, i)
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
180
197
|
VB_z_i = get_value(VB_z, i)
|
198
|
+
MI_z_i = get_value(MI_z, i)
|
199
|
+
|
200
|
+
|
181
201
|
|
182
202
|
error_MI_x_i = get_value(error_MI_x, i)
|
183
203
|
error_MI_y_i = get_value(error_MI_y, i)
|
@@ -299,11 +319,33 @@ error_type_dimension=error_type_dimension, error_dist_dimension=error_dist_dimen
|
|
299
319
|
|
300
320
|
return df_step, All_outputs, fig if 'fig' in locals() else None
|
301
321
|
|
302
|
-
|
322
|
+
# Lets set the random seed
|
323
|
+
np.random.seed(42)
|
303
324
|
|
304
325
|
def add_noise_to_variable(original_value, error, error_type, error_dist, N_dup, neg_values, neg_threshold):
|
305
326
|
""" This function adds noise to each variable for the monte-carloing
|
306
327
|
|
328
|
+
Parameters
|
329
|
+
-----------------
|
330
|
+
original_value: int, float
|
331
|
+
Preferred value (e.g. center of distribution)
|
332
|
+
|
333
|
+
error: int, float
|
334
|
+
Error value
|
335
|
+
|
336
|
+
error_type: str
|
337
|
+
'Abs' if absolute error, 'Perc' if percent
|
338
|
+
|
339
|
+
error_dist: str
|
340
|
+
'normal' if normally distributed, 'uniform' if uniformly distributed.
|
341
|
+
|
342
|
+
N_dup: int
|
343
|
+
number of duplicates
|
344
|
+
|
345
|
+
neg_values: bool
|
346
|
+
whether negative values are replaced with zeros
|
347
|
+
|
348
|
+
|
307
349
|
"""
|
308
350
|
|
309
351
|
# Depending on the error type, allocates an error
|
@@ -351,14 +393,47 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
351
393
|
|
352
394
|
Parameters
|
353
395
|
----------------
|
396
|
+
For volumes, either enter vol% bubble and associated errors...
|
397
|
+
|
398
|
+
vol_perc_bub: int, float, pd.series
|
399
|
+
Volume proportion of sulfide in melt inclusion
|
400
|
+
|
401
|
+
|
402
|
+
error_vol_perc_bub, CO2_bub_dens_gcm3, error_melt_dens_kgm3: int, float, pd.Series
|
403
|
+
Error for each variable, can be absolute or %
|
404
|
+
|
405
|
+
error_type_vol_perc_bub, error_type_bub_dens_gcm3, error_type_melt_dens_kgm3: 'Abs' or 'Perc'
|
406
|
+
whether given error is perc or absolute
|
407
|
+
|
408
|
+
error_dist_vol_perc_bub, error_dist_bub_dens_gcm3, error_dist_melt_dens_kgm3: 'normal' or 'uniform'
|
409
|
+
Distribution of simulated error
|
410
|
+
|
411
|
+
|
412
|
+
OR
|
413
|
+
Enter melt inclusion and vapour bubble dimensions (diameter, not radii), and their errors
|
414
|
+
MI_x, MI_y, MI_z, VB_x, VB_y, VB_z: int, float, series:
|
415
|
+
Diameter of melt inclusions.
|
416
|
+
|
417
|
+
error_MI_x, error_MI_y, error_MI_z, error_VB_x, error_VB_y, error_VB_z:
|
418
|
+
Error on diameter of melt inclusions
|
419
|
+
|
420
|
+
error_type_dimension='Abs' or 'Perc':
|
421
|
+
Specify whether errors on these dimensions are absolute or percentage
|
422
|
+
|
423
|
+
error_dist_dimension='normal' or 'uniform':
|
424
|
+
Specify error distribution
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
354
430
|
SampleID: str, pd.series
|
355
431
|
Sample_ID (e.g. sample names) which is returned on dataframe
|
356
432
|
|
357
433
|
N_dup: int
|
358
434
|
Number of duplicates when generating errors for Monte Carlo simulations
|
359
435
|
|
360
|
-
|
361
|
-
Volume proportion of sulfide in melt inclusion
|
436
|
+
|
362
437
|
|
363
438
|
melt_dens_kgm3:int, float, pd.series
|
364
439
|
Density of the silicate melt in kg/m3, e.g. from DensityX
|
@@ -367,14 +442,6 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
367
442
|
Density of the vapour bubble in g/cm3
|
368
443
|
|
369
444
|
|
370
|
-
error_vol_perc_bub, CO2_bub_dens_gcm3, error_melt_dens_kgm3: int, float, pd.Series
|
371
|
-
Error for each variable, can be absolute or %
|
372
|
-
|
373
|
-
error_type_vol_perc_bub, error_type_bub_dens_gcm3, error_type_melt_dens_kgm3: 'Abs' or 'Perc'
|
374
|
-
whether given error is perc or absolute
|
375
|
-
|
376
|
-
error_dist_vol_perc_bub, error_dist_bub_dens_gcm3, error_dist_melt_dens_kgm3: 'normal' or 'uniform'
|
377
|
-
Distribution of simulated error
|
378
445
|
|
379
446
|
plot_figure: bool
|
380
447
|
Default true - plots a figure of the row indicated by fig_i (default 1st row, fig_i=0)
|
@@ -412,32 +479,37 @@ error_melt_dens_kgm3=0, error_type_melt_dens_kgm3='Abs', error_dist_melt_dens_kg
|
|
412
479
|
|
413
480
|
# Volume error distribution - if they give a volume percentage rather than dimensions
|
414
481
|
if error_vol_perc_bub is not None:
|
482
|
+
print('using error on the bubble volume percent, not the entered dimensions, as error_vol_perc_bub was not None')
|
415
483
|
# Easy peasy
|
416
484
|
Vol_with_noise=add_noise_to_variable(vol_perc_bub, error_vol_perc_bub,
|
417
485
|
error_type_vol_perc_bub, error_dist_vol_perc_bub, N_dup, neg_values, neg_threshold=0.0000000001)
|
418
486
|
|
487
|
+
|
419
488
|
else:
|
489
|
+
|
420
490
|
x_MI_with_noise=add_noise_to_variable(MI_x, error_MI_x,
|
421
491
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
422
492
|
|
423
493
|
y_MI_with_noise=add_noise_to_variable(MI_y, error_MI_y,
|
424
494
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
425
495
|
|
426
|
-
z_MI_with_noise=add_noise_to_variable(MI_z, error_MI_z,
|
427
|
-
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
428
|
-
|
429
496
|
x_VB_with_noise=add_noise_to_variable(VB_x, error_VB_x,
|
430
497
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
431
498
|
|
432
499
|
y_VB_with_noise=add_noise_to_variable(VB_y, error_VB_y,
|
433
500
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
434
501
|
|
502
|
+
|
503
|
+
z_MI_with_noise=add_noise_to_variable(MI_z, error_MI_z,
|
504
|
+
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
505
|
+
|
506
|
+
|
435
507
|
z_VB_with_noise=add_noise_to_variable(VB_z, error_VB_z,
|
436
508
|
error_type_dimension, error_dist_dimension, N_dup, neg_values, neg_threshold=0.0000000001)
|
437
509
|
|
438
510
|
|
439
|
-
Vol_VB_sphere_with_noise=const*x_VB_with_noise*y_VB_with_noise*z_VB_with_noise
|
440
|
-
Vol_MI_sphere_with_noise=const*x_MI_with_noise*y_MI_with_noise*z_MI_with_noise
|
511
|
+
Vol_VB_sphere_with_noise=const*x_VB_with_noise*y_VB_with_noise*z_VB_with_noise*(0.5)**3
|
512
|
+
Vol_MI_sphere_with_noise=const*x_MI_with_noise*y_MI_with_noise*z_MI_with_noise*(0.5)**3
|
441
513
|
Vol_with_noise=100* Vol_VB_sphere_with_noise/Vol_MI_sphere_with_noise
|
442
514
|
|
443
515
|
|
DiadFit/H2O_fitting.py
CHANGED
@@ -10,7 +10,7 @@ from dataclasses import dataclass
|
|
10
10
|
from typing import Tuple, Optional
|
11
11
|
from DiadFit.importing_data_files import *
|
12
12
|
from numpy import trapz
|
13
|
-
from scipy.integrate import
|
13
|
+
from scipy.integrate import simpson
|
14
14
|
##
|
15
15
|
def extract_xstal_MI_name(*, files, char_xstal, pos_xstal, char_MI, pos_MI,
|
16
16
|
prefix=True, str_prefix=" ", file_ext='.txt'):
|
@@ -872,30 +872,30 @@ fit_sil='poly', dpi=200):
|
|
872
872
|
ydat_sil=y_corr_sil
|
873
873
|
|
874
874
|
xspace_sil=xdat_sil[1]-xdat_sil[0]
|
875
|
-
area_trap =
|
876
|
-
area_simps =
|
875
|
+
area_trap = trapezoid(y_corr_sil, dx=xspace_sil)
|
876
|
+
area_simps = simpson(y_corr_sil, dx=xspace_sil)
|
877
877
|
# Just the LW area
|
878
878
|
xsil_LW=xdat_sil[(xdat_sil>LW[0]) & (xdat_sil<LW[1])]
|
879
879
|
y_corr_sil_LW=y_corr_sil[(xdat_sil>LW[0]) & (xdat_sil<LW[1])]
|
880
880
|
xspace_sil_LW=xsil_LW[1]-xsil_LW[0]
|
881
|
-
area_trap_LW=
|
882
|
-
area_simp_LW=
|
881
|
+
area_trap_LW=trapezoid(y_corr_sil_LW, dx=xspace_sil_LW)
|
882
|
+
area_simp_LW=simpson(y_corr_sil_LW, dx=xspace_sil_LW)
|
883
883
|
|
884
884
|
|
885
885
|
# Just the HW area
|
886
886
|
xsil_HW=xdat_sil[(xdat_sil>HW[0]) & (xdat_sil<HW[1])]
|
887
887
|
y_corr_sil_HW=y_corr_sil[(xdat_sil>HW[0]) & (xdat_sil<HW[1])]
|
888
888
|
xspace_sil_HW=xsil_HW[1]-xsil_HW[0]
|
889
|
-
area_trap_HW=
|
890
|
-
area_simp_HW=
|
889
|
+
area_trap_HW=trapezoid(y_corr_sil_HW, dx=xspace_sil_HW)
|
890
|
+
area_simp_HW=simpson(y_corr_sil_HW, dx=xspace_sil_HW)
|
891
891
|
|
892
892
|
# MW
|
893
893
|
if MW is not None:
|
894
894
|
xsil_MW=xdat_sil[(xdat_sil>MW[0]) & (xdat_sil<MW[1])]
|
895
895
|
y_corr_sil_MW=y_corr_sil[(xdat_sil>MW[0]) & (xdat_sil<MW[1])]
|
896
896
|
xspace_sil_MW=xsil_MW[1]-xsil_MW[0]
|
897
|
-
area_trap_MW=
|
898
|
-
area_simp_MW=
|
897
|
+
area_trap_MW=trapezoid(y_corr_sil_MW, dx=xspace_sil_MW)
|
898
|
+
area_simp_MW=simpson(y_corr_sil_MW, dx=xspace_sil_MW)
|
899
899
|
|
900
900
|
|
901
901
|
# Plotting what its doing
|
@@ -1155,8 +1155,8 @@ def fit_area_for_water_region(*, path, filename, Spectra=None, config1: water_bc
|
|
1155
1155
|
|
1156
1156
|
|
1157
1157
|
xspace_water=xdat_water[1]-xdat_water[0]
|
1158
|
-
area_trap =
|
1159
|
-
area_simps =
|
1158
|
+
area_trap = trapezoid(y_corr_water, dx=xspace_water)
|
1159
|
+
area_simps = simpson(y_corr_water, dx=xspace_water)
|
1160
1160
|
|
1161
1161
|
|
1162
1162
|
# Plotting what its doing
|
DiadFit/__init__.py
CHANGED
DiadFit/_version.py
CHANGED
DiadFit/densimeters.py
CHANGED
@@ -545,7 +545,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
545
545
|
|
546
546
|
|
547
547
|
|
548
|
-
elif lab=='CCMR':
|
548
|
+
elif lab=='CCMR' and temp=='SupCrit':
|
549
549
|
pickle_str_lowr='Lowrho_polyfit_data_CCMR.pkl'
|
550
550
|
with open(DiadFit_dir/pickle_str_lowr, 'rb') as f:
|
551
551
|
lowrho_pickle_data = pickle.load(f)
|
@@ -557,11 +557,12 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
557
557
|
# This gets the densimeter at high density.
|
558
558
|
pickle_str_highr='Highrho_polyfit_data_CCMR.pkl'
|
559
559
|
with open(DiadFit_dir/pickle_str_highr, 'rb') as f:
|
560
|
-
highrho_pickle_data = pickle.load(f)
|
560
|
+
highrho_pickle_data = pickle.load(f)
|
561
|
+
|
561
562
|
|
562
563
|
|
563
564
|
else:
|
564
|
-
raise TypeError('Lab name not recognised. enter CCMR
|
565
|
+
raise TypeError('Lab name not recognised. enter CCMR SupCrit, CMASS SupCrit, CMASS roomT (CCMR room T can be added on request to Penny)')
|
565
566
|
|
566
567
|
# this allocates the model
|
567
568
|
lowrho_model = lowrho_pickle_data['model']
|
@@ -627,7 +628,7 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
627
628
|
# If splitting is 0
|
628
629
|
zero=df['Corrected_Splitting']==0
|
629
630
|
|
630
|
-
|
631
|
+
# Cut off values -------------------------------------------
|
631
632
|
# Range for SC low density
|
632
633
|
min_lowD_SC_Split=df['Corrected_Splitting']>=102.7623598753032
|
633
634
|
max_lowD_SC_Split=df['Corrected_Splitting']<=103.1741034592534
|
@@ -643,6 +644,8 @@ CI_split=0.67, CI_neon=0.67, Ne_pickle_str=None, pref_Ne=None, Ne_err=None, cor
|
|
643
644
|
# Range for Room T high density
|
644
645
|
min_HD_RoomT_Split=df['Corrected_Splitting']>=104.407308904012
|
645
646
|
max_HD_RoomT_Split=df['Corrected_Splitting']<=105.1
|
647
|
+
|
648
|
+
|
646
649
|
# Impossible densities, room T
|
647
650
|
Imposs_lower_end=(df['Corrected_Splitting']>103.350311768435) & (df['Corrected_Splitting']<103.88)
|
648
651
|
# Impossible densities, room T
|
@@ -941,20 +944,29 @@ def merge_fit_files(path):
|
|
941
944
|
|
942
945
|
if os.path.exists(os.path.join(path, 'Weak_Diads.xlsx')):
|
943
946
|
grp1 = pd.read_excel(os.path.join(path, 'Weak_Diads.xlsx'))
|
947
|
+
grp1['Standard']='No'
|
944
948
|
else:
|
945
949
|
grp1 = None
|
946
950
|
|
947
951
|
if os.path.exists(os.path.join(path, 'Medium_Diads.xlsx')):
|
948
952
|
grp2 = pd.read_excel(os.path.join(path, 'Medium_Diads.xlsx'))
|
953
|
+
grp2['Standard']='No'
|
949
954
|
else:
|
950
955
|
grp2 = None
|
951
956
|
|
952
957
|
if os.path.exists(os.path.join(path, 'Strong_Diads.xlsx')):
|
953
958
|
grp3 = pd.read_excel(os.path.join(path, 'Strong_Diads.xlsx'))
|
959
|
+
grp3['Standard']='No'
|
954
960
|
else:
|
955
961
|
grp3 = None
|
962
|
+
|
963
|
+
if os.path.exists(os.path.join(path, 'Std_Diads.xlsx')):
|
964
|
+
grp4 = pd.read_excel(os.path.join(path, 'Std_Diads.xlsx'))
|
965
|
+
grp4['Standard']='Yes'
|
966
|
+
else:
|
967
|
+
grp4 = None
|
956
968
|
|
957
|
-
df2 = pd.concat([grp1, grp2, grp3], axis=0).reset_index(drop=True)
|
969
|
+
df2 = pd.concat([grp1, grp2, grp3, grp4], axis=0).reset_index(drop=True)
|
958
970
|
|
959
971
|
if discard is not None:
|
960
972
|
discard_cols=discard[discard.columns.intersection(df2.columns)]
|
DiadFit/diads.py
CHANGED
@@ -18,7 +18,7 @@ import matplotlib.patches as patches
|
|
18
18
|
import warnings as w
|
19
19
|
from tqdm import tqdm
|
20
20
|
from numpy import trapz
|
21
|
-
from scipy.integrate import
|
21
|
+
from scipy.integrate import simpson
|
22
22
|
from scipy.interpolate import interp1d
|
23
23
|
|
24
24
|
# Allowed models
|
@@ -725,7 +725,7 @@ def plot_peak_params(fit_params,
|
|
725
725
|
def filter_splitting_prominence(*, fit_params, data_y_all,
|
726
726
|
x_cord,
|
727
727
|
splitting_limits=[100, 107],
|
728
|
-
lower_diad1_prom=10, exclude_str):
|
728
|
+
lower_diad1_prom=10, exclude_str=None, str_filt=None):
|
729
729
|
""" Filters Spectra based on approximate splitting, draws a plot showing spectra to discard and those to keep
|
730
730
|
|
731
731
|
Parameters
|
@@ -746,6 +746,12 @@ def filter_splitting_prominence(*, fit_params, data_y_all,
|
|
746
746
|
Only keeps spectra that meet the splitting parameter, and have an absolute
|
747
747
|
diad1 prominence greater than this value (helps filter out other weird spectra)
|
748
748
|
|
749
|
+
exclude_str: str
|
750
|
+
Excludes files with this string.
|
751
|
+
|
752
|
+
str_filt: str
|
753
|
+
Filters just based on string in filename
|
754
|
+
|
749
755
|
Returns
|
750
756
|
--------------
|
751
757
|
fit_params_filt: pd.DataFrame
|
@@ -759,21 +765,30 @@ def filter_splitting_prominence(*, fit_params, data_y_all,
|
|
759
765
|
|
760
766
|
|
761
767
|
"""
|
768
|
+
if str_filt is not None:
|
769
|
+
filt=fit_params['filename'].str.contains(str_filt)
|
762
770
|
|
763
|
-
reas_split=(fit_params['approx_split'].between(splitting_limits[0], splitting_limits[1]))
|
764
|
-
reas_heigh=fit_params['Diad1_abs_prom']>lower_diad1_prom
|
765
|
-
if exclude_str is not None:
|
766
|
-
name_in_file=~fit_params['filename'].str.contains(exclude_str)
|
767
771
|
else:
|
768
|
-
name_in_file=reas_heigh
|
769
772
|
|
770
|
-
|
771
|
-
|
773
|
+
reas_split=(fit_params['approx_split'].between(splitting_limits[0], splitting_limits[1]))
|
774
|
+
reas_heigh=fit_params['Diad1_abs_prom']>lower_diad1_prom
|
775
|
+
|
776
|
+
if exclude_str is not None:
|
777
|
+
name_in_file=~fit_params['filename'].str.contains(exclude_str)
|
778
|
+
else:
|
779
|
+
name_in_file=reas_heigh
|
780
|
+
|
781
|
+
filt=reas_split&reas_heigh&name_in_file
|
782
|
+
|
783
|
+
fit_params_filt=fit_params.loc[filt].reset_index(drop=True)
|
784
|
+
fit_params_disc=fit_params.loc[~(filt)].reset_index(drop=True)
|
772
785
|
|
773
786
|
print('Keeping N='+str(len(fit_params_filt)))
|
774
787
|
print('Discarding N='+str(len(fit_params_disc)))
|
775
788
|
|
776
|
-
|
789
|
+
|
790
|
+
|
791
|
+
# Then apply to get data
|
777
792
|
data_y_filt=data_y_all[:, (filt)]
|
778
793
|
data_y_disc=data_y_all[:, ~(filt)]
|
779
794
|
|
@@ -804,17 +819,21 @@ def filter_splitting_prominence(*, fit_params, data_y_all,
|
|
804
819
|
Diff=np.nanmax(data_y_filt[:, i])-np.nanmin(data_y_filt[:, i])
|
805
820
|
av_prom_Keep=fit_params_filt['Diad1_abs_prom'].iloc[i]
|
806
821
|
prom_filt=prom_filt+av_prom_Keep
|
822
|
+
file=fit_params_filt['filename'].iloc[i]
|
807
823
|
ax2.plot(x_cord+i*5, (data_y_filt[:, i]-np.nanmin(data_y_filt[:, i]))/Diff+i/3, '-b', lw=0.5)
|
824
|
+
yplot=np.quantile((data_y_filt[:, i]-np.nanmin(data_y_filt[:, i]))/Diff+i/3, 0.65)
|
825
|
+
ax2.annotate(str(file), xy=(1450+i*5, yplot),
|
826
|
+
xycoords="data", fontsize=8, bbox=dict(facecolor='white', edgecolor='none', pad=2))
|
808
827
|
|
809
828
|
|
810
829
|
ax2.set_xlim([1250, 1450+i*5])
|
811
830
|
ax2.set_xticks([])
|
812
831
|
ax2.set_yticks([])
|
813
832
|
|
814
|
-
return fit_params_filt, data_y_filt, fit_params_disc, data_y_disc
|
833
|
+
return fit_params_filt.reset_index(drop=True), data_y_filt, fit_params_disc.reset_index(drop=True), data_y_disc
|
815
834
|
|
816
835
|
|
817
|
-
def identify_diad_group(*, fit_params, data_y, x_cord, filter_bool,y_fig_scale=0.1, grp_filter='Weak'):
|
836
|
+
def identify_diad_group(*, fit_params, data_y, x_cord, filter_bool,y_fig_scale=0.1, grp_filter='Weak', str_filt=None):
|
818
837
|
|
819
838
|
"""Sorts diads into two groups. Those meeting the 'filter_bool' criteria, and those not
|
820
839
|
meeting this criteria. Ones meeting the criteria are shown on the left hand plot,
|
@@ -853,6 +872,9 @@ def identify_diad_group(*, fit_params, data_y, x_cord, filter_bool,y_fig_scale=
|
|
853
872
|
|
854
873
|
|
855
874
|
"""
|
875
|
+
if str_filt is not None:
|
876
|
+
filt_name=~fit_params['filename'].str.contains(str_filt)
|
877
|
+
filt_bool=filt_name&filt_bool
|
856
878
|
|
857
879
|
if np.shape(data_y)[1]==0:
|
858
880
|
Group1_df=pd.DataFrame().reindex_like(fit_params)
|
@@ -3835,8 +3857,8 @@ path=None, filename=None, filetype=None,
|
|
3835
3857
|
|
3836
3858
|
|
3837
3859
|
xspace_sil=x_new[1]-x_new[0]
|
3838
|
-
area_trap =
|
3839
|
-
area_simps =
|
3860
|
+
area_trap = trapezoid(Baseline_ysub_sil, dx=xspace_sil)
|
3861
|
+
area_simps = simpson(Baseline_ysub_sil, dx=xspace_sil)
|
3840
3862
|
|
3841
3863
|
|
3842
3864
|
|