-
Notifications
You must be signed in to change notification settings - Fork 4
/
MATE_BATCH
executable file
·4465 lines (3361 loc) · 183 KB
/
MATE_BATCH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
import os
core_path_ext = os.path.join(os.path.dirname(os.path.abspath(__file__)) , 'mate_src')
import sys, csv, itertools, math, warnings
import numpy as np
from scipy.interpolate import interp1d, griddata
from scipy import optimize
from mtpy.utils import gis_tools as gis_tools
#Importing external functions
sys.path.append(core_path_ext)
from cond_models.dry_odd import * #Dry conductivity of NAMS with specialized functions
from cond_models.ol_wet_odd import * #Whole models of olivine with specialized functions
from cond_models.ol_diffusion import * #Hydrogen diffusion functions of olivine
from cond_models.opx_wet_odd import * #Whole models of opx with specialized functions
from cond_models.opx_diffusion import * #Hydrogen diffusion functions of opx
from cond_models.cpx_wet_odd import * #Whole models of cpx with specialized functions
from cond_models.cpx_diffusion import * #Hydrogen diffusion functions of cpx
from cond_models.gt_wet_odd import * #Whole models of garnet with specialized functions
from cond_models.gt_diffusion import * #Hydrogen diffusion functions of garnet
from cond_models.pl_odd import * #Conductivity functions of phlogopites
from cond_models.amp_odd import * #Conductivity functions of amphiboles
from cond_models.melt_odd import * #Conductivity functions of melts
from cond_models.sp_chr_odd import * #Conductivity functions of spinel-chromites
from min_sol.ol_sol import * #Olivine solubility models
warnings.filterwarnings("ignore", category=RuntimeWarning) #ignoring many RuntimeWarning printouts that are useless
class bcolors:
BLUE = '\033[94m'
GREEN = '\033[92m'
RED = '\033[91m'
B = '\033[0m'
NC ='\x1b[0m'
#Version 1.5, June. 2023.
#MATE - (M)antle (A)nalysis (T)ools for (E)lectromagnetics
#Program written by Sinan Ozaydin (School of Geosciences, University of Sydney
#, Australia).
#Indentation method: hard tabs ('\t')
#Works with Python3
#Required libraries: numpy,scipy,matplotlib,PyQt5
#optional libraries: mtpy
#Installation of libraries:
#In Linux (mac included) distros through terminal:
#pip install numpy,scipy,matplotlib,PyQt5
#In Windows skip sudo.
print(bcolors.GREEN + '#############################################')
print(' ')
print(' ')
print(' ')
print(bcolors.GREEN + ' MATE_BATCH 1.5')
print(' ')
print(bcolors.BLUE + ' Mantle Analysis Tools')
print(' for')
print(' Electromagnetics')
print(' ')
print(' ')
print(' ')
print(bcolors.GREEN + '#############################################')
print(bcolors.BLUE + 'developed by Sinan Ozaydin,' + bcolors.RED + ' School of Geosciences, University of Sydney')
print(' ')
print(' ')
print(bcolors.NC + 'for questions, email: [email protected] or [email protected]')
print('Initializing the software...')
class MATE_BATCH(object):
def __init__(self, core_path = core_path_ext):
args_input = sys.argv
self.core_path = core_path
if len(args_input) == 1:
print('You have to run the program with options:')
print('Current Methods:')
print(' ')
print(bcolors.RED + '1. -modem')
print('2. -mtNC')
print('3. -forward')
print(' ')
print(' ')
print(bcolors.NC + 'To have more information for each method. Just run the program with the option only like MATE_BATCH -modem ')
sys.exit()
if args_input[1] == '-modem':
try:
self.setup_path = args_input[2]
self.comp_path = args_input[3]
self.rho_path = args_input[4]
self.dat_path = args_input[5]
self.T_path = args_input[6]
except IndexError:
print('This options reads a ModEM output model and data file calculates\
water content with the input temperature, composition and other parametrisations.')
print(' ')
print('Not enough inputs are entered for -modem method, five input files are needed...')
print(' ')
print('1. Parameter setup file (get the output from MATE gui)')
print('2. Composition file (e.g., Lherzolite.csv)')
print('3. MT Model File (e.g. ModEM rho)')
print('4. MT Data File (e.g. ModEM dat)')
print('5. Thermal model, .xyz format (The file has to have these headers in same names: id Longitude Latitude Depth Temperature, with a space delimited format.)')
print(' ')
print('Exiting the program... Try again with correct input format')
sys.exit()
self.computing_style = args_input[1]
self.read_batch_parameter_file()
self.read_cond_models()
self.read_cond_dry_models()
self.read_params()
#Initializing the non iterative parametrisations
self.adjust_composition()
self.calculate_pressure()
self.read_ModEM_dat()
self.read_ModEM_rho()
self.get_T()
self.define_profile_()
self.calculate_water(method = 'array',idx = None) #initial water calculation
#solving for the entered resistivity and temperature
self.solve_water_for_model()
#writing out water data
self.write_data()
elif args_input[1] == '-mtNC':
try:
self.setup_path = args_input[2]
self.comp_path = args_input[3]
self.nc_path = args_input[4]
self.T_path = args_input[5]
except IndexError:
print('This option reads a 3D MT model in nc format and calculates\
water content with the input temperature, composition and other parametrisations.')
print('NC format is neccesarily linked to just xyz(lat-long-depth)-rho format in NC format. Usually favoured by the USGS databases.')
print(' ')
print('Not enough inputs are entered for -modem method, five input files are needed...')
print(' ')
print('1. Parameter setup file (get the output from MATE gui)')
print('2. Composition file (e.g., Lherzolite.csv)')
print('3. MT Model File (e.g. NC format xyz lat-long-depth file, IRIS website USARRAY models)')
print('4. Thermal model, .xyz format (The file has to have these headers in same names: id Longitude Latitude Depth Temperature, with a space delimited format.)')
print(' ')
print('Exiting the program... Try again with correct input format')
sys.exit()
self.computing_style = args_input[1]
self.read_batch_parameter_file()
self.read_cond_models()
self.read_cond_dry_models()
self.read_params()
#Initializing the non iterative parametrisations
self.adjust_composition()
self.calculate_pressure()
self.read_MT_NC()
self.get_T()
self.define_profile_()
self.calculate_water(method = 'array',idx = None) #initial water calculation
#solving for the entered resistivity and temperature
self.solve_water_for_model()
#writing out water data
self.write_data()
elif args_input[1] == '-forward':
try:
self.setup_path = args_input[2]
self.calc_path = args_input[3]
except IndexError:
print('This options reads a calculation file\
and outputs a single forward calculation.')
print(' ')
print('Not enough inputs are entered for -forward method, two extra input files are needed...')
print(' ')
print(' ')
print('1. Parameter setup file (get the output from MATE gui)')
print('2. Calculation file (see an example from example_single_calculations folder from the repository.)')
sys.exit()
self.computing_style = args_input[1]
self.read_batch_parameter_file()
self.read_cond_models()
self.read_cond_dry_models()
self.read_params()
self.idx_moho = 0
self.read_single_calculation_file()
self.calculate_water(method = 'array',idx = None)
self.calculate_single_conductivities()
self.write_data_single_forward()
def read_csv(self,filename,delim):
#Simple function for reading csv files and give out filtered output for given delimiter (delim)
file_obj = open(filename,'rt',encoding = "utf8") #Creating file object
file_csv = csv.reader(file_obj,delimiter = delim) #Reading the file object with csv module, delimiter assigned to ','
data = [] #Creating empty array to append data
#Appending data from csb object
for row in file_csv:
data.append(row)
#Filtering data for None elements read.
for j in range(0,len(data)):
data[j] = list(filter(None,data[j]))
data = list(filter(None,data))
return data
def read_batch_parameter_file(self):
self.setup_data = self.read_csv(self.setup_path, delim = ',')
self.moho = float(self.setup_data[1][1])
self.lab = float(self.setup_data[2][1])
self.dz = float(self.setup_data[3][1])
self.part_px_method = str(self.setup_data[4][1])
self.opx_part_select = int(self.setup_data[5][1])
self.cpx_part_select = int(self.setup_data[6][1])
self.px_part_select = int(self.setup_data[7][1])
self.gt_part_select = int(self.setup_data[8][1])
self.amp_part_select = int(self.setup_data[9][1])
self.pl_part_select = int(self.setup_data[10][1])
self.ol_melt_part_select = int(self.setup_data[11][1])
self.opx_melt_part_select = int(self.setup_data[12][1])
self.cpx_melt_part_select = int(self.setup_data[13][1])
self.gt_melt_part_select = int(self.setup_data[14][1])
self.hydr_part_method = int(self.setup_data[15][1])
self.w_inp_method = str(self.setup_data[16][1])
self.sol_method = int(self.setup_data[17][1])
self.ol_sol_calib = int(self.setup_data[18][1])
self.ol_calib = int(self.setup_data[19][1])
self.px_calib = int(self.setup_data[20][1])
self.al_method = str(self.setup_data[21][1])
self.amph_stab_select = int(self.setup_data[22][1])
self.sol_model_pref_select = int(self.setup_data[23][1])
self.amp_method = str(self.setup_data[24][1])
self.pl_method = str(self.setup_data[25][1])
self.phs_mix_method = int(self.setup_data[26][1])
self.phs_melt_mix_method = int(self.setup_data[27][1])
self.ol_dry_selection = int(self.setup_data[28][1])
self.opx_dry_selection = int(self.setup_data[29][1])
self.cpx_dry_selection = int(self.setup_data[30][1])
self.gt_dry_selection = int(self.setup_data[31][1])
self.ol_cond_selection = int(self.setup_data[32][1])
self.opx_cond_selection = int(self.setup_data[33][1])
self.cpx_cond_selection = int(self.setup_data[34][1])
self.gt_cond_selection = int(self.setup_data[35][1])
self.amp_cond_selection = int(self.setup_data[36][1])
self.pl_cond_selection = int(self.setup_data[37][1])
self.sp_chr_cond_selection = int(self.setup_data[38][1])
self.melt_cond_selection = int(self.setup_data[39][1])
self.px_cond_method = int(self.setup_data[40][1])
self.D_gb = float(self.setup_data[41][1])
self.delta = float(self.setup_data[42][1])
self.GB_ol_select = int(self.setup_data[43][1])
self.GB_gt_select = int(self.setup_data[44][1])
self.o2_buffer = int(self.setup_data[45][1])
self.water_end = self.setup_data[46][1]
if self.water_end == 'False':
self.water_end = False
elif self.water_end == 'True':
self.water_end = True
self.model_method_list = ['Proton+Polaron+Ionic', 'Proton Only']
self.model_method_ol = int(self.setup_data[47][1])
self.model_method_opx = int(self.setup_data[48][1])
self.model_method_cpx = int(self.setup_data[49][1])
self.model_method_gt = int(self.setup_data[50][1])
self.model_method = [self.model_method_ol,self.model_method_opx,self.model_method_cpx,self.model_method_gt]
self.solidus_dry_model_selection = int(self.setup_data[51][1])
self.solidus_wet_model_selection = int(self.setup_data[52][1])
self.solidus_carbon_model_selection = int(self.setup_data[53][1])
self.melt_fraction_function_selection = int(self.setup_data[54][1])
#Additional PARAMETERS
self.melt_fraction_function_names = ['Hirschmann2009 dF/dT = -40P + 450']
self.melt_fraction_functions = ['(-40 * self.p) + 450.0']
self.mineral_partitions_calculated = False
self.melt_partitions_calculated = False
self.water_end = False
def read_cond_models(self):
#A function that reads conductivity model files and get the data.
self.ol_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'ol.csv'),delim = ',')
self.opx_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'opx.csv'),delim = ',')
self.cpx_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'cpx.csv'),delim = ',')
self.gt_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'gt.csv'),delim = ',')
self.sp_chr_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'sp_chr.csv'),delim = ',')
self.amp_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'amp.csv'),delim = ',')
self.pl_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'phlg.csv'),delim = ',')
self.melt_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'melt.csv'),delim = ',')
self.cond_data_array = [self.ol_cond_data,self.opx_cond_data,self.cpx_cond_data,self.gt_cond_data,self.amp_cond_data,self.pl_cond_data,self.sp_chr_cond_data,self.melt_cond_data]
len_ol = len(self.ol_cond_data) - 1
len_opx = len(self.opx_cond_data) - 1
len_cpx = len(self.cpx_cond_data) - 1
len_gt = len(self.gt_cond_data) - 1
len_sp_chr = len(self.sp_chr_cond_data) - 1
len_amp = len(self.amp_cond_data) - 1
len_pl = len(self.pl_cond_data) - 1
len_melt = len(self.melt_cond_data) - 1
#Creating empty arrays for appending new data.
self.name = [[None] * len_ol , [None] * len_opx,[None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.type = [[None] * len_ol , [None] * len_opx,[None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.t_min = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.t_max = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.p_min = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.p_max = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.w_calib = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.mg_cond = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl, [None] * len_sp_chr, [None] * len_melt]
self.sigma_i = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.sigma_i_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.h_i = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.h_i_err =[[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.sigma_pol = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.sigma_pol_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.h_pol = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.h_pol_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.sigma_p = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.sigma_p_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.h_p = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.h_p_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.r = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.r_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.alpha_p = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.alpha_p_err = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.wtype = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
self.dens_mat = [[None] * len_ol , [None] * len_opx, [None] * len_cpx, [None] * len_gt,[None] * len_amp,[None] * len_pl,[None] * len_sp_chr, [None] * len_melt]
#Filling up the arrays.
for i in range(0,len(self.type)):
count = 1
for j in range(0,len(self.type[i])):
self.name[i][count-1] = self.cond_data_array[i][count][0]
self.type[i][count-1] = self.cond_data_array[i][count][1]
self.t_min[i][count-1] = float(self.cond_data_array[i][count][2])
self.t_max[i][count-1] = float(self.cond_data_array[i][count][3])
self.p_min[i][count-1] = float(self.cond_data_array[i][count][4])
self.p_max[i][count-1] = float(self.cond_data_array[i][count][5])
self.w_calib[i][count-1] = int(self.cond_data_array[i][count][6])
self.mg_cond[i][count-1] = float(self.cond_data_array[i][count][7])
self.sigma_i[i][count-1] = float(self.cond_data_array[i][count][8])
self.sigma_i_err[i][count-1] = float(self.cond_data_array[i][count][9])
self.h_i[i][count-1] = float(self.cond_data_array[i][count][10])
self.h_i_err[i][count-1] = float(self.cond_data_array[i][count][11])
self.sigma_pol[i][count-1] = float(self.cond_data_array[i][count][12])
self.sigma_pol_err[i][count-1] = float(self.cond_data_array[i][count][13])
self.h_pol[i][count-1] = float(self.cond_data_array[i][count][14])
self.h_pol_err[i][count-1] = float(self.cond_data_array[i][count][15])
self.sigma_p[i][count-1] = float(self.cond_data_array[i][count][16])
self.sigma_p_err[i][count-1] = float(self.cond_data_array[i][count][17])
self.h_p[i][count-1] = float(self.cond_data_array[i][count][18])
self.h_p_err[i][count-1] = float(self.cond_data_array[i][count][19])
self.r[i][count-1] = float(self.cond_data_array[i][count][20])
self.r_err[i][count-1] = float(self.cond_data_array[i][count][21])
self.alpha_p[i][count-1] = float(self.cond_data_array[i][count][22])
self.alpha_p_err[i][count-1] = float(self.cond_data_array[i][count][23])
self.wtype[i][count-1] = int(self.cond_data_array[i][count][24])
self.dens_mat[i][count-1] = float(self.cond_data_array[i][count][25])
count += 1
def read_cond_dry_models(self):
#A function that reads the dry conductivity models from the external csv files.
self.ol_dry_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'ol_dry.csv'),delim = ',')
self.opx_dry_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'opx_dry.csv'),delim = ',')
self.cpx_dry_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'cpx_dry.csv'),delim = ',')
self.gt_dry_cond_data = self.read_csv(os.path.join(self.core_path, 'cond_models' , 'gt_dry.csv'),delim = ',')
self.cond_dry_data_array = [self.ol_dry_cond_data,self.opx_dry_cond_data,self.cpx_dry_cond_data,self.gt_dry_cond_data]
self.name_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.type_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.t_min_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.t_max_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.p_min_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.p_max_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.mg_cond_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.sigma_i_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.sigma_i_dry_err = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.h_i_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.h_i_dry_err =[[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.sigma_pol_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.sigma_pol_dry_err = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.h_pol_dry = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
self.h_pol_dry_err = [[None] * (len(self.ol_dry_cond_data)-1) , [None] * (len(self.opx_dry_cond_data) - 1),[None] * (len(self.cpx_dry_cond_data) - 1), [None] * (len(self.gt_dry_cond_data)-1)]
for i in range(0,len(self.cond_dry_data_array)):
count = 1
for j in range(0,len(self.cond_dry_data_array[i])-1):
self.name_dry[i][count-1] = self.cond_dry_data_array[i][count][0]
self.type_dry[i][count-1] = self.cond_dry_data_array[i][count][1]
self.t_min_dry[i][count-1] = float(self.cond_dry_data_array[i][count][2])
self.t_max_dry[i][count-1] = float(self.cond_dry_data_array[i][count][3])
self.p_min_dry[i][count-1] = float(self.cond_dry_data_array[i][count][4])
self.p_max_dry[i][count-1] = float(self.cond_dry_data_array[i][count][5])
self.mg_cond_dry[i][count-1] = float(self.cond_dry_data_array[i][count][6])
self.sigma_i_dry[i][count-1] = float(self.cond_dry_data_array[i][count][7])
self.sigma_i_dry_err[i][count-1] = float(self.cond_dry_data_array[i][count][8])
self.h_i_dry[i][count-1] = float(self.cond_dry_data_array[i][count][9])
self.h_i_dry_err[i][count-1] = float(self.cond_dry_data_array[i][count][10])
self.sigma_pol_dry[i][count-1] = float(self.cond_dry_data_array[i][count][11])
self.sigma_pol_dry_err[i][count-1] = float(self.cond_dry_data_array[i][count][12])
self.h_pol_dry[i][count-1] = float(self.cond_dry_data_array[i][count][13])
self.h_pol_dry_err[i][count-1] = float(self.cond_dry_data_array[i][count][14])
count += 1
def read_params(self):
#READING THE PARAMETERS IN PARAMS.CSV WHICH ARE GENERAL PHYSICAL CONSTANTS
#AND PROPERTIES OF MATERIALS
params_dat = self.read_csv(os.path.join(self.core_path, 'params.csv'), delim = ',')
self.g = float(params_dat[0][1]) # in kg/
self.R = float(params_dat[1][1])
self.rho_crust = float(params_dat[2][1])
self.rho_mantle = float(params_dat[3][1])
self.rho_forst = float(params_dat[4][1])
self.rho_fayal = float(params_dat[5][1])
self.rho_enst = float(params_dat[6][1])
self.rho_ferrosil = float(params_dat[7][1])
self.rho_diop = float(params_dat[8][1])
self.rho_heden = float(params_dat[9][1])
self.rho_pyrop = float(params_dat[10][1])
self.rho_alm = float(params_dat[11][1])
self.rho_sp_chr = float(params_dat[12][1])
self.rho_amph = float(params_dat[13][1])
self.rho_phlg = float(params_dat[14][1])
self.avog = float(params_dat[15][1])
self.boltz = float(params_dat[16][1])
self.el_q = float(params_dat[17][1])
self.spreadsheet = str(params_dat[18][1])
self.mu = 4.0 * np.pi * 10**(-7)
#READING THE GEOTHERM CALCULATION PARAMETERS FROM HASTEROK AND CHAPMAN (2011) -
hasterok_vanilla_dat = self.read_csv(os.path.join(self.core_path, 'thermal', 'hasterok_vanilla.csv'), delim = ',')
self.k0_upper_1 = float(hasterok_vanilla_dat[0][1])
self.k0_upper_2 = float(hasterok_vanilla_dat[1][1])
self.k0_mid_1 = float(hasterok_vanilla_dat[2][1])
self.k0_mid_2 = float(hasterok_vanilla_dat[3][1])
self.k0_low_1 = float(hasterok_vanilla_dat[4][1])
self.k0_low_2 =float(hasterok_vanilla_dat[5][1])
self.k0_mantle_sp = float(hasterok_vanilla_dat[6][1])
self.k0_mantle_gt = float(hasterok_vanilla_dat[7][1])
self.k1_upper_1 = float(hasterok_vanilla_dat[8][1])
self.k1_upper_2 = float(hasterok_vanilla_dat[9][1])
self.k1_mid_1 = float(hasterok_vanilla_dat[10][1])
self.k1_mid_2 = float(hasterok_vanilla_dat[11][1])
self.k1_low_1 = float(hasterok_vanilla_dat[12][1])
self.k1_low_2 = float(hasterok_vanilla_dat[13][1])
self.k1_mantle_sp = float(hasterok_vanilla_dat[14][1])
self.k1_mantle_gt =float(hasterok_vanilla_dat[15][1])
self.k2_upper_1 = float(hasterok_vanilla_dat[16][1])
self.k2_upper_2 = float(hasterok_vanilla_dat[17][1])
self.k2_mid_1 = float(hasterok_vanilla_dat[18][1])
self.k2_mid_2 = float(hasterok_vanilla_dat[19][1])
self.k2_low_1 = float(hasterok_vanilla_dat[20][1])
self.k2_low_2 = float(hasterok_vanilla_dat[21][1])
self.k2_mantle_sp = float(hasterok_vanilla_dat[22][1])
self.k2_mantle_gt = float(hasterok_vanilla_dat[23][1])
self.k3_upper_1 = float(hasterok_vanilla_dat[24][1])
self.k3_upper_2 = float(hasterok_vanilla_dat[25][1])
self.k3_mid_1 = float(hasterok_vanilla_dat[26][1])
self.k3_mid_2 = float(hasterok_vanilla_dat[27][1])
self.k3_low_1 = float(hasterok_vanilla_dat[28][1])
self.k3_low_2 = float(hasterok_vanilla_dat[29][1])
self.k3_mantle_sp = float(hasterok_vanilla_dat[30][1])
self.k3_mantle_gt = float(hasterok_vanilla_dat[31][1])
self.t_criterion = float(hasterok_vanilla_dat[32][1])
self.thermal_data = self.read_csv(os.path.join(self.core_path, 'thermal', 'thermal.csv'), delim = ',')
self.k_0 = []
self.k_1 = []
self.k_2 = []
self.n_thermal = []
self.lambda_r_max = []
self.omega_thermal = []
self.T_ref = []
self.rho_thermal = []
self.K_T = []
self.K_T2 = []
for i in range(1,len(self.thermal_data)):
self.k_0.append(float(self.thermal_data[i][1]))
self.k_1.append(float(self.thermal_data[i][2]))
self.k_2.append(float(self.thermal_data[i][3]))
self.n_thermal.append(float(self.thermal_data[i][4]))
self.lambda_r_max.append(float(self.thermal_data[i][5]))
self.omega_thermal.append(float(self.thermal_data[i][6]))
self.T_ref.append(float(self.thermal_data[i][7]))
self.rho_thermal.append(float(self.thermal_data[i][8]))
self.K_T.append(float(self.thermal_data[i][9]))
self.K_T2.append(float(self.thermal_data[i][10]))
#WATER PARTITIONING PARAMETERS OF PYROXENES
self.px_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'px_part.csv'), delim = ',')
self.d_px_items = []
self.d_px_type = []
self.d_px_function = []
self.d_px_function_2 = []
self.d_px_change = []
for i in range(4,len(self.px_data)):
self.d_px_items.append("Type " + self.px_data[i][1] + ' - ' + self.px_data[i][-1])
self.d_px_type.append(self.px_data[i][1])
if self.px_data[i][1] == '0' or self.px_data[i][1] == '1' or self.px_data[i][1] == '3':
self.d_px_function.append(self.px_data[i][2])
self.d_px_function_2.append(None)
self.d_px_change.append(None)
elif self.px_data[i][1] == '2':
self.d_px_function.append(self.px_data[i][2])
self.d_px_function_2.append(self.px_data[i][3])
self.d_px_change.append(self.px_data[i][4])
elif self.px_data[i][1] == '4':
self.d_px_function.append(self.px_data[i][2]) #In this case only a constant value
self.d_px_function_2.append(None) #In this case error rate
self.d_px_change.append(None)
self.px_part_select = 0
#WATER PARTITIONING PARAMETERS OF OPX
self.opx_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'opx_part.csv'), delim = ',')
self.d_opx_items = []
self.d_opx_type = []
self.dopx_function = []
self.dopx_function_2 = []
self.dopx_change = []
for i in range(1,len(self.opx_data)):
self.d_opx_items.append("Type " + self.opx_data[i][1] + ' - ' + self.opx_data[i][-1])
self.d_opx_type.append(self.opx_data[i][1])
self.dopx_function.append(self.opx_data[i][2])
self.dopx_function_2.append(self.opx_data[i][3])
self.dopx_change.append(float(self.opx_data[i][4]))
self.opx_part_select = 0
self.opx_display = self.d_opx_items[self.opx_part_select]
#WATER PARTITIONIN PARAMETERS OF CPX
self.cpx_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'cpx_part.csv'), delim = ',')
self.d_cpx_items = []
self.d_cpx_type = []
self.dcpx_function = []
self.dcpx_function_2 = []
self.dcpx_change = []
for i in range(1,len(self.cpx_data)):
self.d_cpx_items.append("Type " + self.cpx_data[i][1] + ' - ' +self.cpx_data[i][-1])
self.d_cpx_type.append(self.cpx_data[i][1])
self.dcpx_function.append(self.cpx_data[i][2])
self.dcpx_function_2.append(self.cpx_data[i][3])
self.dcpx_change.append(float(self.cpx_data[i][4]))
self.cpx_part_select = 0
self.cpx_display = self.d_cpx_items[self.cpx_part_select]
#WATER PARTITIONING PARAMETERS OF GT
self.gt_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'gt_part.csv'), delim = ',')
self.d_gt_items = []
self.d_gt_type = []
self.d_gt_function = []
self.d_gt_function_2 = []
for i in range(1,len(self.gt_data)):
self.d_gt_items.append("Type " + self.gt_data[i][1] + ' - ' +self.gt_data[i][-1])
self.d_gt_type.append(self.gt_data[i][1])
self.d_gt_function.append(self.gt_data[i][2])
self.d_gt_function_2.append(self.gt_data[i][3])
self.gt_part_select = 0
self.gt_display = self.d_gt_items[self.gt_part_select]
#WATER PARTITIONING PARAMETERS OF AMP
self.amp_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'amp_part.csv'), delim = ',')
self.d_amp_items = []
self.d_amp_type = []
self.d_amp_function = []
self.d_amp_function_2 = []
for i in range(1,len(self.amp_data)):
self.d_amp_items.append("Type " + self.amp_data[i][1] + ' - ' +self.amp_data[i][-1])
self.d_amp_type.append(self.amp_data[i][1])
self.d_amp_function.append(self.amp_data[i][2])
self.d_amp_function_2.append(self.amp_data[i][3])
self.amp_part_select = 0
self.amp_display = self.d_amp_items[self.amp_part_select]
#WATER PARTITIONING PARAMETERS OF PHLG
self.pl_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'pl_part.csv'), delim = ',')
self.d_pl_items = []
self.d_pl_type = []
self.d_pl_function = []
self.d_pl_function_2 = []
for i in range(1,len(self.pl_data)):
self.d_pl_items.append("Type " + self.pl_data[i][1] + ' - ' +self.pl_data[i][-1])
self.d_pl_type.append(self.pl_data[i][1])
self.d_pl_function.append(self.pl_data[i][2])
self.d_pl_function_2.append(self.pl_data[i][3])
self.pl_part_select = 0
self.pl_display = self.d_pl_items[self.pl_part_select]
#WATER PARTITIONING PARAMETERS OF OLIVINE AND MELT
self.ol_melt_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'ol_melt_part.csv'), delim = ',')
self.d_melt_ol_items = []
self.d_melt_ol_type = []
self.d_melt_ol_function = []
self.d_melt_ol_function_2 = []
for i in range(1,len(self.pl_data)):
self.d_melt_ol_items.append("Type " + self.ol_melt_data[i][1] + ' - ' +self.ol_melt_data[i][-1])
self.d_melt_ol_type.append(self.ol_melt_data[i][1])
self.d_melt_ol_function.append(self.ol_melt_data[i][2])
self.d_melt_ol_function_2.append(self.ol_melt_data[i][3])
self.ol_melt_part_select = 0
self.ol_melt_display = self.d_melt_ol_items[self.ol_melt_part_select]
#WATER PARTITIONING PARAMETERS OF ORTHOPYROXENE AND MELT
self.opx_melt_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'opx_melt_part.csv'), delim = ',')
self.d_melt_opx_items = []
self.d_melt_opx_type = []
self.d_melt_opx_function = []
self.d_melt_opx_function_2 = []
self.d_melt_opx_change = []
for i in range(1,len(self.pl_data)):
self.d_melt_opx_items.append("Type " + self.opx_melt_data[i][1] + ' - ' +self.opx_melt_data[i][-1])
self.d_melt_opx_type.append(self.opx_melt_data[i][1])
self.d_melt_opx_function.append(self.opx_melt_data[i][2])
self.d_melt_opx_function_2.append(self.opx_melt_data[i][3])
self.d_melt_opx_change.append(self.opx_melt_data[i][4])
self.opx_melt_part_select = 0
self.opx_melt_display = self.d_melt_opx_items[self.opx_melt_part_select]
#WATER PARTITIONING PARAMETERS OF CLINOPYROXENE AND MELT
self.cpx_melt_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'cpx_melt_part.csv'), delim = ',')
self.d_melt_cpx_items = []
self.d_melt_cpx_type = []
self.d_melt_cpx_function = []
self.d_melt_cpx_function_2 = []
self.d_melt_cpx_change = []
for i in range(1,len(self.pl_data)):
self.d_melt_cpx_items.append("Type " + self.cpx_melt_data[i][1] + ' - ' +self.cpx_melt_data[i][-1])
self.d_melt_cpx_type.append(self.cpx_melt_data[i][1])
self.d_melt_cpx_function.append(self.cpx_melt_data[i][2])
self.d_melt_cpx_function_2.append(self.cpx_melt_data[i][3])
self.d_melt_cpx_change.append(self.cpx_melt_data[i][4])
self.cpx_melt_part_select = 0
self.cpx_melt_display = self.d_melt_cpx_items[self.cpx_melt_part_select]
#WATER PARTITIONING PARAMETERS OF GARNET AND MELT
self.gt_melt_data = self.read_csv(os.path.join(self.core_path, 'water_part', 'gt_melt_part.csv'), delim = ',')
self.d_melt_gt_items = []
self.d_melt_gt_type = []
self.d_melt_gt_function = []
self.d_melt_gt_function_2 = []
for i in range(1,len(self.pl_data)):
self.d_melt_gt_items.append("Type " + self.gt_melt_data[i][1] + ' - ' +self.gt_melt_data[i][-1])
self.d_melt_gt_type.append(self.gt_melt_data[i][1])
self.d_melt_gt_function.append(self.gt_melt_data[i][2])
self.d_melt_gt_function_2.append(self.gt_melt_data[i][3])
self.gt_melt_part_select = 0
self.gt_melt_display = self.d_melt_gt_items[self.gt_melt_part_select]
#AL-opx solubility models from alopx.csv
self.al_model_data = self.read_csv(os.path.join(self.core_path, 'al_models', 'alopx.csv'),delim = ',')
self.al_opx_model_items = []
self.al_opx_model_function = []
self.al_opx_model_pcrit = []
self.al_opx_model_display = []
for i in range(1,len(self.al_model_data)):
self.al_opx_model_items.append(self.al_model_data[i][0])
self.al_opx_model_function.append(self.al_model_data[i][1])
self.al_opx_model_pcrit.append(float(self.al_model_data[i][2]))
self.al_opx_model_display.append(self.al_model_data[i][3])
#Amphibole stability fileds from amp_st.csv
self.amp_st_data = self.read_csv(os.path.join(self.core_path, 'min_stab', 'amp_st.csv'),delim = ',')
self.amph_stab_list = []
self.P_amph = []
for i in range(1,len(self.amp_st_data)):
self.amph_stab_list.append(self.amp_st_data[i][0])
self.P_amph.append(float(self.amp_st_data[i][1]))
#Reading ol_gb.csv where grainboundary diffusion of olivine resides.
self.ol_gb_data = self.read_csv(os.path.join(self.core_path, 'cond_models', 'ol_gb.csv'),delim = ',')
self.GB_ol_list = []
self.D_ol_GB = []
self.E_ol_GB = []
self.E_err_ol_GB = []
self.ol_calib_GB = []
for i in range(1,len(self.ol_gb_data)):
self.GB_ol_list.append(self.ol_gb_data[i][0])
self.D_ol_GB.append(float(self.ol_gb_data[i][1]))
self.E_ol_GB.append(float(self.ol_gb_data[i][2]))
self.E_err_ol_GB.append(float(self.ol_gb_data[i][3]))
self.ol_calib_GB.append(int(self.ol_gb_data[i][4]))
#Reading gt_gb.csv where grainboundary diffusion of garnet-spinel resides.
self.gt_gb_data = self.read_csv(os.path.join(self.core_path, 'cond_models', 'gt_gb.csv'),delim = ',')
self.GB_gt_list = []
self.D_gt_GB = []
self.E_gt_GB = []
self.E_err_gt_GB = []
for i in range(1,len(self.gt_gb_data)):
self.GB_gt_list.append(self.gt_gb_data[i][0])
self.D_gt_GB.append(float(self.gt_gb_data[i][1]))
self.E_gt_GB.append(float(self.gt_gb_data[i][2]))
self.E_err_gt_GB.append(float(self.gt_gb_data[i][3]))
#Reading ol_sol.csv to take solubility model information
self.ol_sol_data = self.read_csv(os.path.join(self.core_path, 'min_sol', 'ol_sol.csv'),delim = ',')
self.name_ol_sol = []
self.ol_sol_fug_dep = []
self.ol_sol_wcalib = []
for i in range(1,len(self.ol_sol_data)):
self.name_ol_sol.append(self.ol_sol_data[i][0])
self.ol_sol_fug_dep.append(self.ol_sol_data[i][1])
self.ol_sol_wcalib.append(self.ol_sol_data[i][2])
#RETURNHERE - add the other lists once you decide
#Reading calibration correction factors from the file.
correction_factor_dat = self.read_csv(os.path.join(self.core_path, 'water_calib.csv'), delim = ',')
self.pat2with = float(correction_factor_dat[0][1])
self.bell2with = float(correction_factor_dat[1][1])
self.pat2bell = float(correction_factor_dat[2][1])
self.with2bell = 1.0/self.bell2with
self.bell2path = 1.0/self.pat2bell
self.with2pat = 1.0/self.pat2with
self.pat2bell95 = float(correction_factor_dat[3][1])
self.bell952pat = 1.0/self.pat2bell95
def adjust_composition(self):
#Interpolating the data for to be appear continous from crust to lab
#with increments of self.dz in meters.100 m is also suggested for
#calculating thermal conductivity properly in Hasterok and Chapman (2010)
self.layer_data = self.read_csv(filename = self.comp_path, delim = ',')
del self.layer_data[0] #deleting header layer
self.h2o_fugacity_calculated = False
self.depth_comp = []
self.h2o_comp = []
self.co2_comp = []
self.ol_frac_comp = []
self.opx_frac_comp = []
self.cpx_frac_comp = []
self.gt_frac_comp = []
self.sp_chr_frac_comp = []
self.pl_frac_comp = []
self.amp_frac_comp = []
self.cond_frac_comp = []
self.cond_cond_comp = []
self.melt_frac_comp = []
self.fe_ol_comp = []
self.fe_opx_comp = []
self.fe_cpx_comp = []
self.fe_gt_comp = []
self.al_opx_comp = []
self.ti_ol_comp = []
self.na2o_melt_comp = []
self.k2o_melt_comp = []
self.ol_m_comp = []
self.opx_m_comp = []
self.cpx_m_comp = []
self.gt_m_comp = []
self.sp_chr_m_comp = []
self.pl_m_comp = []
self.amp_m_comp = []
self.cond_m_comp = []
self.cond_t_k_comp = []
self.melt_m_comp = []
self.flu_comp = []
self.ol_gs_comp = []
self.heat_prod_mantle = []
self.continue_adjusting = 1
for i in range(0,len(self.layer_data)):
for j in range(0,len(self.layer_data[i])):
try:
float(self.layer_data[i][j])
if float(self.layer_data[i][j]) < 0.0:
self.continue_adjusting = 0
print("Warning! - There is an entered value for a parameters that is smaller than zero, which can not be the case. Correct this value to continue.")
break
if float(self.layer_data[0][0])*1000.0 != self.moho:
self.continue_adjusting = 0
print("Warning! - Entered Moho depth from the -Depth Range- section is not same as the depth of the first layer. Please fix this to continue.")
break
if i !=0:
if float(self.layer_data[i][0]) <= float(self.layer_data[i-1][0]):
self.continue_adjusting = 0
print("Warning! - Layers depths are not in right order. The value decreased on the next layer or the same within some layer.")
break
except ValueError:
print("Warning! - There are some elements in the composition file that can not be converted to floating numbers.\n" +\
"Please enter all the parameters as numbers that can be converted to floating numbers.")
self.continue_adjusting = 0
if self.continue_adjusting == 0:
break
if self.continue_adjusting == 1:
for i in range(0,len(self.layer_data)):
if i < len(self.layer_data)-1:
self.depth_comp.append(float(self.layer_data[i][0]) * 1000.0)
self.depth_comp.append((float(self.layer_data[i+1][0]) * 1000.0) - self.dz)
else:
self.depth_comp.append(float(self.layer_data[i][0]) * 1000.0)
self.depth_comp.append(self.lab)
for j in range(0,2):
self.h2o_comp.append(float(self.layer_data[i][1]))
self.co2_comp.append(float(self.layer_data[i][2]))
self.ol_frac_comp.append(float(self.layer_data[i][3]) / 100.0) #converting to perc to fraction
self.opx_frac_comp.append(float(self.layer_data[i][4]) / 100.0)
self.cpx_frac_comp.append(float(self.layer_data[i][5]) / 100.0)
self.gt_frac_comp.append(float(self.layer_data[i][6]) / 100.0)
self.sp_chr_frac_comp.append(float(self.layer_data[i][7]) / 100.0)
self.pl_frac_comp.append(float(self.layer_data[i][8]) / 100.0)
self.amp_frac_comp.append(float(self.layer_data[i][9]) / 100.0)
self.cond_frac_comp.append(float(self.layer_data[i][10]) / 100.0)
self.cond_cond_comp.append(1.0 / float(self.layer_data[i][11])) #converting to conductivity
self.melt_frac_comp.append(float(self.layer_data[i][12]) / 100.0)
self.fe_ol_comp.append(float(self.layer_data[i][13]))
self.fe_opx_comp.append(float(self.layer_data[i][14]))
self.fe_cpx_comp.append(float(self.layer_data[i][15]))
self.fe_gt_comp.append(float(self.layer_data[i][16]))
self.ol_m_comp.append(float(self.layer_data[i][17]))
self.opx_m_comp.append(float(self.layer_data[i][18]))
self.cpx_m_comp.append(float(self.layer_data[i][19]))
self.gt_m_comp.append(float(self.layer_data[i][20]))
self.sp_chr_m_comp.append(float(self.layer_data[i][21]))
self.pl_m_comp.append(float(self.layer_data[i][22]))
self.amp_m_comp.append(float(self.layer_data[i][23]))
self.cond_m_comp.append(float(self.layer_data[i][24]))
self.melt_m_comp.append(float(self.layer_data[i][25]))
self.al_opx_comp.append(float(self.layer_data[i][26]))
self.ti_ol_comp.append(float(self.layer_data[i][27]))
self.na2o_melt_comp.append(float(self.layer_data[i][28]))
self.k2o_melt_comp.append(float(self.layer_data[i][29]))
self.cond_t_k_comp.append(float(self.layer_data[i][30]))
self.flu_comp.append(float(self.layer_data[i][31]))
self.ol_gs_comp.append(float(self.layer_data[i][32])*1e-3) #converting to mm to m
self.heat_prod_mantle.append(float(self.layer_data[i][33]))
f_ol = interp1d(self.depth_comp,self.ol_frac_comp)
f_opx = interp1d(self.depth_comp,self.opx_frac_comp)
f_cpx = interp1d(self.depth_comp,self.cpx_frac_comp)
f_gt = interp1d(self.depth_comp,self.gt_frac_comp)
f_sp_chr = interp1d(self.depth_comp,self.sp_chr_frac_comp)
f_pl = interp1d(self.depth_comp,self.pl_frac_comp)
f_amp = interp1d(self.depth_comp,self.amp_frac_comp)
f_cond = interp1d(self.depth_comp,self.cond_frac_comp)
f_cond_cond = interp1d(self.depth_comp,self.cond_cond_comp)
f_melt = interp1d(self.depth_comp,self.melt_frac_comp)
f_fe_ol = interp1d(self.depth_comp,self.fe_ol_comp)
f_fe_opx = interp1d(self.depth_comp,self.fe_opx_comp)
f_fe_cpx = interp1d(self.depth_comp,self.fe_cpx_comp)
f_fe_gt = interp1d(self.depth_comp,self.fe_gt_comp)
if self.al_method == '0':
f_al_opx = interp1d(self.depth_comp,self.al_opx_comp)
f_ti_ol = interp1d(self.depth_comp,self.ti_ol_comp)
f_na2o_melt = interp1d(self.depth_comp,self.na2o_melt_comp)
f_k2o_melt = interp1d(self.depth_comp,self.k2o_melt_comp)
f_ol_m = interp1d(self.depth_comp,self.ol_m_comp)
f_opx_m = interp1d(self.depth_comp,self.opx_m_comp)
f_cpx_m = interp1d(self.depth_comp,self.cpx_m_comp)
f_gt_m = interp1d(self.depth_comp,self.gt_m_comp)
f_sp_chr_m = interp1d(self.depth_comp,self.sp_chr_m_comp)
f_pl_m = interp1d(self.depth_comp,self.pl_m_comp)
f_amp_m = interp1d(self.depth_comp,self.amp_m_comp)
f_cond_m = interp1d(self.depth_comp,self.cond_m_comp)
f_melt_m = interp1d(self.depth_comp,self.melt_m_comp)
f_h2o = interp1d(self.depth_comp,self.h2o_comp)
f_co2 = interp1d(self.depth_comp,self.co2_comp)
f_cond_t_k = interp1d(self.depth_comp,self.cond_t_k_comp)
f_flu = interp1d(self.depth_comp,self.flu_comp)
f_ol_gs = interp1d(self.depth_comp,self.ol_gs_comp)
f_heat_prod_mantle = interp1d(self.depth_comp,self.heat_prod_mantle)
self.composition_readfile = True