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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181 | class ICF(object):
def __init__(self):
"""
ICF tool.
No parameters for the instantiation.
"""
self.log_ = pn.log_
self.calling = 'ICF'
self._init_all_icfs()
self._max_pass = 3
def _init_all_icfs(self):
# Dictionary of ICF recipes
self.all_icfs = {'direct_He.23':{'elem': 'He',
'atom': 'abun["He2"] + abun["He3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_N.23':{'elem': 'N',
'atom': 'abun["N2"] + abun["N3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_N.234':{'elem': 'N',
'atom': 'abun["N2"] + abun["N3"] + abun["N4"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_N.2345':{'elem': 'N',
'atom': 'abun["N2"] + abun["N3"] + abun["N4"] + abun["N5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_O.23':{'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_O.234':{'elem': 'O',
'atom': 'abun["O2"] + abun["O3"] + abun["O4"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_O.2345':{'elem': 'O',
'atom': 'abun["O2"] + abun["O3"] + abun["O4"] + abun["O5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_S.23':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_S.234':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"] + abun["S4"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_S.2345':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"] + abun["S4"] + abun["S5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ne.23':{'elem': 'Ne',
'atom': 'abun["Ne2"] + abun["Ne3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ne.235':{'elem': 'Ne',
'atom': 'abun["Ne2"] + abun["Ne3"] + abun["Ne5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ne.2345':{'elem': 'Ne',
'atom': 'abun["Ne2"] + abun["Ne3"] + abun["Ne4"] + abun["Ne5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ne.345':{'elem': 'Ne',
'atom': 'abun["Ne3"] + abun["Ne4"] + abun["Ne5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ne.2356':{'elem': 'Ne',
'atom': 'abun["Ne2"] + abun["Ne3"] + abun["Ne5"] + abun["Ne6"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Mg.45':{'elem': 'Mg',
'atom': 'abun["Mg4"] + abun["Mg5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ar.23':{'elem': 'Ar',
'atom': 'abun["Ar2"] + abun["Ar3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ar.234':{'elem': 'Ar',
'atom': 'abun["Ar2"] + abun["Ar3"] + abun["Ar4"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Ar.345':{'elem': 'Ar',
'atom': 'abun["Ar3"] + abun["Ar4"] + abun["Ar5"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Cl.23':{'elem': 'Cl',
'atom': 'abun["Cl2"] + abun["Cl3"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Cl.34':{'elem': 'Cl',
'atom': 'abun["Cl3"] + abun["Cl4"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'direct_Cl.234':{'elem': 'Cl',
'atom': 'abun["Cl2"] + abun["Cl3"] + abun["Cl4"]',
'icf': '1',
'type': 'All',
'comment': 'just summing visible ions'},
'TPP77_13': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '(abun["He2"] + abun["He3"]) / abun["He2"]',
'type': 'PNe',
'comment': ''},
'TPP77_14': {'elem': 'N',
'atom': 'abun["N2"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O2"]',
'type': 'PNe',
'comment': ''},
'TPP77_15': {'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O3"]',
'type': 'PNe',
'comment': ''},
'PHCD07_12': {'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O3"]',
'type': 'HII',
'comment': 'Based on a grid of photoionization models'},
'PHCD07_13': {'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': '(0.753 + 0.142 * abun["O3"] / (abun["O2"] + abun["O3"]) + 0.171 / abun["O3"] * (abun["O2"] + abun["O3"]))',
'type': 'HII',
'comment': 'Based on a grid of photoionization models'},
# PHCD07_16 and 17 added on December 11, 2014
'PHCD07_16': {'elem': 'Ar',
'atom': '(abun["Ar3"] + abun["Ar4"])',
'icf': '(0.928 + 0.364 * (1 - abun["O3"] / (abun["O2"] + abun["O3"])) + 0.006 / (1 - abun["O3"] / (abun["O2"] + abun["O3"])))',
'type': 'HII',
'comment': 'Based on a grid of photoionization models'},
'PHCD07_17': {'elem': 'Ar',
'atom': 'abun["Ar3"]',
'icf': '(0.596 + 0.967 * (1 - abun["O3"] / (abun["O2"] + abun["O3"])) + 0.077 / (1 - abun["O3"] / (abun["O2"] + abun["O3"])))',
'type': 'HII',
'comment': 'Based on a grid of photoionization models'},
# Cited in PHCD07 but originally proposed by ITL94. Authorship changed in the code 3/Nov/2014.
# 'PHCD07_14': {'elem': 'Ar',
'ITL94_19': {'elem': 'Ar',
'atom': '(abun["Ar3"] + abun["Ar4"])',
'icf': '(0.99 + 0.091 * abun["O2"] / (abun["O2"] + abun["O3"]) - 1.14 * (abun["O2"] / (abun["O2"] + abun["O3"]))**2. + 0.077 * (abun["O2"] / (abun["O2"] + abun["O3"]))**3.)**-1.',
'type': 'HII',
'comment': 'Based on a grid of photoionization models'},
# Cited in PHCD07 but originally proposed by ITL94. Authorship changed in the code 3/Nov/2014.
# 'PHCD07_15': {'elem': 'Ar',
'ITL94_20': {'elem': 'Ar',
'atom': 'abun["Ar3"]',
'icf': '(0.15 + 2.39 * abun["O2"] / (abun["O2"] + abun["O3"]) - 2.64 * (abun["O2"] / (abun["O2"] + abun["O3"]))**2.)**-1.',
'type': 'HII',
'comment': 'Based on a grid of photoionization models'},
'PTPR92_21':{'elem': 'He',
'atom': 'abun["He2"]',
'icf': '(1 + abun["S2"] / (elem_abun["KB94_A36.10"] - abun["S2"]))',
'type': 'HII',
'comment': 'Based on ionization potentials'},
'KB94_A0': {'elem': 'N',
'atom': 'abun["N2"] + abun["N3"] + abun["N4"] + abun["N5"]',
'icf': '1',
'type': 'PNe',
'comment': 'Sum of all N ions from N+ to N4+'},
'KB94_A1.6': {'elem': 'N',
'atom': 'abun["N2"]',
'icf': 'elem_abun["KB94_A6"] / abun["O2"]',
'type': 'PNe',
# Comment clarified on 12 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 are detected, but O5 is not'},
'KB94_A1.8': {'elem': 'N',
'atom': 'abun["N2"]',
'icf': 'elem_abun["KB94_A8"] / abun["O2"]',
'type': 'PNe',
# wrong comment. Corrected 12 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. To be used if both O3 and are N5 detected, but O4 is not'},
'KB94_A1.10': {'elem': 'N',
'atom': 'abun["N2"]',
'icf': 'elem_abun["KB94_A10"] / abun["O2"]',
'type': 'PNe',
# wrong comment. Corrected 12 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. To be used if only O2 and O3 are detected'},
'KB94_A1.10b': {'elem': 'N',
'atom': 'abun["N2"]',
'icf': 'elem_abun["KB94_A10b"] / abun["O2"]',
'type': 'PNe',
# wrong comment. Corrected 12 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. To be used if only O2 and O3 are detected and no HeII is seen'},
'KB94_A6': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"] + abun["O4"]',
'icf': '1 / (1 - 0.95 * abun["N5"] / (abun["N2"] + abun["N3"] + abun["N4"] + abun["N5"]))',
'type': 'PNe',
# Comment clarified on 12 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 are detected, but O5 is not'},
'KB94_A8': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '(abun["N2"] + abun["N3"] + abun["N4"] + abun["N5"]) / (abun["N2"] + abun["N3"])',
'type': 'PNe',
# Comment clarified on 12 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if N5 detected and O4 not detected'},
'comment': 'Based on a grid of photoionization models. To be used if N5 detected, but neither O3 nor O4 are'},
'KB94_A10': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '((abun["He2"] + abun["He3"]) / abun["He2"])**(2./3.)',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models. To be used if only O2 and O3 are detected'},
'KB94_A10b': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '1',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models. To be used if only O2 and O3 are detected and no HeII is seen'},
# Wrong 12 Dec 2014
# 'KB94_A10.5': {'elem': 'C',
# 'atom': 'abun["C2"] + abun["C3"] + abun["C4"] + abun["C5"]',
# 'icf': '1',
# 'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. To be used if no He3 detected and C2, C3, and C4 detected'},
# Misleading comment clarified on 12 Dec 2014
'KB94_A12': {'elem': 'C',
'atom': 'abun["C3"] + abun["C4"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O3"]',
'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. To be used if no C II lines detected'},
'comment': 'Based on a grid of photoionization models. To be used if no C2 lines available and C4 and He3 are not present'},
# Wrong because eq. A10 does not point to eq. A6 (no O4 present). 12 Dec 2014
# 'KB94_A13.6': {'elem': 'C',
# 'atom': 'abun["C3"]',
# 'icf': 'elem_abun["KB94_A6"] / abun["O3"]',
# 'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. To be used if no C II lines detected'},
#
# Wrong because eq. A10 does not point to eq. A8 (no N5 present)
# 'KB94_A13.8': {'elem': 'C',
# 'icf': 'elem_abun["KB94_A8"] / abun["O3"]',
# 'atom': 'abun["C3"]',
# 'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. To be used if no C II lines detected'},
# Misleading comment clarified on 12 Dec 2014
'KB94_A13.10': {'elem': 'C',
'atom': 'abun["C3"]',
'icf': 'elem_abun["KB94_A10"] / abun["O3"]',
'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. To be used if no C II lines detected'},
'comment': 'Based on a grid of photoionization models. To be used if C5 is not present; only C3 lines are detected; O3 also detected; He2 and He3 also detected'},
'KB94_A13.10b': {'elem': 'C',
'atom': 'abun["C3"]',
'icf': 'elem_abun["KB94_A10b"] / abun["O3"]',
'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. To be used if no C II lines detected'},
'comment': 'Based on a grid of photoionization models. To be used if C5 is not present; only C3 lines are detected; O3 also detected; He2 also detected, He3 Not'},
# Clarified comment 12 Dec 2014
'KB94_A16': {'elem': 'C',
'atom': 'abun["C2"] + abun["C3"] + abun["C4"]',
'icf': '1 / (1 - 2.7 * abun["N5"] / (abun["N2"] + abun["N3"] + abun["N4"] + abun["N5"]))',
'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. Valid for high excitation PNe if icf < 5'},
'comment': 'Based on a grid of photoionization models. To be used in high excitation PNe where C5 is present (as inferred from He3 and N5). Valid if icf < 5'},
# Clarified comment 12 Dec 2014
'KB94_A19': {'elem': 'C',
'atom': 'abun["C2"] + abun["C3"] + abun["C4"]',
'icf': '(1 + abun["N5"] / (abun["N2"] + abun["N3"] + abun["N4"]))',
'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. Valid for extremely high excitation PNe if icf > 5'},
'comment': 'Based on a grid of photoionization models. To be used in very high excitation PNe where C5 is present (as inferred from He3 and N5). Valid if icf > 5'},
'KB94_A21': {'elem': 'C',
'atom': 'abun["C2"] + abun["C3"] + abun["C4"]',
'icf': '((abun["He2"] + abun["He3"]) / abun["He2"])**(1./3.)',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models. Valid if He3 present and N5 absent'},
# Clarified comment 12 Dec 2014
'KB94_A26': {'elem': 'C',
'atom': 'abun["C2"] + abun["C3"] + abun["C4"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O3"] * ((abun["He2"] + abun["He3"]) / abun["He2"])**(1./3.)',
'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models. Valid if C5 is present but N4 or N5 not seen'},
'comment': 'Based on a grid of photoionization models. Valid if C5 is present but only optical data are available, so N4 and N5 are not seen'},
'KB94_A27': {'elem': 'Ne',
'atom': 'abun["Ne3"] + abun["Ne5"]',
'icf': '1.5',
'type': 'PNe',
# Wrong comment. Corrected 19 Dec 2014
# 'comment': 'Based on a grid of photoionization models. Valid if N4 or N5 not seen'},
'comment': 'Based on a grid of photoionization models. Valid if Ne3 and Ne5 are seen and Ne4 is not'},
#
# Unsure about this icf. I don't know if eq. 28 can be mixed with eq. 6. In any case, I explicitly set out the conditions of eq. 6 in the comment.
'KB94_A28.6':{'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': 'elem_abun["KB94_A6"] / abun["O3"]',
'type': 'PNe',
# Wrong comment. Corrected 19 Dec 2014
# 'comment': 'Based on a grid of photoionization models. Valid if N4 or N5 not seen'},
'comment': 'Based on a grid of photoionization models. Valid if neither Ne4 nor Ne5 are seen, both O4 and N5 are detected, but O5 is not'},
#
# Unsure about this icf. I don't know if eq. 28 can be mixed with eq. 8. In any case, I explicitly set out the conditions of eq. 6 in the comment.
'KB94_A28.8':{'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': 'elem_abun["KB94_A8"] / abun["O3"]',
'type': 'PNe',
# Wrong comment. Corrected 19 Dec 2014
# 'comment': 'Based on a grid of photoionization models. Valid if N4 or N5 not seen'},
'comment': 'Based on a grid of photoionization models. Valid if neither Ne4 nor Ne5 are seen, N5 is detected, but neither O3 nor O4 are'},
#
# Unsure about this icf. I don't know if eq. 28 can be mixed with eq. 10. In any case, I explicitly set out the conditions of eq. 6 in the comment.
'KB94_A28.10':{'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': 'elem_abun["KB94_A10"] / abun["O3"]',
'type': 'PNe',
# Wrong comment. Corrected 19 Dec 2014
# 'comment': 'Based on a grid of photoionization models. Valid if N4 or N5 not seen'},
'comment': 'Based on a grid of photoionization models. Valid if neither Ne4 nor Ne5 are seen, if C5 is not present; only C3 lines are detected; O3 also detected; He2 and He3 also detected'},
'KB94_A28.10b':{'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': 'elem_abun["KB94_A10b"] / abun["O3"]',
'type': 'PNe',
# Wrong comment. Corrected 19 Dec 2014
# 'comment': 'Based on a grid of photoionization models. Valid if N4 or N5 not seen'},
'comment': 'Based on a grid of photoionization models. Valid if neither Ne4 nor Ne5 are seen, if C5 is not present; only C3 lines are detected; O3 also detected; He2 detected, He3 not.'},
# 26 Dec 2014 These icfs are temporarily commented out because they must be checked. The comments, at the very least, are wrong, and thee icfs may be physically wrong.
'KB94_A30.0': {'elem': 'Ar',
'atom': 'abun["Ar3"] + abun["Ar4"] + abun["Ar5"]',
'type': 'PNe',
'icf': '1./(1. - abun["N2"] / elem_abun["KB94_A0"])',
'comment': 'Based on a grid of photoionization models. To be used if N+ to N4+ are seen'},
'KB94_A30.10': {'elem': 'Ar',
'atom': 'abun["Ar3"] + abun["Ar4"] + abun["Ar5"]',
'icf': '1./(1. - abun["N2"] / elem_abun["KB94_A1.10"])',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models. To be used if He2 and He3 are detected.'},
'KB94_A30.10b': {'elem': 'Ar',
'atom': 'abun["Ar3"] + abun["Ar4"] + abun["Ar5"]',
'icf': '1./(1. - abun["N2"] / elem_abun["KB94_A1.10b"])',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models. To be used if He2 is detected.and He3 not.'},
# end block of commented icfs
'KB94_A32': {'elem': 'Ar',
'atom': 'abun["Ar3"]',
'icf': '1.87',
'type': 'PNe',
# Wrong comment. Corrected 26 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. To be used when only Ar3 is observed'},
'KB94_A36.6':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"]',
'icf': ' (1 - (1 - abun["O2"]/elem_abun["KB94_A6"])**3)**(-1./3.)',
'type': 'PNe',
# Wrong comment. Corrected 26 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. Valid if both S2 and S3 detected'},
'KB94_A36.8':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"]',
'icf': ' (1-(1 - abun["O2"]/elem_abun["KB94_A8"])**3)**(-1./3.)',
'type': 'PNe',
# Wrong comment. Corrected 26 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. Valid if both S2 and S3 detected'},
'KB94_A36.10':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"]',
'icf': ' (1-(1 - abun["O2"]/elem_abun["KB94_A10"])**3)**(-1./3.)',
'type': 'PNe',
# Wrong comment. Corrected 26 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. Valid if both S2 and S3 detected. He2 and He3 detected.'},
'KB94_A36.10b':{'elem': 'S',
'atom': 'abun["S2"] + abun["S3"]',
'icf': ' (1-(1 - abun["O2"]/elem_abun["KB94_A10b"])**3)**(-1./3.)',
'type': 'PNe',
# Wrong comment. Corrected 26 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. Valid if both S2 and S3 detected. He2 detected, He3 not.'},
# 26 Dec 2014 These icfs are temporarily commented out because they must be still be checked.
# June 2023, after talking with L. Stanghellini, it appears there is a typo in KB94_A38, 4.677 + instead of 4.677 *
'KB94_A38.6':{'elem': 'S',
'atom': 'abun["S2"]',
'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A6"])**3)**(-1./3.)) * (4.677 * (abun["O3"]/abun["O2"])**(0.433))',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
# Added 26 Dec 2014
'KB94_A38.8':{'elem': 'S',
'atom': 'abun["S2"]',
'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A8"])**3)**(-1./3.)) * (4.677 * (abun["O3"]/abun["O2"])**(0.433))',
'type': 'PNe',
'comment': 'BBased on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
# Added 26 Dec 2014
'KB94_A38.10':{'elem': 'S',
'atom': 'abun["S2"]',
'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A10"])**3)**(-1./3.)) * (4.677 * (abun["O3"]/abun["O2"])**(0.433))',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
'KH01_4a': {'elem': 'He',
'atom': 'abun["He2"] + abun["He3"]',
'icf': '1',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4b': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '(abun["He2"] + abun["He3"]) / abun["He2"]',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4c': {'elem': 'N',
'atom': 'abun["N2"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O2"] * (abun["He2"] + abun["He3"]) / abun["He2"]',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4d': {'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O3"] * (abun["He2"] + abun["He3"]) / abun["He2"]',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4e': {'elem': 'S',
'atom': 'abun["S2"] + abun["S3"]',
'icf': '10**(-0.017+0.18*np.log10(elem_abun["KH01_4b"]/ abun["O2"])-0.11*np.log10(elem_abun["KH01_4b"]/ abun["O2"])**2+0.072*np.log10(elem_abun["KH01_4b"]/ abun["O2"])**3)',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4f': {'elem': 'Cl',
'atom': 'abun["Cl3"] + abun["Cl4"]',
'icf': '(abun["He2"] + abun["He3"]) / abun["He2"]',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4g': {'elem': 'Ar',
'atom': 'abun["Ar3"] + abun["Ar4"]',
'icf': '(abun["He2"] + abun["He3"]) / abun["He2"] / (1 - abun["N2"] / (elem_abun["KH01_4c"]))',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models'},
'KH01_4txt': {'elem': 'Ar',
'atom': 'abun["Ar3"]',
'icf': '1',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models. To be used when log(O/O2) <= 0.6'},
'Ial06_16': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '1',
'type': 'HII',
'comment': 'Based on a grid of photoionization models. To be used if no 4686 detected'},
'Ial06_17': {'elem': 'O',
'atom': 'abun["O2"] + abun["O3"]',
'icf': '1 + 0.5 * abun["He3"] / (abun["He2"] + abun["He3"])',
'type': 'HII',
'comment': 'Based on a grid of photoionization models. To be used if 4686 detected'},
# Wrong. It is not a general ICF recipe but a particular case. Changed for PTPR92_21
#
# 'GRal04_10a': {'elem': 'He',
# 'atom': 'abun["He2"]',
# 'type': 'HII',
# 'icf': '1.05',
# 'comment': 'Based on the ionization potential. To be used if t2 = 0.00'},
# 'GRal04_10b': {'elem': 'He',
# 'atom': 'abun["He2"]',
# 'icf': '1.04',
# 'type': 'HII',
# 'comment': 'Based on the ionization potential. To be used if t2 > 0.00'},
'PTPR92_21': {'elem': 'He',
'atom': 'abun["He2"]',
'icf': '(1 + abun["S2"] / abun["S3"])',
'type': 'HII',
'comment': 'Based on the ionization potential, assumoing that S = S2 + S3'},
'PC69_40': {'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O3"]',
'type': 'HII',
'comment': 'High ionization degree'},
'S78_265b': {'elem': 'Ne',
'atom': 'abun["Ne3"]',
'icf': '(abun["O2"] + abun["O3"]) / (abun["O3"] - 0.2 * abun["O2"])',
'type': 'HII',
'comment': 'Based on photoionization models'},
# Superseded by RR05
# 'RR04_1': {'elem': 'Fe',
# 'atom': 'abun["Fe3"]',
# 'icf': '(abun["O2"] / abun["O3"])**0.09 * (abun["O2"] + abun["O3"]) / abun["O2"]',
# 'type': 'HII',
# 'comment': 'Based on photoionization models and the assumption that O/H = (O+ + O++) / H+'},
'RR05_2': {'elem': 'Fe',
'atom': 'abun["Fe3"]',
'icf': '0.9 * (abun["O2"] / abun["O3"])**0.08 * (abun["O2"] + abun["O3"]) / abun["O2"]',
'type': 'HII',
'comment': 'Based on fit to data and the assumption that O/H = (O+ + O++) / H+'},
'RR05_3': {'elem': 'Fe',
'atom': 'abun["Fe3"]',
'icf': '1.1 * (abun["O2"] / abun["O3"])**0.58 * (abun["O2"] + abun["O3"]) / abun["O2"]',
'type': 'All',
'comment': 'Based on PNe and HII data with -1.35 < log(O2/O3) < -0.1. It is assumed that O/H = (O+ + O++) / H+'},
'RR05_4': {'elem': 'Fe',
'atom': 'abun["Fe2"] + abun["Fe3"]',
'icf': '(abun["O2"] + abun["O3"]) / abun["O2"]',
'type': 'All',
'comment': 'Based on PNe and HII data with log(O2/O3) > -0.1. It is assumed that O/H = (O+ + O++) / H+'},
'GKA07_1.p269': {'elem': 'Cl',
'atom': 'abun["Cl3"]',
'icf': '(elem_abun["direct_He.23"] / abun["He2"])**2',
'type': 'PNe',
'comment': 'Based on photoionization models'},
'mGKA07-PTPR92_p269': {'elem': 'Cl',
'atom': 'abun["Cl3"]',
'icf': '(elem_abun["PTPR92_21"] / abun["He2"])**2',
'type': 'PNe',
'comment': 'Based on photoionization models'},
'DIMS14_10': {'elem': 'He',
'atom':'abun["He2"] + abun["He3"]',
'icf': '1.0',
'type': 'PNe',
'comment': 'Based on photoionization models'},
'DIMS14_12': {'elem': 'O',
'atom':'abun["O2"] + abun["O3"]',
'icf': '10**((0.08 * abun["He3"] / (abun["He2"] + abun["He3"]) + 0.006 * (abun["He3"] / (abun["He2"] + abun["He3"]))**2) / (0.34 - 0.27 * abun["He3"] / (abun["He2"] + abun["He3"])))',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.03 + 0.5 * abun["He3"] / (abun["He2"] + abun["He3"]) - 0.2 * (abun["He3"] / (abun["He2"] + abun["He3"]))**2',
'up_error': '0.03 + 0.5 * abun["He3"] / (abun["He2"] + abun["He3"]) - 0.2 * (abun["He3"] / (abun["He2"] + abun["He3"]))**2'},
'DIMS14_14': {'elem': 'N',
'atom':'abun["N2"]',
'icf': '10**(-0.16 * abun["O3"] / (abun["O2"] + abun["O3"]) * (1.0 + np.log10(abun["He3"] / (abun["He2"] + abun["He3"])))) * elem_abun["DIMS14_12"] / abun["O2"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.32 * abun["O3"] / (abun["O2"] + abun["O3"])',
'up_error': '0.50 * abun["O3"] / (abun["O2"] + abun["O3"])'},
'DIMS14_14b': {'elem': 'N',
'atom':'abun["N2"]',
'icf': '10**(0.64 * abun["O3"] / (abun["O2"] + abun["O3"])) * elem_abun["DIMS14_12"] / abun["O2"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.32 * abun["O3"] / (abun["O2"] + abun["O3"])',
'up_error': '0.50 * abun["O3"] / (abun["O2"] + abun["O3"])'},
'DIMS14_17a': {'elem': 'Ne',
'atom':'abun["Ne3"]',
'icf': '(abun["O3"] / (abun["O2"] + abun["O3"]) + (0.014 / (abun["He3"] / (abun["He2"] + abun["He3"])) + 2 * (abun["He3"] / (abun["He2"] + abun["He3"]))**2.7)**3 * (0.7 + 0.2 * abun["O3"] / (abun["O2"] + abun["O3"]) - 0.8 * (abun["O3"] / (abun["O2"] + abun["O3"]))**2)) * elem_abun["DIMS14_12"] / abun["O3"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.17',
'up_error': '0.12'},
'DIMS14_17b': {'elem': 'Ne',
'atom':'abun["Ne3"]',
'icf': '(abun["O3"] / (abun["O2"] + abun["O3"]) + (0.014 / (0.01) + 2 * (0.01)**2.7)**3 * (0.7 + 0.2 * abun["O3"] / (abun["O2"] + abun["O3"]) - 0.8 * (abun["O3"] / (abun["O2"] + abun["O3"]))**2)) * elem_abun["DIMS14_12"] / abun["O3"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.17',
'up_error': '0.12'},
'DIMS14_17c': {'elem': 'Ne',
'atom':'abun["Ne3"]',
'icf': '(abun["O3"] / (abun["O2"] + abun["O3"]) + (0.014 / (0.015) + 2 * (0.015)**2.7)**3 * (0.7 + 0.2 * abun["O3"] / (abun["O2"] + abun["O3"]) - 0.8 * (abun["O3"] / (abun["O2"] + abun["O3"]))**2)) * elem_abun["DIMS14_12"] / abun["O3"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.17',
'up_error': '0.12'},
'DIMS14_20': {'elem': 'Ne',
'atom':'abun["Ne3"]+abun["Ne5"]',
'icf': '(1.31+12.68*(abun["He3"]/(abun["He2"]+abun["He3"]))**2.57)**0.27',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.20',
'up_error': '0.17'},
'DIMS14_23': {'elem': 'S',
'atom':'abun["S2"]',
'icf': '(10**(0.31 - 0.52 * abun["He3"] / (abun["He2"] + abun["He3"]))) * elem_abun["DIMS14_12"] / abun["O2"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.38',
'up_error': '0.41'},
'DIMS14_26': {'elem': 'S',
'atom':'abun["S2"] + abun["S3"]',
'icf': '(10**((-0.02 - 0.03*abun["O3"] / (abun["O2"] + abun["O3"]) - 2.31*(abun["O3"] / (abun["O2"] + abun["O3"]))**2 + 2.19 * (abun["O3"] / (abun["O2"] + abun["O3"]))**3) / (0.69 + 2.09 * abun["O3"] / (abun["O2"] + abun["O3"]) - 2.69 * (abun["O3"] / (abun["O2"] + abun["O3"]))**2))) * elem_abun["DIMS14_12"] / abun["O2"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.20',
'up_error': '0.12'},
'DIMS14_29': {'elem': 'Cl',
'atom':'abun["Cl3"]',
'icf': '((4.162 - 4.1622*(abun["O3"] / (abun["O2"] + abun["O3"]))**0.21)**.75) * elem_abun["DIMS14_12"] / abun["O2"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.27',
'up_error': '0.15'},
'DIMS14_29b': {'elem': 'Cl',
'atom':'abun["Cl2"] + abun["Cl3"]',
'icf': '(1.) * elem_abun["DIMS14_12"] / abun["O2"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.13',
'up_error': '0.0'},
'DIMS14_32': {'elem': 'Cl',
'atom':'abun["Cl2"] + abun["Cl3"] + abun["Cl4"]',
'icf': '0.98 + (0.56 - 0.57 * abun["He3"] / (abun["He2"] + abun["He3"]))**7.64',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.30',
'up_error': '0.33'},
'DIMS14_35': {'elem': 'Ar',
'atom':'abun["Ar3"]',
'icf': '(10**(0.05 / (0.06 + abun["O3"] / (abun["O2"] + abun["O3"])) - 0.07)) * elem_abun["DIMS14_12"] / (abun["O2"] + abun["O3"])',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.70',
'up_error': '0.60'},
'DIMS14_36': {'elem': 'Ar',
'atom':'abun["Ar3"]',
'icf': '(10**((0.03 * abun["O3"] / (abun["O2"] + abun["O3"])) / (0.4 - 0.3 * abun["O3"] / (abun["O2"] + abun["O3"])) - 0.05)) * elem_abun["DIMS14_12"] / (abun["O2"] + abun["O3"])',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.70',
'up_error': '0.60'},
'DIMS14_39': {'elem': 'C',
'atom':'abun["C3"]',
'icf': '(0.05 + 2.21 * abun["O3"] / (abun["O2"] + abun["O3"]) - 2.77 * (abun["O3"] / (abun["O2"] + abun["O3"]))**2 + 1.74 * (abun["O3"] / (abun["O2"] + abun["O3"]))**3) * elem_abun["DIMS14_12"] / abun["O3"]',
'type': 'PNe',
'comment': 'Based on photoionization models',
'low_error': '0.19',
'up_error': '(0.4 - 1.06 * abun["O3"] / (abun["O2"] + abun["O3"]) + 0.65 * (abun["O3"] / (abun["O2"] + abun["O3"]))**2 + 0.27 * (abun["O3"] / (abun["O2"] + abun["O3"]))**3) '},
# To be completed
# 'Sal07_Kr1': {'elem': 'Kr',
# 'atom':'abun["Kr3"] + abun["Kr4"]',
# 'icf': 'elem_abun["DIMS14_12"]/(abun["Ar3"] + abun["ar4"])',
# 'type': 'PNe',
# 'comment': 'Based on photoionization models'},}
}
Ial06 = [('18a', 'N', 'N2', (-0.825, 0.718, 0.853), 'v', 'low Z'),
('18b', 'N', 'N2', (-0.809, 0.712, 0.852), 'v', 'int Z'),
('18c', 'N', 'N2', (-1.476, 1.752, 0.688), 'v', 'high Z'),
('19a', 'Ne', 'Ne3', (-0.385, 1.365, 0.022), 'w', 'low Z'),
('19b', 'Ne', 'Ne3', (-0.405, 1.382, 0.021), 'w', 'int Z'),
('19c', 'Ne', 'Ne3', (-0.591, 0.927, 0.546), 'w', 'high Z'),
('21a', 'Cl', 'Cl3', (0.756, 0.648, 0.022), 'v', 'low Z'),
('21b', 'Cl', 'Cl3', (0.814, 0.620, 0.128), 'v', 'int Z'),
('21c', 'Cl', 'Cl3', (1.186, 0.357, 0.131), 'v', 'high Z'),
('22a', 'Ar', 'Ar3', (0.278, 0.836, 0.121), 'v', 'low Z'),
('22b', 'Ar', 'Ar3', (0.285, 0.833, 0.051), 'v', 'int Z'),
('22c', 'Ar', 'Ar3', (0.517, 0.763, 0.042), 'v', 'high Z'),
('24a', 'Fe', 'Fe3', (0.036, -0.146, 1.386), 'v', 'low Z'),
('24b', 'Fe', 'Fe3', (0.301, -0.259, 1.367), 'v', 'int Z'),
('24c', 'Fe', 'Fe3', (-1.377, 1.606, 1.045), 'v', 'high Z'),
('20a', 'S', 'S2+S3', (0.121, 0.511, 0.161), 'v', 'low Z'),
('20b', 'S', 'S2+S3', (0.155, 0.849, 0.062), 'v', 'int Z'),
('20c', 'S', 'S2+S3', (0.178, 0.610, 0.153), 'v', 'high Z'),
('23a', 'Ar', 'Ar3+Ar4', (0.158, 0.958, 0.004), 'v', 'low Z'),
('23b', 'Ar', 'Ar3+Ar4', (0.104, 0.980, 0.001), 'v', 'int Z'),
('23c', 'Ar', 'Ar3+Ar4', (0.238, 0.931, 0.004), 'v', 'high Z')]
for item in Ial06:
key = 'Ial06_' + item[0]
atom = 'abun["' + item[2] + '"]'
icf = self._calcIal06(item[3], item[4])
self.all_icfs[key] = {'elem': item[1], 'atom': atom, 'icf': icf, 'type': 'HII', 'comment': item[5]}
# Quickest way to account for the special case of Eqs. 20 and 23
for key in ['Ial06_20a', 'Ial06_20b', 'Ial06_20c']:
self.all_icfs[key]['atom'] = '(abun["S2"] + abun["S3"])'
for key in ['Ial06_23a', 'Ial06_23b', 'Ial06_23c']:
self.all_icfs[key]['atom'] = '(abun["Ar3"] + abun["Ar4"])'
self.all_icf_refs = {'direct':{'ref': 'Direct determination by summing observed ions',
'url':''},
'TPP77': {'ref': 'Torres-Peimbert and Peimbert 1977, RMAA, 2, 181',
'url': 'http://adsabs.harvard.edu/abs/1977RMxAA...2..181T'},
'PHCD07': {'ref': 'Perez-Montero, Haegele, Contini, and Diaz 2007, MNRAS, 381, 125',
'url': 'http://adsabs.harvard.edu/abs/2007MNRAS.381..125P'},
'KB94': {'ref': 'Kinsburgh & Barlow 1994, MNRAS, 271, 257',
'url': 'http://adsabs.harvard.edu/abs/1994MNRAS.271..257K'},
'KH01': {'ref': 'Kwitter & Henry 2001, ApJ, 562, 804',
'url': 'http://adsabs.harvard.edu/abs/2001ApJ...562..804K'},
'ITL94': {'ref': 'Izotov, Thuan & Lipovetsky 1994, ApJ, 435, 647',
'url': 'http://http://adsabs.harvard.edu/abs/1994ApJ...435..647I'},
'Ial06': {'ref': 'Izotov et al 2006, A&A, 448, 955',
'url': 'http://adsabs.harvard.edu/abs/2006A%26A...448..955I'},
'PC69': {'ref': 'Peimbert & Costero 1969, BOTT, 5, 3',
'url': 'http://adsabs.harvard.edu/abs/1969BOTT....5....3P'},
'S78': {'ref': 'Stasinska 1978, A&A, 66, 257',
'url': 'http://adsabs.harvard.edu/abs/1978A%26A....66..257S'},
# Superseded by RR05
# 'RR04': {'ref': 'Rodriguez & Rubin 2004, IAUS, 217, 188',
# 'url': 'http://adsabs.harvard.edu/abs/2004IAUS..217..188R'},
'RR05': {'ref': 'Rodriguez & Rubin 2005, ApJ, 626, 900',
'url': 'http://adsabs.harvard.edu/abs/2005ApJ...626..900R'},
# Corrected with PTPR92
# 'GRal04': {'ref': 'Garcia-Rojas et al 2004, ApJS, 153, 501',
# 'url': 'http://adsabs.harvard.edu/abs/2004ApJS..153..501G'},
'GKA07': {'ref': 'Girard, Koeppen and Acker 2007, A&A, 463, 265',
'url': 'http://adsabs.harvard.edu/abs/2007A%26A...463..265G'},
'PTPR92': {'ref': 'Peimbert, Torres-Peimbert and Ruiz 1992, RMAA, 24, 155',
'url': 'http://adsabs.harvard.edu/abs/1992RMxAA..24..155P'},
'Sal07': {'ref': 'Sharpee et al 2007, MNRAS, 659, 1265',
'url': 'http://adsabs.harvard.edu/abs/2007ApJ...659.1265S'},
'DIMS14': {'ref': 'Delgado-Inglada, Morisset and Stasinska, 2014, MNRAS',
'url':'http://arxiv.org/abs/1402.4852'}
}
def _calcIal06(self, coeff, degree):
"""
Compute the analytical expressions of the Ial06 paper
"""
if degree == 'v':
k1 = 'abun["O2"] / (abun["O2"] + abun["O3"])'
k2 = '(abun["O2"] + abun["O3"]) / abun["O2"]'
else:
k1 = 'abun["O3"] / (abun["O2"] + abun["O3"])'
k2 = '(abun["O2"] + abun["O3"]) / abun["O3"]'
return '(' + str(coeff[0]) + ' * ' + k1 + ' + ' + str(coeff[1]) + ' + ' + str(coeff[2]) + ' * ' + k2 + ')'
def _getAtomExp(self, label):
"""
Clean the ionic factor expressions for display purposes
"""
return self.all_icfs[label]['atom'].replace('abun["', '').replace('"]', '')
def _getIcfExp(self, label):
"""
Clean the icf expressions for display purposes
"""
return self.all_icfs[label]['icf'].replace('elem_abun["', '').replace('abun["', '').replace('"]', '')
def getAvailableICFs(self, elem_list=ELEM_LIST, type_=['HII', 'PNe', 'All']):
"""
Get a list of all the available ICFs for the specified elements.
Details can be obtained by invoking getReference('label') and getExpression('label') or printAllICFs()
Parameters:
- elem_list selected element or list of selected elements (default: all PyNeb elements)
- type_ dbject class to which the icf is appliable (e.g. "PNe", "HII"; default: both)
Usage:
icf=pn.ICF()
icf.getAvailableICFs()
icf.getAvailableICFs('S')
icf.getAvailableICFs('S', type_='HII')
"""
if type(type_) == type(''):
type_ = [type_]
if elem_list.__class__ is str:
elem_list = [elem_list]
icf_dict = {}
for elem in elem_list:
# Each element is associated to an icf_list which holds all the icfs for that element
icf_list = []
for key in self.all_icfs.keys():
if (self.all_icfs[key]['elem'] == elem):
if self.all_icfs[key]['type'] in type_:
icf_list.append(key)
if len(icf_list) > 0:
icf_dict[elem] = icf_list
return icf_dict
def printAllICFs(self, type_=['HII', 'PNe', 'All']):
"""
Print a list of all the available ICFs. Details can be obtained by
invoking getReference('label') and getExpression('label')
Parameters:
- type_ object class to which the icf is appliable (e.g. "PNe", "HII"; default: both)
"""
if type(type_) == type(''):
type_ = [type_]
for label in self.all_icfs:
if self.all_icfs[label]['type'] in type_:
print(label + ': elem = ' + self.all_icfs[label]['elem'] + '; atom = ' +
self._getAtomExp(label) + '; type = ' + self.all_icfs[label]['type'])
def addICF(self, label, elem, atom, icf, type_='All', comment='', ref=None, url=None):
"""
Add a new icf
Parameters:
label: a label which identifies the new ICF. The suggested format for the label is "R_E.N",
where R is a reference to the paper, E to the equation in the paper and the optional
key N is an indication of the higher ion need to compute the icf.
elem: element whose abundance is computed
atom: ion or ions whose abundance is multiplied by the icf to get the elemenmt abundance
icf: the correcting expression
type_: object class to which the icf is appliable (e.g. "PNe", "HII")
comment: additional comment, relevant to icf usage
ref: bibliographic reference, if any
url: URL of the source paper, if any
**Usage:**
icf=pn.ICF()
icf.addICF(label='TEST_1',
elem='Ne',
atom ='abun["Ne2"] + abun["Ne3"]',
icf='(abun["O2"] + abun["O3"]) / abun["O2"]',
type_='PNe',
comment='',
ref='PyNeb international conference, 2025',
url='http://www.iac.es')
"""
if label in self.all_icfs:
pn.log_.warn('{0} is already an entry of the ICF label dictionary'.format(label), calling=self.calling)
return None
else:
self.all_icfs[label] = {'elem': elem,
'atom': atom,
'icf': icf,
'type': type_,
'comment': comment}
paper = label.split('_')[0]
self.all_icf_refs[paper] = {'ref': ref, 'url': url}
def delICF(self, label):
"""Delete an existing icf (only for current session)
Parameters:
label: the label which identifies the new ICF.
**Usage:**
icf=pn.ICF()
icf.delICF(label='TEST_1')
"""
del self.all_icfs[label]
def printInfo(self, label, filter='licores'):
"""
Return complete information on the required icf or paper
Parameters:
label (str): label of selected ICF recipe or paper
filter (str): string with initials of required fields (substring of 'licores'; all by default)
**Usage:**
icf=pn.ICF()
icf.printInfo('Ial06_20a')
"""
for item in self.all_icfs:
if (label in item):
print('------------------------------------------------------------------------')
if ('l' in filter): print('Label:', item)
if ('e' in filter): print('Element:', self.all_icfs[item]['elem'])
if ('r' in filter): print('Required ions:', self._getAtomExp(item))
if ('i' in filter): print('ICF expression:', self._getIcfExp(item))
if ('o' in filter): print('Object class:', self.all_icfs[item]['type'])
if ('c' in filter): print('Comments:', self.all_icfs[item]['comment'])
if ('s' in filter): print('Source:', self.getReference(item))
def getReference(self, label):
""" Return the reference of the selected ICF recipe
Parameters:
label (str): label of selected ICF recipe or paper
"""
paper = label.split('_')[0]
if paper[0] == 'm':
paper1 = paper.split('-')[0][1:]
paper2 = paper.split('-')[1]
mixed = self.all_icf_refs[paper1]['ref'] + ' using an abundance based on ' + self.all_icf_refs[paper2]['ref']
return mixed
else:
return self.all_icf_refs[paper]['ref']
def getURL(self, label):
""" Return the ADS URL of the selected ICF recipe
Parameters:
label (str): label of selected ICF recipe or paper
"""
paper = label.split('_')[0]
if paper[0] == 'm':
paper1 = paper.split('-')[0][1:]
paper2 = paper.split('-')[1]
mixed = self.all_icf_refs[paper1]['url'] + ' using an abundance based on ' + self.all_icf_refs[paper2]['url']
return mixed
else:
return self.all_icf_refs[paper]['url']
def getExpression(self, label):
"""
Return the analytical expression of the selected ICF
Parameters:
label(str) label of selected ICF expression
"""
elem = self.all_icfs[label]['elem']
atom = self._getAtomExp(label)
icf_factor = self._getIcfExp(label)
if icf_factor != '1':
return elem + " = (" + atom + ") * " + icf_factor
else:
return elem + " = " + atom
def getType(self, label):
"""
Return the kind of object for which the selected ICF is suitable.
Parameters:
label(str): label of selected ICF expression
"""
return self.all_icfs[label]['type']
def getComment(self, label):
"""
Return the comment associated to the selected ICF.
Parameters:
label(str): label of selected ICF expression
"""
return self.all_icfs[label]['comment']
def getElemAbundance(self, atom_abun, icf_list=[], icf_family=None, absentIon=np.nan, use_coll=True,
use_MC=False):
"""
Compute elemental abundances from ionic abundances. The complete iventory is printed through pn.ICF().printAllICFs().
See the ICF class for more details.
Store the result in ICF.elem_abund
Parameters:
atom_abun: a dictionary of ionic abundances
icf_list: a list of selected ICFs (default: all)
icf_family: a string common to all the icf one want to use, e.g. "DIMS14"
use_coll: In case both collision lines and recombination lines abundances exists:
if True (default), use collision line ionic abundance, if false use recombination ones
use_MC: If True and if the ICF definition includes error informations, the ICF will be multiplied
by some factor taking into account the error.
**Usage:**
atom_abun = {'O2': 0.001, 'O3': 0.002, 'Ne3': 1.2e-5}
getElemAbundance(atom_abun)
"""
if type(icf_list) == type(''):
icf_list = [icf_list]
# List of all existing atoms. Necessary to initialize the ionic abundance dictionary
if icf_family is not None:
icf_list = [icf for icf in self.all_icfs.keys() if icf_family in icf]
atom_list = list(pn.LINE_LABEL_LIST.keys())
for elem in ('He2', 'He3'):
if elem not in atom_list:
atom_list.append(elem)
# Initialize the ionic abundances so that the code does not crash when a specific abundance is invoked
# TODO : Check that the same ion is not present as collisional and recombination !!
abun = {}
for atom in atom_list:
# Set those abundances which are different from 0. These determine which ICFs can be computed
if atom in atom_abun:
if atom == 'He1r':
abun['He2'] = atom_abun[atom]
elif atom == 'He2r':
abun['He3'] = atom_abun[atom]
else:
abun[atom] = atom_abun[atom]
# if atom[-1] == 'r':
# elem, spec = parseAtom(atom[:-1])
# atomc = elem + str(int(spec)+1)
# if (not use_coll) or (atomc not in atom_abun):
# abun[atomc] = atom_abun[atom]
# print('1',atom, atomc)
# else:
# print('2',atom, atomc)
# else:
# elem, spec = parseAtom(atom)
# atomr = elem + str(int(spec)-1) + 'r'
# if use_coll or (atomr not in atom_abun):
# abun[atom] = atom_abun[atom]
# print('3',atom, atom)
# else:
# print('4',atom, atom)
else:
abun[atom] = absentIon
self.abun = abun
# Initialize the lists of elemental abundances
self.icf_value = {}
elem_abun = {}
# Compute either all the available ICFs or just a selected subset of them
if len(icf_list) == 0:
icf_list = self.all_icfs.keys()
do_one_more_pass = True
i_pass = 0
while (do_one_more_pass and (i_pass < self._max_pass)):
do_one_more_pass = False
i_pass += 1
for icf_label in icf_list:
atom = self.all_icfs[icf_label]['atom']
try:
atom_value = eval(atom)
except:
pn.log_.warn('Unable to eval {}'.format(atom), calling=self.calling + '.getElemAbundance')
if self.all_icfs[icf_label]['elem'] is not None:
pn.log_.debug('Doing {}'.format(icf_label), calling='ICF')
this_icf = self.all_icfs[icf_label]
elem = this_icf['elem']
try:
icf_value = eval(this_icf['icf'])
self.icf_value[icf_label] = icf_value
if use_MC and 'low_error' in this_icf:
try:
low_error = eval(this_icf['low_error'])
except:
pn.log_.warn('low error {0} cannot be evaluated for {1}'.format(this_icf['low_error'], icf_label))
try:
up_error = eval(this_icf['up_error'])
except:
pn.log_.warn('up error {0} cannot be evaluated for {1}'.format(this_icf['up_error'], icf_label))
try:
if np.size(low_error) == 1:
D_icf_MC = np.random.uniform(-low_error, up_error, np.size(atom_value))
else:
D_icf_MC = np.random.uniform(-low_error, up_error)
D_icf_MC[0] = 0.0
except:
pn.log_.warn('MC not working for ICF {}'.format(this_icf['icf']), calling=self.calling)
# print '--------IN---------'
# print this_icf['icf']
# print this_icf['low_error']
# print 'low_error'
# print low_error
# print this_icf['up_error']
# print 'up_error'
# print up_error
# if icf_label == 'DIMS14_36':
# print 'icf_MC for {}'.format(icf_label)
# print Dicf_MC
# print 'icf_value'
# print icf_value
icf_value = icf_value + D_icf_MC
pn.log_.message('Using MC for ICF {}'.format(icf_label))
# print 'icf_value2'
# print icf_value
# print '---------OUT---------'
elem_abun[icf_label] = atom_value * icf_value
except:
do_one_more_pass = True
if i_pass == self._max_pass:
pn.log_.warn('{0} cannot be evaluated for {1}'.format(this_icf['icf'], icf_label),
calling=self.calling)
else:
pn.log_.debug('{} not present'.format(icf_label), calling='ICF')
self.elem_abun = elem_abun
return self.elem_abun
# elem_abun[icf.all_icfs[icf_ref]['elem']] = np.log10(elem_abun_dic[icf_ref])+12
def __getElemAbundanceFromStategy(self, atom_abun, strategy):
"""
Return the elemental abundances in a dictionary, computed by applying a given strategy.
Parameters:
atom_abund: dictionary of ionic abundances
strategy: dictionary of the ICF to apply in order to obtain elemental abundances.
example: strategy = {'He':['direct_He.2', 'PTPR92_21'],
'N': 'KB94_A1.10'}
**Usage:**
final_abund = icf.getElemAbundanceFromStrategy(ion_ab_dic, icf_strategies)
"""
# the following is great, as it only computes the abundances from a subset, but
# it does not work when an ICF requires an ab undance not in the list!
icf_list = []
for elem in strategy:
if type(strategy[elem]) == type(''):
icf_list.append(strategy[elem])
else:
for meth in strategy[elem]:
icf_list.append(meth)
allAbund = self.getElemAbundance(atom_abun, icf_list, absentIon=np.nan)
elemAbund = {}
for elem in strategy:
if type(strategy[elem]) == type(''):
elemAbund[elem] = allAbund[strategy[elem]]
else:
elemAbund[elem] = allAbund[strategy[elem][0]]
for meth in strategy[elem][1::]:
tt = np.isnan(elemAbund[elem])
pn.log_.message('Computing {0} abundance using {1} for {2} observations.'.format(elem,
meth,
tt.sum()),
calling=self.calling)
elemAbund[elem][tt] = allAbund[meth][tt]
return elemAbund
def test(self):
"""
Test function for the ICF class
"""
label1 = 'Ial06_18a'
label2 = 'TPP77_14'
label3 = 'KH01_4b'
label4 = 'PHCD07_13'
print('All the available ICFs, listed by element:')
print(self.getAvailableICFs())
print('\nAll the available ICFs, with some detail:')
print(self.printAllICFs())
print('\nAll the available ICFs for S and Ne:' )
print(self.getAvailableICFs(['S', 'Ne']))
print('\nAnalytical expression for ' + label1 + ':')
print(self.getExpression(label1))
print('\nBibliographic reference for ' + label2 + ':')
print(self.getReference(label2))
print('\nURL for ' + label3 + ':')
print(self.getURL(label3))
print('\nType of object to which ' + label4 + ' can be applied:')
print(self.getType(label4))
print('\nAdditional details of ' + label4 + ':')
print(self.getComment(label4) )
atom_abun = {}
atom_abun['O2'] = 0.001
atom_abun['O3'] = 0.002
atom_abun['Ne2'] = 1.0e-4
atom_abun['Ne3'] = 1.2e-5
atom_abun['Ar3'] = 4.e-6
atom_abun['Ar4'] = 1.e-6
atom_abun['N2'] = 1.e-4
atom_abun['He2'] = 1.e-1
atom_abun['He3'] = 1.e-2
atom_abun['He2'] = 1.e-1
atom_abun['Cl3'] = 4.e-6
atom_abun['Cl4'] = 1.e-6
atom_abun['Ar3'] = 6.e-5
atom_abun['Ar4'] = 5.e-7
atom_abun['S3'] = 1.e-5
self.getElemAbundance(atom_abun, icf_list=[label4])
|