-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lecture_module.py
executable file
·2602 lines (2201 loc) · 136 KB
/
Lecture_module.py
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
# module de lecture des fichiers .sum de SimClust pour python
# Marie je te confie tout ca...
import os
import linecache
import re
import math
import subprocess
import shutil
import time
import random
from random import gauss
import math
import numpy as np
import numexpr as ne
import scipy
from scipy import integrate
from scipy.integrate import quad
from sklearn import mixture
#import numpy as np #bizarre, pas de numpy ni scipy sur jt serveur!!
def Lecture_sumfile(file_name):
infile1 = open(file_name,'r')
UUU = [] #refresh important ###
BBB = []
VVV = []
RRR = []
III = []
JJJ = []
HHH = []
KKK = []
U = [] #refresh important ###
B = []
V = []
R = []
I = []
J = []
H = []
K = []
U_V = [] #refresh important ###
B_V = []
V_R = []
V_I = []
V_J = []
V_H = []
V_K = []
kk=0
for line in infile1:
kk = kk+1
ll = line.split()
UUU.append(ll[4])
BBB.append(ll[5])
VVV.append(ll[6])
RRR.append(ll[7])
III.append(ll[8])
JJJ.append(ll[9])
HHH.append(ll[10])
KKK.append(ll[11])
infile1.close()
for ii in range(1,kk) :
U.append(float(UUU[ii]))
B.append(float(BBB[ii]))
V.append(float(VVV[ii]))
R.append(float(RRR[ii]))
I.append(float(III[ii]))
J.append(float(JJJ[ii]))
H.append(float(HHH[ii]))
K.append(float(KKK[ii]))
for ii in range(0,kk-1) :
U_V.append(U[ii] - V[ii])
B_V.append(B[ii] - V[ii])
V_R.append(V[ii] - R[ii])
V_I.append(V[ii] - I[ii])
V_J.append(V[ii] - J[ii])
V_H.append(V[ii] - H[ii])
V_K.append(V[ii] - K[ii])
print( 'Il y a', kk-1, 'clusters dans le fichier' )
#print 'En voici ces magnitudes, normalisees par la bande V'
#print str(U_V[0])+' 'str(B_V[0])+' 'str(0.)+' 'str(V_R[0])+' 'str(V_I[0])+' 'str(V_J[0])+' 'str(V_H[0])+' 'str(V_K[0])
#for ii in range(0,kk) :
#print U_V[0], B_V[0], 0., V_R[0], V_I[0], V_J[0], V_H[0], V_K[0]
#print U_V[ii], B_V[ii], 0., V_R[ii], V_I[ii], V_J[ii], V_H[ii], V_K[ii]
return U_V, B_V, V_R, V_I, V_J, V_H, V_K
def Lecture_sumfile_gCMD(file_name):
infile1 = open(file_name,'r')
UUU = [] #refresh important ###
BBB = []
VVV = []
RRR = []
III = []
U = [] #refresh important ###
B = []
V = []
R = []
I = []
U_V = [] #refresh important ###
U_B = []
B_V = []
V_R = []
V_I = []
kk=0
for line in infile1:
kk = kk+1
ll = line.split()
UUU.append(ll[0])
BBB.append(ll[1])
VVV.append(ll[2])
RRR.append(ll[3])
III.append(ll[4])
infile1.close()
for ii in range(1,kk) :
U.append(float(UUU[ii]))
B.append(float(BBB[ii]))
V.append(float(VVV[ii]))
R.append(float(RRR[ii]))
I.append(float(III[ii]))
for ii in range(0,kk-1) :
U_V.append(U[ii] - V[ii])
U_B.append(U[ii] - B[ii])
B_V.append(B[ii] - V[ii])
V_R.append(V[ii] - R[ii])
V_I.append(V[ii] - I[ii])
print( 'Il y a', kk-1, 'clusters dans le fichier' )
#print 'En voici ces magnitudes, normalisees par la bande V'
#print str(U_V[0])+' 'str(B_V[0])+' 'str(0.)+' 'str(V_R[0])+' 'str(V_I[0])+' 'str(V_J[0])+' 'str(V_H[0])+' 'str(V_K[0])
#for ii in range(0,kk) :
#print U_V[0], B_V[0], 0., V_R[0], V_I[0], V_J[0], V_H[0], V_K[0]
#print U_V[ii], B_V[ii], 0., V_R[ii], V_I[ii], V_J[ii], V_H[ii], V_K[ii]
#return U_V, B_V, V_R, V_I
return U, B, V, R, I, U_B, B_V
def Numberlines_sumfile(file_name):
infile1 = open(file_name,'r')
UUU = [] #refresh important ###
BBB = []
VVV = []
RRR = []
III = []
JJJ = []
HHH = []
KKK = []
kk=0
for line in infile1:
kk = kk+1
ll = line.split()
UUU.append(ll[4])
BBB.append(ll[5])
VVV.append(ll[6])
RRR.append(ll[7])
III.append(ll[8])
JJJ.append(ll[9])
HHH.append(ll[10])
KKK.append(ll[11])
infile1.close()
#print 'Il y a', kk-1, 'clusters dans le fichier'
return kk-1 #number of lines of file
def age_mass_Z_May2011(a,m,zz):
#Old Grid May 2011
if a ==1: age = 7.0 #10 Myr
elif a ==2: age = 7.5 #30 Myr
elif a ==3: age = 8.0 #100 Myr
elif a ==4: age = 8.5 #300 Myr
elif a ==5: age = 9.0 #1000 Myr
elif a ==6: age = 10.0 #10000 Myr
if m==1: mass = 1000. #Solar masses
elif m==2: mass = 5000. #Solar masses
elif m==3: mass = 10000. #Solar masses
elif m==4: mass = 50000. #Solar masses
elif m==5: mass = 100000. #Solar masses
if zz ==1: Z = 0.001 #10 Myr
elif zz ==2: Z = 0.004 #30 Myr
elif zz ==3: Z = 0.008 #100 Myr
elif zz ==4: Z = 0.01 #300 Myr
elif zz ==5: Z = 0.02 #1000 Myr
elif zz ==6: Z = 0.03 #10000 Myr
return age, mass, Z
def age_mass_Z_June2011(a,m,zz):
#Old Age grid June 2011
if a ==1: age, age_indice = 7.00, '700'
elif a ==2: age, age_indice = 7.15, '715'
elif a ==3: age, age_indice = 7.30, '730'
elif a ==4: age, age_indice = 7.45, '745'
elif a ==5: age, age_indice = 7.60, '760'
elif a ==6: age, age_indice = 7.75, '775'
elif a ==7: age, age_indice = 7.90, '790'
elif a ==8: age, age_indice = 8.05, '805'
elif a ==9: age, age_indice = 8.20, '820'
elif a ==10: age, age_indice = 8.35, '835'
elif a ==11: age, age_indice = 8.50, '850'
elif a ==12: age, age_indice = 8.65, '865'
elif a ==13: age, age_indice = 8.80, '880'
elif a ==14: age, age_indice = 8.95, '895'
elif a ==15: age, age_indice = 9.10, '910'
elif a ==16: age, age_indice = 9.25, '925'
elif a ==17: age, age_indice = 9.40, '940'
elif a ==18: age, age_indice = 9.55, '955'
elif a ==19: age, age_indice = 9.70, '970'
elif a ==20: age, age_indice = 9.85, '985'
elif a ==21: age, age_indice = 10.0, '1000'
#Old Mass grid June 2011
if m ==1: mass, mass_indice = 10**3.00, '300' #Solar masses
elif m ==2: mass, mass_indice = 10**3.25, '325' #Solar masses
elif m ==3: mass, mass_indice = 10**3.50, '350' #Solar masses
elif m ==4: mass, mass_indice = 10**3.75, '375' #Solar masses
elif m ==5: mass, mass_indice = 10**4.00, '400' #Solar masses
elif m ==6: mass, mass_indice = 10**4.25, '425' #Solar masses
elif m ==7: mass, mass_indice = 10**4.50, '450' #Solar masses
elif m ==8: mass, mass_indice = 10**4.75, '475' #Solar masses
elif m ==9: mass, mass_indice = 10**5.00, '500' #Solar masses
#Old metallicity grid (June 2011), based on Zs=0.020
# a tester : [-2.3, -1.9, -1.6, -1.3, -1.0, -0.8, -0.6, -0.4, -0.2, 0.0, +0.2]
#if zz ==1: Z, Z_indice = 0.00010, 'm23' # [M/H] = -2.3
#elif zz ==2: Z, Z_indice = 0.00025, 'm19' # [M/H] = -1.9
#elif zz ==3: Z, Z_indice = 0.00050, 'm16' # [M/H] = -1.6
#elif zz ==4: Z, Z_indice = 0.00100, 'm13' # [M/H] = -1.3
#elif zz ==5: Z, Z_indice = 0.00200, 'm10' # [M/H] = -1.0
#elif zz ==6: Z, Z_indice = 0.00317, 'm08' # [M/H] = -0.8
#elif zz ==7: Z, Z_indice = 0.00502, 'm06' # [M/H] = -0.6
##elif zz ==8: Z, Z_indice = 0.00796, 'm04' # [M/H] = -0.4 #BUG!!
#elif zz ==8: Z, Z_indice = 0.00800, 'm04' # [M/H] = -0.4
#elif zz ==9: Z, Z_indice = 0.01262, 'm02' # [M/H] = -0.2
#elif zz ==10: Z, Z_indice = 0.02000, 'n00' # [M/H] = +0.0
#elif zz ==11: Z, Z_indice = 0.03000, 'p02' # [M/H] = +0.2 ABOUT, not exactly
#New metallicities, based on Zs=0.019, 11 metal
#if zz ==1: Z, Z_indice = 0.00010, 'm23' # [M/H] = -2.3
#elif zz ==2: Z, Z_indice = 0.00024, 'm19' # [M/H] = -1.9
#elif zz ==3: Z, Z_indice = 0.00050, 'm16' # [M/H] = -1.6
#elif zz ==4: Z, Z_indice = 0.00095, 'm13' # [M/H] = -1.3
#elif zz ==5: Z, Z_indice = 0.00190, 'm10' # [M/H] = -1.0
#elif zz ==6: Z, Z_indice = 0.00300, 'm08' # [M/H] = -0.8
#elif zz ==7: Z, Z_indice = 0.00480, 'm06' # [M/H] = -0.6
#elif zz ==8: Z, Z_indice = 0.00800, 'm04' # [M/H] = -0.4
#elif zz ==9: Z, Z_indice = 0.01200, 'm02' # [M/H] = -0.2
#elif zz ==10: Z, Z_indice = 0.01900, 'n00' # [M/H] = +0.0
#elif zz ==11: Z, Z_indice = 0.03000, 'p02' # [M/H] = +0.2
#New metallicities, based on Zs=0.019, 13 metal
if zz ==1: Z, Z_indice = 0.00012, 'm22' # [M/H] = -2.2
elif zz ==2: Z, Z_indice = 0.00019, 'm20' # [M/H] = -2.0
elif zz ==3: Z, Z_indice = 0.00030, 'm18' # [M/H] = -1.8
elif zz ==4: Z, Z_indice = 0.00050, 'm16' # [M/H] = -1.6
elif zz ==5: Z, Z_indice = 0.00075, 'm14' # [M/H] = -1.4
elif zz ==6: Z, Z_indice = 0.00120, 'm12' # [M/H] = -1.2
elif zz ==7: Z, Z_indice = 0.00190, 'm10' # [M/H] = -1.0
elif zz ==8: Z, Z_indice = 0.00300, 'm08' # [M/H] = -0.8
elif zz ==9: Z, Z_indice = 0.00480, 'm06' # [M/H] = -0.6
elif zz ==10: Z, Z_indice = 0.00800, 'm04' # [M/H] = -0.4
elif zz ==11: Z, Z_indice = 0.01200, 'm02' # [M/H] = -0.2
elif zz ==12: Z, Z_indice = 0.01900, 'n00' # [M/H] = +0.0
elif zz ==13: Z, Z_indice = 0.03000, 'p02' # [M/H] = +0.2
return age, mass, Z, age_indice, mass_indice, Z_indice
def age_mass_Z_September2011(a,m,zz):
#Age grid September 2011
if a ==1: age, age_indice = 7.00, '700' #10 Myr
elif a ==2: age, age_indice = 7.10, '710'
elif a ==3: age, age_indice = 7.20, '720'
elif a ==4: age, age_indice = 7.30, '730'
elif a ==5: age, age_indice = 7.40, '740'
elif a ==6: age, age_indice = 7.50, '750'
elif a ==7: age, age_indice = 7.60, '760'
elif a ==8: age, age_indice = 7.70, '770'
elif a ==9: age, age_indice = 7.80, '780'
elif a ==10: age, age_indice = 7.90, '790'
elif a ==11: age, age_indice = 8.00, '800'
elif a ==12: age, age_indice = 8.10, '810'
elif a ==13: age, age_indice = 8.20, '820'
elif a ==14: age, age_indice = 8.30, '830'
elif a ==15: age, age_indice = 8.40, '840'
elif a ==16: age, age_indice = 8.50, '850'
elif a ==17: age, age_indice = 8.60, '860'
elif a ==18: age, age_indice = 8.70, '870'
elif a ==19: age, age_indice = 8.80, '880'
elif a ==20: age, age_indice = 8.90, '890'
elif a ==21: age, age_indice = 9.00, '900'
elif a ==22: age, age_indice = 9.10, '910'
elif a ==23: age, age_indice = 9.20, '920'
elif a ==24: age, age_indice = 9.30, '930'
elif a ==25: age, age_indice = 9.40, '940'
elif a ==26: age, age_indice = 9.50, '950'
elif a ==27: age, age_indice = 9.60, '960'
elif a ==28: age, age_indice = 9.70, '970'
elif a ==29: age, age_indice = 9.80, '980'
elif a ==30: age, age_indice = 9.90, '990'
elif a ==31: age, age_indice = 10.0, '1000'
#Mass grid September 2011
if m ==1 : mass, mass_indice = 10**3.00, '300' #Solar masses
elif m ==2 : mass, mass_indice = 10**3.10, '310' #Solar masses
elif m ==3 : mass, mass_indice = 10**3.20, '320' #Solar masses
elif m ==4 : mass, mass_indice = 10**3.30, '330' #Solar masses
elif m ==5 : mass, mass_indice = 10**3.40, '340' #Solar masses
elif m ==6 : mass, mass_indice = 10**3.50, '350' #Solar masses
elif m ==7 : mass, mass_indice = 10**3.60, '360' #Solar masses
elif m ==8 : mass, mass_indice = 10**3.70, '370' #Solar masses
elif m ==9 : mass, mass_indice = 10**3.80, '380' #Solar masses
elif m ==10: mass, mass_indice = 10**3.90, '390' #Solar masses
elif m ==11: mass, mass_indice = 10**4.00, '400' #Solar masses
elif m ==12: mass, mass_indice = 10**4.10, '410' #Solar masses
elif m ==13: mass, mass_indice = 10**4.20, '420' #Solar masses
elif m ==14: mass, mass_indice = 10**4.30, '430' #Solar masses
elif m ==15: mass, mass_indice = 10**4.40, '440' #Solar masses
elif m ==16: mass, mass_indice = 10**4.50, '450' #Solar masses
elif m ==17: mass, mass_indice = 10**4.60, '460' #Solar masses
elif m ==18: mass, mass_indice = 10**4.70, '470' #Solar masses
elif m ==19: mass, mass_indice = 10**4.80, '480' #Solar masses
elif m ==20: mass, mass_indice = 10**4.90, '490' #Solar masses
elif m ==21: mass, mass_indice = 10**5.00, '500' #Solar masses
#September 2011, end
#if zz ==1: Z, Z_indice = 0.00010 , 'm23' # [M/H] = -2.3
#elif zz ==2: Z, Z_indice = 0.00012619 , 'm22' # [M/H] = -2.2
#elif zz ==3: Z, Z_indice = 0.00015887 , 'm21' # [M/H] = -2.1
#elif zz ==4: Z, Z_indice = 0.00020000 , 'm20' # [M/H] = -2.0
#elif zz ==5: Z, Z_indice = 0.00025 , 'm19' # [M/H] = -1.9
#elif zz ==6: Z, Z_indice = 0.00031698 , 'm18' # [M/H] = -1.8
#elif zz ==7: Z, Z_indice = 0.00039905 , 'm17' # [M/H] = -1.7
#elif zz ==8: Z, Z_indice = 0.00050 , 'm16' # [M/H] = -1.6
#elif zz ==9: Z, Z_indice = 0.00063246 , 'm15' # [M/H] = -1.5
#elif zz ==10: Z, Z_indice = 0.00079621 , 'm14' # [M/H] = -1.4
#elif zz ==11: Z, Z_indice = 0.00100 , 'm13' # [M/H] = -1.3
#elif zz ==12: Z, Z_indice = 0.0012619 , 'm12' # [M/H] = -1.2
#elif zz ==13: Z, Z_indice = 0.0015887 , 'm11' # [M/H] = -1.1
#elif zz ==14: Z, Z_indice = 0.00200 , 'm10' # [M/H] = -1.0
#elif zz ==15: Z, Z_indice = 0.0025179 , 'm09' # [M/H] = -0.9
#elif zz ==16: Z, Z_indice = 0.00317 , 'm08' # [M/H] = -0.8
#elif zz ==17: Z, Z_indice = 0.0039905 , 'm07' # [M/H] = -0.7
#elif zz ==18: Z, Z_indice = 0.00502 , 'm06' # [M/H] = -0.6
#elif zz ==19: Z, Z_indice = 0.0063246 , 'm05' # [M/H] = -0.5
#elif zz ==20: Z, Z_indice = 0.00796 , 'm04' # [M/H] = -0.4
#elif zz ==21: Z, Z_indice = 0.010024 , 'm03' # [M/H] = -0.3
#elif zz ==22: Z, Z_indice = 0.01262 , 'm02' # [M/H] = -0.2
#elif zz ==23: Z, Z_indice = 0.015887 , 'm01' # [M/H] = -0.1
#elif zz ==24: Z, Z_indice = 0.02000 , 'n00' # [M/H] = +0.0
#elif zz ==25: Z, Z_indice = 0.025179 , 'p01' # [M/H] = +0.1
#elif zz ==26: Z, Z_indice = 0.03000 , 'p02' # [M/H] = +0.2 ABOUT, not exactly
#September 2011, end
if zz ==1: Z, Z_indice = 0.00010 , 'm23' # [M/H] = -2.3
elif zz ==2: Z, Z_indice = 0.00013 , 'm22' # [M/H] = -2.2 #Should be 0.00012
elif zz ==3: Z, Z_indice = 0.00015 , 'm21' # [M/H] = -2.1
elif zz ==4: Z, Z_indice = 0.00019 , 'm20' # [M/H] = -2.0
elif zz ==5: Z, Z_indice = 0.00024 , 'm19' # [M/H] = -1.9
elif zz ==6: Z, Z_indice = 0.00030 , 'm18' # [M/H] = -1.8
elif zz ==7: Z, Z_indice = 0.00040 , 'm17' # [M/H] = -1.7
elif zz ==8: Z, Z_indice = 0.00050 , 'm16' # [M/H] = -1.6
elif zz ==9: Z, Z_indice = 0.00060 , 'm15' # [M/H] = -1.5
elif zz ==10: Z, Z_indice = 0.00080 , 'm14' # [M/H] = -1.4 #Should be 0.00075
elif zz ==11: Z, Z_indice = 0.00100 , 'm13' # [M/H] = -1.3
elif zz ==12: Z, Z_indice = 0.00130 , 'm12' # [M/H] = -1.2 #Should be 0.00120
elif zz ==13: Z, Z_indice = 0.00150 , 'm11' # [M/H] = -1.1
elif zz ==14: Z, Z_indice = 0.00190 , 'm10' # [M/H] = -1.0
elif zz ==15: Z, Z_indice = 0.00240 , 'm09' # [M/H] = -0.9
elif zz ==16: Z, Z_indice = 0.00300 , 'm08' # [M/H] = -0.8
elif zz ==17: Z, Z_indice = 0.00400 , 'm07' # [M/H] = -0.7 #Should be 0.00380
elif zz ==18: Z, Z_indice = 0.00500 , 'm06' # [M/H] = -0.6 #Should be 0.00480
elif zz ==19: Z, Z_indice = 0.00600 , 'm05' # [M/H] = -0.5
elif zz ==20: Z, Z_indice = 0.00800 , 'm04' # [M/H] = -0.4
elif zz ==21: Z, Z_indice = 0.01000 , 'm03' # [M/H] = -0.3
elif zz ==22: Z, Z_indice = 0.01300 , 'm02' # [M/H] = -0.2 #Should be 0.01200
elif zz ==23: Z, Z_indice = 0.01500 , 'm01' # [M/H] = -0.1
elif zz ==24: Z, Z_indice = 0.01900 , 'n00' # [M/H] = +0.0
elif zz ==25: Z, Z_indice = 0.02400 , 'p01' # [M/H] = +0.1
elif zz ==26: Z, Z_indice = 0.03000 , 'p02' # [M/H] = +0.2
return age, mass, Z, age_indice, mass_indice, Z_indice
def age_mass_Z_November2011(a,m,zz):
#Age grid Novtember 2011
if a ==1: age, age_indice = 7.00, '700' #10 Myr
elif a ==2: age, age_indice = 7.10, '710'
elif a ==3: age, age_indice = 7.20, '720'
elif a ==4: age, age_indice = 7.30, '730'
elif a ==5: age, age_indice = 7.40, '740'
elif a ==6: age, age_indice = 7.50, '750'
elif a ==7: age, age_indice = 7.60, '760'
elif a ==8: age, age_indice = 7.70, '770'
elif a ==9: age, age_indice = 7.80, '780'
elif a ==10: age, age_indice = 7.90, '790'
elif a ==11: age, age_indice = 8.00, '800'
elif a ==12: age, age_indice = 8.10, '810'
elif a ==13: age, age_indice = 8.20, '820'
elif a ==14: age, age_indice = 8.30, '830'
elif a ==15: age, age_indice = 8.40, '840'
elif a ==16: age, age_indice = 8.50, '850'
elif a ==17: age, age_indice = 8.60, '860'
elif a ==18: age, age_indice = 8.70, '870'
elif a ==19: age, age_indice = 8.80, '880'
elif a ==20: age, age_indice = 8.90, '890'
elif a ==21: age, age_indice = 9.00, '900'
elif a ==22: age, age_indice = 9.10, '910'
elif a ==23: age, age_indice = 9.20, '920'
elif a ==24: age, age_indice = 9.30, '930'
elif a ==25: age, age_indice = 9.40, '940'
elif a ==26: age, age_indice = 9.50, '950'
elif a ==27: age, age_indice = 9.60, '960'
elif a ==28: age, age_indice = 9.70, '970'
elif a ==29: age, age_indice = 9.80, '980'
elif a ==30: age, age_indice = 9.90, '990'
elif a ==31: age, age_indice = 10.0, '1000'
#Mass grid November 2011
if m ==1 : mass, mass_indice = 10**2.00, '200' #Solar masses
elif m ==2 : mass, mass_indice = 10**2.10, '210' #Solar masses
elif m ==3 : mass, mass_indice = 10**2.20, '220' #Solar masses
elif m ==4 : mass, mass_indice = 10**2.30, '230' #Solar masses
elif m ==5 : mass, mass_indice = 10**2.40, '240' #Solar masses
elif m ==6 : mass, mass_indice = 10**2.50, '250' #Solar masses
elif m ==7 : mass, mass_indice = 10**2.60, '260' #Solar masses
elif m ==8 : mass, mass_indice = 10**2.70, '270' #Solar masses
elif m ==9 : mass, mass_indice = 10**2.80, '280' #Solar masses
elif m ==10: mass, mass_indice = 10**2.90, '290' #Solar masses
elif m ==11: mass, mass_indice = 10**3.00, '300' #Solar masses
elif m ==12: mass, mass_indice = 10**3.10, '310' #Solar masses
elif m ==13: mass, mass_indice = 10**3.20, '320' #Solar masses
elif m ==14: mass, mass_indice = 10**3.30, '330' #Solar masses
elif m ==15: mass, mass_indice = 10**3.40, '340' #Solar masses
elif m ==16: mass, mass_indice = 10**3.50, '350' #Solar masses
elif m ==17: mass, mass_indice = 10**3.60, '360' #Solar masses
elif m ==18: mass, mass_indice = 10**3.70, '370' #Solar masses
elif m ==19: mass, mass_indice = 10**3.80, '380' #Solar masses
elif m ==20: mass, mass_indice = 10**3.90, '390' #Solar masses
elif m ==21: mass, mass_indice = 10**4.00, '400' #Solar masses
elif m ==22: mass, mass_indice = 10**4.10, '410' #Solar masses
elif m ==23: mass, mass_indice = 10**4.20, '420' #Solar masses
elif m ==24: mass, mass_indice = 10**4.30, '430' #Solar masses
elif m ==25: mass, mass_indice = 10**4.40, '440' #Solar masses
elif m ==26: mass, mass_indice = 10**4.50, '450' #Solar masses
elif m ==27: mass, mass_indice = 10**4.60, '460' #Solar masses
elif m ==28: mass, mass_indice = 10**4.70, '470' #Solar masses
elif m ==29: mass, mass_indice = 10**4.80, '480' #Solar masses
elif m ==30: mass, mass_indice = 10**4.90, '490' #Solar masses
elif m ==31: mass, mass_indice = 10**5.00, '500' #Solar masses
elif m ==32: mass, mass_indice = 10**5.10, '510' #Solar masses
elif m ==33: mass, mass_indice = 10**5.20, '520' #Solar masses
elif m ==34: mass, mass_indice = 10**5.30, '530' #Solar masses
elif m ==35: mass, mass_indice = 10**5.40, '540' #Solar masses
elif m ==36: mass, mass_indice = 10**5.50, '550' #Solar masses
elif m ==37: mass, mass_indice = 10**5.60, '560' #Solar masses
elif m ==38: mass, mass_indice = 10**5.70, '570' #Solar masses
elif m ==39: mass, mass_indice = 10**5.80, '580' #Solar masses
elif m ==40: mass, mass_indice = 10**5.90, '590' #Solar masses
elif m ==41: mass, mass_indice = 10**6.00, '600' #Solar masses
#November 2011, end
if zz ==1: Z, Z_indice = 0.00010 , 'm23' # [M/H] = -2.3
elif zz ==2: Z, Z_indice = 0.00013 , 'm22' # [M/H] = -2.2 #Should be 0.00012
elif zz ==3: Z, Z_indice = 0.00015 , 'm21' # [M/H] = -2.1
elif zz ==4: Z, Z_indice = 0.00019 , 'm20' # [M/H] = -2.0
elif zz ==5: Z, Z_indice = 0.00024 , 'm19' # [M/H] = -1.9
elif zz ==6: Z, Z_indice = 0.00030 , 'm18' # [M/H] = -1.8
elif zz ==7: Z, Z_indice = 0.00040 , 'm17' # [M/H] = -1.7
elif zz ==8: Z, Z_indice = 0.00050 , 'm16' # [M/H] = -1.6
elif zz ==9: Z, Z_indice = 0.00060 , 'm15' # [M/H] = -1.5
elif zz ==10: Z, Z_indice = 0.00080 , 'm14' # [M/H] = -1.4 #Should be 0.00075
elif zz ==11: Z, Z_indice = 0.00100 , 'm13' # [M/H] = -1.3
elif zz ==12: Z, Z_indice = 0.00130 , 'm12' # [M/H] = -1.2 #Should be 0.00120
elif zz ==13: Z, Z_indice = 0.00150 , 'm11' # [M/H] = -1.1
elif zz ==14: Z, Z_indice = 0.00190 , 'm10' # [M/H] = -1.0
elif zz ==15: Z, Z_indice = 0.00240 , 'm09' # [M/H] = -0.9
elif zz ==16: Z, Z_indice = 0.00300 , 'm08' # [M/H] = -0.8
elif zz ==17: Z, Z_indice = 0.00400 , 'm07' # [M/H] = -0.7 #Should be 0.00380
elif zz ==18: Z, Z_indice = 0.00500 , 'm06' # [M/H] = -0.6 #Should be 0.00480
elif zz ==19: Z, Z_indice = 0.00600 , 'm05' # [M/H] = -0.5
elif zz ==20: Z, Z_indice = 0.00800 , 'm04' # [M/H] = -0.4
elif zz ==21: Z, Z_indice = 0.01000 , 'm03' # [M/H] = -0.3
elif zz ==22: Z, Z_indice = 0.01300 , 'm02' # [M/H] = -0.2 #Should be 0.01200
elif zz ==23: Z, Z_indice = 0.01500 , 'm01' # [M/H] = -0.1
elif zz ==24: Z, Z_indice = 0.01900 , 'n00' # [M/H] = +0.0
elif zz ==25: Z, Z_indice = 0.02400 , 'p01' # [M/H] = +0.1
elif zz ==26: Z, Z_indice = 0.03000 , 'p02' # [M/H] = +0.2
return age, mass, Z, age_indice, mass_indice, Z_indice
def age_mass_Z_December2011(a,m,zz):
#Age grid December 2011
'''
if a ==1: age, age_indice = 7.00, '700' #10 Myr
elif a ==2: age, age_indice = 7.05, '705'
elif a ==3: age, age_indice = 7.10, '710'
elif a ==4: age, age_indice = 7.15, '715'
elif a ==5: age, age_indice = 7.20, '720'
elif a ==6: age, age_indice = 7.25, '725'
elif a ==7: age, age_indice = 7.30, '730'
elif a ==8: age, age_indice = 7.35, '735'
elif a ==9: age, age_indice = 7.40, '740'
elif a ==10: age, age_indice = 7.45, '745'
elif a ==11: age, age_indice = 7.50, '750'
elif a ==12: age, age_indice = 7.55, '755'
elif a ==13: age, age_indice = 7.60, '760'
elif a ==14: age, age_indice = 7.65, '765'
elif a ==15: age, age_indice = 7.70, '770'
elif a ==16: age, age_indice = 7.75, '775'
elif a ==17: age, age_indice = 7.80, '780'
elif a ==18: age, age_indice = 7.85, '785'
elif a ==19: age, age_indice = 7.90, '790'
elif a ==20: age, age_indice = 7.95, '795'
elif a ==21: age, age_indice = 8.00, '800'
elif a ==22: age, age_indice = 8.05, '805'
elif a ==23: age, age_indice = 8.10, '810'
elif a ==24: age, age_indice = 8.15, '815'
elif a ==25: age, age_indice = 8.20, '820'
elif a ==26: age, age_indice = 8.25, '825'
elif a ==27: age, age_indice = 8.30, '830'
elif a ==28: age, age_indice = 8.35, '835'
elif a ==29: age, age_indice = 8.40, '840'
elif a ==30: age, age_indice = 8.45, '845'
elif a ==31: age, age_indice = 8.50, '850'
elif a ==32: age, age_indice = 8.55, '855'
elif a ==33: age, age_indice = 8.60, '860'
elif a ==34: age, age_indice = 8.65, '865'
elif a ==35: age, age_indice = 8.70, '870'
elif a ==36: age, age_indice = 8.75, '875'
elif a ==37: age, age_indice = 8.80, '880'
elif a ==38: age, age_indice = 8.85, '885'
elif a ==39: age, age_indice = 8.90, '890'
elif a ==40: age, age_indice = 8.95, '895'
elif a ==41: age, age_indice = 9.00, '900'
elif a ==42: age, age_indice = 9.05, '905'
elif a ==43: age, age_indice = 9.10, '910'
elif a ==44: age, age_indice = 9.15, '915'
elif a ==45: age, age_indice = 9.20, '920'
elif a ==46: age, age_indice = 9.25, '925'
elif a ==47: age, age_indice = 9.30, '930'
elif a ==48: age, age_indice = 9.35, '935'
elif a ==49: age, age_indice = 9.40, '940'
elif a ==50: age, age_indice = 9.45, '945'
elif a ==51: age, age_indice = 9.50, '950'
elif a ==52: age, age_indice = 9.55, '955'
elif a ==53: age, age_indice = 9.60, '960'
elif a ==54: age, age_indice = 9.65, '965'
elif a ==55: age, age_indice = 9.70, '970'
elif a ==56: age, age_indice = 9.75, '975'
elif a ==57: age, age_indice = 9.80, '980'
elif a ==58: age, age_indice = 9.85, '985'
elif a ==59: age, age_indice = 9.90, '990'
elif a ==60: age, age_indice = 9.95, '995'
elif a ==61: age, age_indice = 10.0, '1000'
elif a ==62: age, age_indice = 10.05, '1005'
elif a ==63: age, age_indice = 10.10, '1010'
'''
#Age grid December 2011
age = 6.60
#for ii in range(1,67):
# if (a == ii) :
age = age + (a-1)*0.05
age_int = int(round(age*100))
age_indice = str(age_int)
#Mass grid December 2011
mass = 2.00
#for ii in range(1,82):
# if (m == ii) :
mass = mass + (m-1)*0.05
mass_int = int(round(mass*100.))
mass = 10**mass
mass_indice = str(mass_int)
'''
#Mass grid December 2011
if m ==1: mass, mass_indice = 10**2.00, '200' #Solar masses
elif m ==2: mass, mass_indice = 10**2.05, '205' #Solar masses
elif m ==3: mass, mass_indice = 10**2.10, '210' #Solar masses
elif m ==4: mass, mass_indice = 10**2.15, '215' #Solar masses
elif m ==5: mass, mass_indice = 10**2.20, '220' #Solar masses
elif m ==6: mass, mass_indice = 10**2.25, '225' #Solar masses
elif m ==7: mass, mass_indice = 10**2.30, '230' #Solar masses
elif m ==8: mass, mass_indice = 10**2.35, '235' #Solar masses
elif m ==9: mass, mass_indice = 10**2.40, '240' #Solar masses
elif m ==10: mass, mass_indice = 10**2.45, '245' #Solar masses
elif m ==11: mass, mass_indice = 10**2.50, '250' #Solar masses
elif m ==12: mass, mass_indice = 10**2.55, '255' #Solar masses
elif m ==13: mass, mass_indice = 10**2.60, '260' #Solar masses
elif m ==14: mass, mass_indice = 10**2.65, '265' #Solar masses
elif m ==15: mass, mass_indice = 10**2.70, '270' #Solar masses
elif m ==16: mass, mass_indice = 10**2.75, '275' #Solar masses
elif m ==17: mass, mass_indice = 10**2.80, '280' #Solar masses
elif m ==18: mass, mass_indice = 10**2.85, '285' #Solar masses
elif m ==19: mass, mass_indice = 10**2.90, '290' #Solar masses
elif m ==20: mass, mass_indice = 10**2.95, '295' #Solar masses
elif m ==21: mass, mass_indice = 10**3.00, '300' #Solar masses
elif m ==22: mass, mass_indice = 10**3.05, '305' #Solar masses
elif m ==23: mass, mass_indice = 10**3.10, '310' #Solar masses
elif m ==24: mass, mass_indice = 10**3.15, '315' #Solar masses
elif m ==25: mass, mass_indice = 10**3.20, '320' #Solar masses
elif m ==26: mass, mass_indice = 10**3.25, '325' #Solar masses
elif m ==27: mass, mass_indice = 10**3.30, '330' #Solar masses
elif m ==28: mass, mass_indice = 10**3.35, '335' #Solar masses
elif m ==29: mass, mass_indice = 10**3.40, '340' #Solar masses
elif m ==30: mass, mass_indice = 10**3.45, '345' #Solar masses
elif m ==31: mass, mass_indice = 10**3.50, '350' #Solar masses
elif m ==32: mass, mass_indice = 10**3.55, '355' #Solar masses
elif m ==33: mass, mass_indice = 10**3.60, '360' #Solar masses
elif m ==34: mass, mass_indice = 10**3.65, '365' #Solar masses
elif m ==35: mass, mass_indice = 10**3.70, '370' #Solar masses
elif m ==36: mass, mass_indice = 10**3.75, '375' #Solar masses
elif m ==37: mass, mass_indice = 10**3.80, '380' #Solar masses
elif m ==38: mass, mass_indice = 10**3.85, '385' #Solar masses
elif m ==39: mass, mass_indice = 10**3.90, '390' #Solar masses
elif m ==40: mass, mass_indice = 10**3.95, '395' #Solar masses
elif m ==41: mass, mass_indice = 10**4.00, '400' #Solar masses
elif m ==42: mass, mass_indice = 10**4.05, '405' #Solar masses
elif m ==43: mass, mass_indice = 10**4.10, '410' #Solar masses
elif m ==44: mass, mass_indice = 10**4.15, '415' #Solar masses
elif m ==45: mass, mass_indice = 10**4.20, '420' #Solar masses
elif m ==46: mass, mass_indice = 10**4.25, '425' #Solar masses
elif m ==47: mass, mass_indice = 10**4.30, '430' #Solar masses
elif m ==48: mass, mass_indice = 10**4.35, '435' #Solar masses
elif m ==49: mass, mass_indice = 10**4.40, '440' #Solar masses
elif m ==50: mass, mass_indice = 10**4.45, '445' #Solar masses
elif m ==51: mass, mass_indice = 10**4.50, '450' #Solar masses
elif m ==52: mass, mass_indice = 10**4.55, '455' #Solar masses
elif m ==53: mass, mass_indice = 10**4.60, '460' #Solar masses
elif m ==54: mass, mass_indice = 10**4.65, '465' #Solar masses
elif m ==55: mass, mass_indice = 10**4.70, '470' #Solar masses
elif m ==56: mass, mass_indice = 10**4.75, '475' #Solar masses
elif m ==57: mass, mass_indice = 10**4.80, '480' #Solar masses
elif m ==58: mass, mass_indice = 10**4.85, '485' #Solar masses
elif m ==59: mass, mass_indice = 10**4.90, '490' #Solar masses
elif m ==60: mass, mass_indice = 10**4.95, '495' #Solar masses
elif m ==61: mass, mass_indice = 10**5.00, '500' #Solar masses
elif m ==62: mass, mass_indice = 10**5.05, '505' #Solar masses
elif m ==63: mass, mass_indice = 10**5.10, '510' #Solar masses
elif m ==64: mass, mass_indice = 10**5.15, '515' #Solar masses
elif m ==65: mass, mass_indice = 10**5.20, '520' #Solar masses
elif m ==66: mass, mass_indice = 10**5.25, '525' #Solar masses
elif m ==67: mass, mass_indice = 10**5.30, '530' #Solar masses
elif m ==68: mass, mass_indice = 10**5.35, '535' #Solar masses
elif m ==69: mass, mass_indice = 10**5.40, '540' #Solar masses
elif m ==70: mass, mass_indice = 10**5.45, '545' #Solar masses
elif m ==71: mass, mass_indice = 10**5.50, '550' #Solar masses
elif m ==72: mass, mass_indice = 10**5.55, '555' #Solar masses
elif m ==73: mass, mass_indice = 10**5.60, '560' #Solar masses
elif m ==74: mass, mass_indice = 10**5.65, '565' #Solar masses
elif m ==75: mass, mass_indice = 10**5.70, '570' #Solar masses
elif m ==76: mass, mass_indice = 10**5.75, '575' #Solar masses
elif m ==77: mass, mass_indice = 10**5.80, '580' #Solar masses
elif m ==78: mass, mass_indice = 10**5.85, '585' #Solar masses
elif m ==79: mass, mass_indice = 10**5.90, '590' #Solar masses
elif m ==80: mass, mass_indice = 10**5.95, '595' #Solar masses
elif m ==81: mass, mass_indice = 10**6.00, '600' #Solar masses
'''
#November 2011, end
#'''
if zz ==1: Z, Z_indice = 0.00010 , 'm23' # [M/H] = -2.3
elif zz ==2: Z, Z_indice = 0.00013 , 'm22' # [M/H] = -2.2 #Should be 0.00012
elif zz ==3: Z, Z_indice = 0.00015 , 'm21' # [M/H] = -2.1
elif zz ==4: Z, Z_indice = 0.00019 , 'm20' # [M/H] = -2.0
elif zz ==5: Z, Z_indice = 0.00024 , 'm19' # [M/H] = -1.9
elif zz ==6: Z, Z_indice = 0.00030 , 'm18' # [M/H] = -1.8
elif zz ==7: Z, Z_indice = 0.00040 , 'm17' # [M/H] = -1.7
elif zz ==8: Z, Z_indice = 0.00050 , 'm16' # [M/H] = -1.6
elif zz ==9: Z, Z_indice = 0.00060 , 'm15' # [M/H] = -1.5
elif zz ==10: Z, Z_indice = 0.00080 , 'm14' # [M/H] = -1.4 #Should be 0.00075
elif zz ==11: Z, Z_indice = 0.00100 , 'm13' # [M/H] = -1.3
elif zz ==12: Z, Z_indice = 0.00130 , 'm12' # [M/H] = -1.2 #Should be 0.00120
elif zz ==13: Z, Z_indice = 0.00150 , 'm11' # [M/H] = -1.1
elif zz ==14: Z, Z_indice = 0.00190 , 'm10' # [M/H] = -1.0
elif zz ==15: Z, Z_indice = 0.00240 , 'm09' # [M/H] = -0.9
elif zz ==16: Z, Z_indice = 0.00300 , 'm08' # [M/H] = -0.8
elif zz ==17: Z, Z_indice = 0.00400 , 'm07' # [M/H] = -0.7 #Should be 0.00380
elif zz ==18: Z, Z_indice = 0.00500 , 'm06' # [M/H] = -0.6 #Should be 0.00480
elif zz ==19: Z, Z_indice = 0.00600 , 'm05' # [M/H] = -0.5
elif zz ==20: Z, Z_indice = 0.00800 , 'm04' # [M/H] = -0.4
elif zz ==21: Z, Z_indice = 0.01000 , 'm03' # [M/H] = -0.3
elif zz ==22: Z, Z_indice = 0.01300 , 'm02' # [M/H] = -0.2 #Should be 0.01200
elif zz ==23: Z, Z_indice = 0.01500 , 'm01' # [M/H] = -0.1
elif zz ==24: Z, Z_indice = 0.01900 , 'n00' # [M/H] = +0.0
elif zz ==25: Z, Z_indice = 0.02400 , 'p01' # [M/H] = +0.1
elif zz ==26: Z, Z_indice = 0.03000 , 'p02' # [M/H] = +0.2
elif zz ==27: Z, Z_indice = 0.04000 , 'p03' # [M/H] = +0.3
elif zz ==28: Z, Z_indice = 0.05000 , 'p04' # [M/H] = +0.4
return age, mass, Z, age_indice, mass_indice, Z_indice
def mass_to_mass_indice(mass): #Mass should be entered in LOG! 4 in place of 10000Ms
mass_int = int(round(mass*100.))
mass_indice = str(mass_int)
return mass_indice
def age_mass_Z_December2011_inverse(age, mass, Z, age_indice, mass_indice, Z_indice):
#Age grid December 2011
age = (age - 6.60)/0.05
a = int(round(age)) + 1
age_indice = (float(age_indice)/100. - 6.60)/0.05
a_indice = int(round(age_indice)) + 1
#if a != a_indice:
# print a, a_indice
# print 'error'
# raw_input()
#Mass grid December 2011
mass = (math.log10(mass) - 2.0)/0.05
m = int(round(mass)) + 1
mass_indice = (float(mass_indice)/100. - 2.0)/0.05
m_indice = int(round(mass_indice)) + 1
#if m != m_indice:
# print m, m_indice
# print 'error'
# raw_input()
#November 2011, end
if Z == 0.00010 or Z_indice == 'm23' : zz = 1 # [M/H] = -2.3
elif Z == 0.00013 or Z_indice == 'm22' : zz = 2 # [M/H] = -2.2 #Should be 0.00012
elif Z == 0.00015 or Z_indice == 'm21' : zz = 3 # [M/H] = -2.1
elif Z == 0.00019 or Z_indice == 'm20' : zz = 4 # [M/H] = -2.0
elif Z == 0.00024 or Z_indice == 'm19' : zz = 5 # [M/H] = -1.9
elif Z == 0.00030 or Z_indice == 'm18' : zz = 6 # [M/H] = -1.8
elif Z == 0.00040 or Z_indice == 'm17' : zz = 7 # [M/H] = -1.7
elif Z == 0.00050 or Z_indice == 'm16' : zz = 8 # [M/H] = -1.6
elif Z == 0.00060 or Z_indice == 'm15' : zz = 9 # [M/H] = -1.5
elif Z == 0.00080 or Z_indice == 'm14' : zz = 10 # [M/H] = -1.4 #Should be 0.00075
elif Z == 0.00100 or Z_indice == 'm13' : zz = 11 # [M/H] = -1.3
elif Z == 0.00130 or Z_indice == 'm12' : zz = 12 # [M/H] = -1.2 #Should be 0.00120
elif Z == 0.00150 or Z_indice == 'm11' : zz = 13 # [M/H] = -1.1
elif Z == 0.00190 or Z_indice == 'm10' : zz = 14 # [M/H] = -1.0
elif Z == 0.00240 or Z_indice == 'm09' : zz = 15 # [M/H] = -0.9
elif Z == 0.00300 or Z_indice == 'm08' : zz = 16 # [M/H] = -0.8
elif Z == 0.00400 or Z_indice == 'm07' : zz = 17 # [M/H] = -0.7 #Should be 0.00380
elif Z == 0.00500 or Z_indice == 'm06' : zz = 18 # [M/H] = -0.6 #Should be 0.00480
elif Z == 0.00600 or Z_indice == 'm05' : zz = 19 # [M/H] = -0.5
elif Z == 0.00800 or Z_indice == 'm04' : zz = 20 # [M/H] = -0.4
elif Z == 0.01000 or Z_indice == 'm03' : zz = 21 # [M/H] = -0.3
elif Z == 0.01300 or Z_indice == 'm02' : zz = 22 # [M/H] = -0.2 #Should be 0.01200
elif Z == 0.01500 or Z_indice == 'm01' : zz = 23 # [M/H] = -0.1
elif Z == 0.01900 or Z_indice == 'n00' : zz = 24 # [M/H] = +0.0
elif Z == 0.02400 or Z_indice == 'p01' : zz = 25 # [M/H] = +0.1
elif Z == 0.03000 or Z_indice == 'p02' : zz = 26 # [M/H] = +0.2
elif Z == 0.04000 or Z_indice == 'p03' : zz = 27 # [M/H] = +0.3
elif Z == 0.05000 or Z_indice == 'p04' : zz = 28 # [M/H] = +0.4
#return age, mass, Z, age_indice, mass_indice, Z_indice
return a, m, zz
def indices_to_aa_mm_zz(age_indice, mass_indice, Z_indice):
#Age grid December 2011
#age = (age - 6.60)/0.05
#a = int(round(age)) + 1
age_indice = (float(age_indice)/100. - 6.60)/0.05
a = int(round(age_indice)) + 1
#if a != a_indice:
# print a, a_indice
# print 'error'
# raw_input()
#Mass grid December 2011
#mass = (math.log10(mass) - 2.0)/0.05
#m = int(round(mass)) + 1
mass_indice = (float(mass_indice)/100. - 2.0)/0.05
m = int(round(mass_indice)) + 1
#if m != m_indice:
# print m, m_indice
# print 'error'
# raw_input()
#November 2011, end
if Z_indice == 'm23' : zz = 1 # [M/H] = -2.3
elif Z_indice == 'm22' : zz = 2 # [M/H] = -2.2 #Should be 0.00012
elif Z_indice == 'm21' : zz = 3 # [M/H] = -2.1
elif Z_indice == 'm20' : zz = 4 # [M/H] = -2.0
elif Z_indice == 'm19' : zz = 5 # [M/H] = -1.9
elif Z_indice == 'm18' : zz = 6 # [M/H] = -1.8
elif Z_indice == 'm17' : zz = 7 # [M/H] = -1.7
elif Z_indice == 'm16' : zz = 8 # [M/H] = -1.6
elif Z_indice == 'm15' : zz = 9 # [M/H] = -1.5
elif Z_indice == 'm14' : zz = 10 # [M/H] = -1.4 #Should be 0.00075
elif Z_indice == 'm13' : zz = 11 # [M/H] = -1.3
elif Z_indice == 'm12' : zz = 12 # [M/H] = -1.2 #Should be 0.00120
elif Z_indice == 'm11' : zz = 13 # [M/H] = -1.1
elif Z_indice == 'm10' : zz = 14 # [M/H] = -1.0
elif Z_indice == 'm09' : zz = 15 # [M/H] = -0.9
elif Z_indice == 'm08' : zz = 16 # [M/H] = -0.8
elif Z_indice == 'm07' : zz = 17 # [M/H] = -0.7 #Should be 0.00380
elif Z_indice == 'm06' : zz = 18 # [M/H] = -0.6 #Should be 0.00480
elif Z_indice == 'm05' : zz = 19 # [M/H] = -0.5
elif Z_indice == 'm04' : zz = 20 # [M/H] = -0.4
elif Z_indice == 'm03' : zz = 21 # [M/H] = -0.3
elif Z_indice == 'm02' : zz = 22 # [M/H] = -0.2 #Should be 0.01200
elif Z_indice == 'm01' : zz = 23 # [M/H] = -0.1
elif Z_indice == 'n00' : zz = 24 # [M/H] = +0.0
elif Z_indice == 'p01' : zz = 25 # [M/H] = +0.1
elif Z_indice == 'p02' : zz = 26 # [M/H] = +0.2
elif Z_indice == 'p03' : zz = 27 # [M/H] = +0.3
elif Z_indice == 'p04' : zz = 28 # [M/H] = +0.4
#return age, mass, Z, age_indice, mass_indice, Z_indice
return a, m, zz
def Zindex_to_Z_and_zz(Z_indice):
if Z_indice == 'm23' : Z,zz = 0.00010, 1 # [M/H] = -2.3
elif Z_indice == 'm22' : Z,zz = 0.00013, 2 # [M/H] = -2.2 #Should be 0.00012
elif Z_indice == 'm21' : Z,zz = 0.00015, 3 # [M/H] = -2.1
elif Z_indice == 'm20' : Z,zz = 0.00019, 4 # [M/H] = -2.0
elif Z_indice == 'm19' : Z,zz = 0.00024, 5 # [M/H] = -1.9
elif Z_indice == 'm18' : Z,zz = 0.00030, 6 # [M/H] = -1.8
elif Z_indice == 'm17' : Z,zz = 0.00040, 7 # [M/H] = -1.7
elif Z_indice == 'm16' : Z,zz = 0.00050, 8 # [M/H] = -1.6
elif Z_indice == 'm15' : Z,zz = 0.00060, 9 # [M/H] = -1.5
elif Z_indice == 'm14' : Z,zz = 0.00080, 10 # [M/H] = -1.4 #Should be 0.00075
elif Z_indice == 'm13' : Z,zz = 0.00100, 11 # [M/H] = -1.3
elif Z_indice == 'm12' : Z,zz = 0.00130, 12 # [M/H] = -1.2 #Should be 0.00120
elif Z_indice == 'm11' : Z,zz = 0.00150, 13 # [M/H] = -1.1
elif Z_indice == 'm10' : Z,zz = 0.00190, 14 # [M/H] = -1.0
elif Z_indice == 'm09' : Z,zz = 0.00240, 15 # [M/H] = -0.9
elif Z_indice == 'm08' : Z,zz = 0.00300, 16 # [M/H] = -0.8
elif Z_indice == 'm07' : Z,zz = 0.00400, 17 # [M/H] = -0.7 #Should be 0.00380
elif Z_indice == 'm06' : Z,zz = 0.00500, 18 # [M/H] = -0.6 #Should be 0.00480
elif Z_indice == 'm05' : Z,zz = 0.00600, 19 # [M/H] = -0.5
elif Z_indice == 'm04' : Z,zz = 0.00800, 20 # [M/H] = -0.4
elif Z_indice == 'm03' : Z,zz = 0.01000, 21 # [M/H] = -0.3
elif Z_indice == 'm02' : Z,zz = 0.01300, 22 # [M/H] = -0.2 #Should be 0.01200
elif Z_indice == 'm01' : Z,zz = 0.01500, 23 # [M/H] = -0.1
elif Z_indice == 'n00' : Z,zz = 0.01900, 24 # [M/H] = +0.0
elif Z_indice == 'p01' : Z,zz = 0.02400, 25 # [M/H] = +0.1
elif Z_indice == 'p02' : Z,zz = 0.03000, 26 # [M/H] = +0.2
elif Z_indice == 'p03' : Z,zz = 0.04000, 27 # [M/H] = +0.3
elif Z_indice == 'p04' : Z,zz = 0.05000, 28 # [M/H] = +0.4
return Z,zz
def Z_to_Zindex_and_zz(Z):
if Z==0.00010 : Z_indice ,zz = 'm23', 1 # [M/H] = -2.3
elif Z==0.00013 : Z_indice ,zz = 'm22', 2 # [M/H] = -2.2 #Should be 0.00012
elif Z==0.00015 : Z_indice ,zz = 'm21', 3 # [M/H] = -2.1
elif Z==0.00019 : Z_indice ,zz = 'm20', 4 # [M/H] = -2.0
elif Z==0.00024 : Z_indice ,zz = 'm19', 5 # [M/H] = -1.9
elif Z==0.00030 : Z_indice ,zz = 'm18', 6 # [M/H] = -1.8
elif Z==0.00040 : Z_indice ,zz = 'm17', 7 # [M/H] = -1.7
elif Z==0.00050 : Z_indice ,zz = 'm16', 8 # [M/H] = -1.6
elif Z==0.00060 : Z_indice ,zz = 'm15', 9 # [M/H] = -1.5
elif Z==0.00080 : Z_indice ,zz = 'm14', 10 # [M/H] = -1.4 #Should be 0.00075
elif Z==0.00100 : Z_indice ,zz = 'm13', 11 # [M/H] = -1.3
elif Z==0.00130 : Z_indice ,zz = 'm12', 12 # [M/H] = -1.2 #Should be 0.00120
elif Z==0.00150 : Z_indice ,zz = 'm11', 13 # [M/H] = -1.1
elif Z==0.00190 : Z_indice ,zz = 'm10', 14 # [M/H] = -1.0
elif Z==0.00240 : Z_indice ,zz = 'm09', 15 # [M/H] = -0.9
elif Z==0.00300 : Z_indice ,zz = 'm08', 16 # [M/H] = -0.8
elif Z==0.00400 : Z_indice ,zz = 'm07', 17 # [M/H] = -0.7 #Should be 0.00380
elif Z==0.00500 : Z_indice ,zz = 'm06', 18 # [M/H] = -0.6 #Should be 0.00480
elif Z==0.00600 : Z_indice ,zz = 'm05', 19 # [M/H] = -0.5
elif Z==0.00800 : Z_indice ,zz = 'm04', 20 # [M/H] = -0.4
elif Z==0.01000 : Z_indice ,zz = 'm03', 21 # [M/H] = -0.3
elif Z==0.01300 : Z_indice ,zz = 'm02', 22 # [M/H] = -0.2 #Should be 0.01200
elif Z==0.01500 : Z_indice ,zz = 'm01', 23 # [M/H] = -0.1
elif Z==0.01900 : Z_indice ,zz = 'n00', 24 # [M/H] = +0.0
elif Z==0.02400 : Z_indice ,zz = 'p01', 25 # [M/H] = +0.1
elif Z==0.03000 : Z_indice ,zz = 'p02', 26 # [M/H] = +0.2
elif Z==0.04000 : Z_indice ,zz = 'p03', 27 # [M/H] = +0.3
elif Z==0.05000 : Z_indice ,zz = 'p04', 28 # [M/H] = +0.4
return Z_indice,zz
def Z_to_Zindex_and_zz_and_jj(Z):
if Z==0.00010 : Z_indice ,zz,jj = 'm23', 1 , 99 # [M/H] = -2.3
elif Z==0.00013 : Z_indice ,zz,jj = 'm22', 2 , 12 # [M/H] = -2.2 #Should be 0.00012
elif Z==0.00015 : Z_indice ,zz,jj = 'm21', 3 , 99 # [M/H] = -2.1
elif Z==0.00019 : Z_indice ,zz,jj = 'm20', 4 , 11 # [M/H] = -2.0
elif Z==0.00024 : Z_indice ,zz,jj = 'm19', 5 , 99 # [M/H] = -1.9
elif Z==0.00030 : Z_indice ,zz,jj = 'm18', 6 , 10 # [M/H] = -1.8
elif Z==0.00040 : Z_indice ,zz,jj = 'm17', 7 , 99 # [M/H] = -1.7
elif Z==0.00050 : Z_indice ,zz,jj = 'm16', 8 , 9 # [M/H] = -1.6
elif Z==0.00060 : Z_indice ,zz,jj = 'm15', 9 , 99 # [M/H] = -1.5
elif Z==0.00080 : Z_indice ,zz,jj = 'm14', 10, 8 # [M/H] = -1.4 #Should be 0.00075
elif Z==0.00100 : Z_indice ,zz,jj = 'm13', 11, 99 # [M/H] = -1.3
elif Z==0.00130 : Z_indice ,zz,jj = 'm12', 12, 7 # [M/H] = -1.2 #Should be 0.00120
elif Z==0.00150 : Z_indice ,zz,jj = 'm11', 13, 99 # [M/H] = -1.1
elif Z==0.00190 : Z_indice ,zz,jj = 'm10', 14, 6 # [M/H] = -1.0
elif Z==0.00240 : Z_indice ,zz,jj = 'm09', 15, 99 # [M/H] = -0.9
elif Z==0.00300 : Z_indice ,zz,jj = 'm08', 16, 5 # [M/H] = -0.8
elif Z==0.00400 : Z_indice ,zz,jj = 'm07', 17, 99 # [M/H] = -0.7 #Should be 0.00380
elif Z==0.00500 : Z_indice ,zz,jj = 'm06', 18, 4 # [M/H] = -0.6 #Should be 0.00480
elif Z==0.00600 : Z_indice ,zz,jj = 'm05', 19, 99 # [M/H] = -0.5
elif Z==0.00800 : Z_indice ,zz,jj = 'm04', 20, 3 # [M/H] = -0.4
elif Z==0.01000 : Z_indice ,zz,jj = 'm03', 21, 99 # [M/H] = -0.3
elif Z==0.01300 : Z_indice ,zz,jj = 'm02', 22, 2 # [M/H] = -0.2 #Should be 0.01200
elif Z==0.01500 : Z_indice ,zz,jj = 'm01', 23, 99 # [M/H] = -0.1
elif Z==0.01900 : Z_indice ,zz,jj = 'n00', 24, 1 # [M/H] = +0.0
elif Z==0.02400 : Z_indice ,zz,jj = 'p01', 25, 99 # [M/H] = +0.1
elif Z==0.03000 : Z_indice ,zz,jj = 'p02', 26, 0 # [M/H] = +0.2
elif Z==0.04000 : Z_indice ,zz,jj = 'p03', 27, 99 # [M/H] = +0.3
elif Z==0.05000 : Z_indice ,zz,jj = 'p04', 28, 99 # [M/H] = +0.4
return Z_indice,zz,jj
def zz_to_Z_and_Zindex(zz):
if zz ==1: Z, Z_indice = 0.00010 , 'm23' # [M/H] = -2.3
elif zz ==2: Z, Z_indice = 0.00013 , 'm22' # [M/H] = -2.2 #Should be 0.00012
elif zz ==3: Z, Z_indice = 0.00015 , 'm21' # [M/H] = -2.1
elif zz ==4: Z, Z_indice = 0.00019 , 'm20' # [M/H] = -2.0
elif zz ==5: Z, Z_indice = 0.00024 , 'm19' # [M/H] = -1.9
elif zz ==6: Z, Z_indice = 0.00030 , 'm18' # [M/H] = -1.8
elif zz ==7: Z, Z_indice = 0.00040 , 'm17' # [M/H] = -1.7
elif zz ==8: Z, Z_indice = 0.00050 , 'm16' # [M/H] = -1.6
elif zz ==9: Z, Z_indice = 0.00060 , 'm15' # [M/H] = -1.5
elif zz ==10: Z, Z_indice = 0.00080 , 'm14' # [M/H] = -1.4 #Should be 0.00075
elif zz ==11: Z, Z_indice = 0.00100 , 'm13' # [M/H] = -1.3
elif zz ==12: Z, Z_indice = 0.00130 , 'm12' # [M/H] = -1.2 #Should be 0.00120
elif zz ==13: Z, Z_indice = 0.00150 , 'm11' # [M/H] = -1.1
elif zz ==14: Z, Z_indice = 0.00190 , 'm10' # [M/H] = -1.0
elif zz ==15: Z, Z_indice = 0.00240 , 'm09' # [M/H] = -0.9
elif zz ==16: Z, Z_indice = 0.00300 , 'm08' # [M/H] = -0.8
elif zz ==17: Z, Z_indice = 0.00400 , 'm07' # [M/H] = -0.7 #Should be 0.00380
elif zz ==18: Z, Z_indice = 0.00500 , 'm06' # [M/H] = -0.6 #Should be 0.00480
elif zz ==19: Z, Z_indice = 0.00600 , 'm05' # [M/H] = -0.5
elif zz ==20: Z, Z_indice = 0.00800 , 'm04' # [M/H] = -0.4
elif zz ==21: Z, Z_indice = 0.01000 , 'm03' # [M/H] = -0.3
elif zz ==22: Z, Z_indice = 0.01300 , 'm02' # [M/H] = -0.2 #Should be 0.01200
elif zz ==23: Z, Z_indice = 0.01500 , 'm01' # [M/H] = -0.1
elif zz ==24: Z, Z_indice = 0.01900 , 'n00' # [M/H] = +0.0
elif zz ==25: Z, Z_indice = 0.02400 , 'p01' # [M/H] = +0.1
elif zz ==26: Z, Z_indice = 0.03000 , 'p02' # [M/H] = +0.2
elif zz ==27: Z, Z_indice = 0.04000 , 'p03' # [M/H] = +0.3
elif zz ==28: Z, Z_indice = 0.05000 , 'p04' # [M/H] = +0.4
return Z,Z_indice
def node_from_NPZ(aa,mm,zz): #Function to extract a node from a NPZ grid
U,B,V = np.zeros(1000), np.zeros(1000), np.zeros(1000)
age, mass, Z, age_indice, mass_indice, Z_indice = Lecture_module.age_mass_Z_December2011(aa,mm,zz)
#Open the npz node file