Skip to content

Commit 67c4c6b

Browse files
committed
Merge branch 'hotfix/v1.4.5'
2 parents 503bd52 + ecf1abe commit 67c4c6b

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

Metallicity_Stack_Commons/valid_table.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from astropy.io import ascii as asc
44
from astropy.table import Table, Column
55

6-
from .column_names import filename_dict, valid_table_names0 # , bin_names0, remove_from_list
6+
from .column_names import filename_dict, valid_table_names0
77

88

9-
def make_validation_table(fitspath: str):
9+
def make_validation_table(fitspath: str, vmin_4363SN=3, vmin_5007SN=100,
10+
vmax_4363sig=1.6, rlmin_4363SN=3,
11+
rlmax_4363sig=1.6, rlmin_5007SN=100):
1012
"""
1113
This function creates a validation table for a given binning set.
1214
The validation table contains a OIII4363 detection column where 1.0
@@ -20,6 +22,12 @@ def make_validation_table(fitspath: str):
2022
2123
:param fitspath: Full file path where the input file is and where the
2224
output file will be placed.
25+
:param vmin_4363SN: int. minimum OIII4363 S/N for valid detection
26+
:param vmin_5007SN: int. minimum OIII5007 S/N for valid detection
27+
:param vmax_4363sig: int. maximum OIII4363 sigma for valid detection
28+
:param rlmin_4363SN: int. minimum OIII4363 S/N for robust limit
29+
:param rlmax_4363sig: int. maximum OIII4363 sigma for robust limit
30+
:param rlmin_5007SN: int. minimum OIII5007 S/N for robust limit
2331
2432
Outputs:
2533
fitspath + 'bin_validation.tbl'
@@ -45,12 +53,17 @@ def make_validation_table(fitspath: str):
4553
OIII4363 = np.zeros(len(bin_ID))
4654
up_limit = (Hgamma/Hgamma_SN) * 3
4755

48-
valid_stacks_idx = np.where((O_4363_SN >= 3) & (O_5007_SN > 100) & (O_4363_sigma < 1.6))[0]
49-
reliable_5007_stacks = np.where((O_4363_SN < 3) & (O_5007_SN > 100))[0]
50-
wide_lines_valid = np.where((O_4363_SN >= 3) & (O_5007_SN > 100) & (O_4363_sigma >= 1.6))[0]
51-
detection[valid_stacks_idx] = 1
56+
valid_stacks_idx = np.where((O_4363_SN >= vmin_4363SN) &
57+
(O_5007_SN > vmin_5007SN) &
58+
(O_4363_sigma < vmax_4363sig))[0]
59+
reliable_5007_stacks = np.where((O_4363_sigma < rlmax_4363sig) &
60+
(O_5007_SN > rlmin_5007SN))[0]
61+
wide_line_valid = np.where((O_4363_SN >= rlmin_4363SN) &
62+
(O_5007_SN > rlmin_5007SN) &
63+
(O_4363_sigma >= rlmax_4363sig))[0]
5264
detection[reliable_5007_stacks] = 0.5
53-
detection[wide_lines_valid] = 0.5
65+
detection[wide_line_valid] = 0.5
66+
detection[valid_stacks_idx] = 1
5467
print(detection)
5568

5669
for ii in range(len(OIII4363)):
@@ -62,22 +75,9 @@ def make_validation_table(fitspath: str):
6275
OIII4363[ii] = up_limit[ii]
6376

6477
ver_tab = fitspath + filename_dict['bin_valid']
65-
tab1 = Table([bin_ID, N_stack, detection, OIII4363, O_4363_SN], names=valid_table_names0)
78+
tab1 = Table([bin_ID, N_stack, detection, OIII4363, O_4363_SN],
79+
names=valid_table_names0)
6680
asc.write(tab1, ver_tab, format='fixed_width_two_line')
67-
'''
68-
# Write revised file for human editing
69-
ver_tab_revised = fitspath + filename_dict['bin_valid_rev']
70-
if not exists(ver_tab_revised):
71-
asc.write(tab1, ver_tab_revised, format='fixed_width_two_line')
72-
print(" ")
73-
print("URGENT!!! HUMAN EDITING OF FILE NEEDED : "+ver_tab_revised)
74-
print(" ")
75-
else:
76-
print(" ")
77-
print("ERROR!!! FILE EXISTS!!! WILL NOT OVERWRITE !!!")
78-
print("ERROR!!! PLEASE RENAME/DELETE FILE TO REGENERATE !!!")
79-
print(" ")
80-
'''
8181

8282

8383
def compare_to_by_eye(fitspath: str, dataset: str):
@@ -130,14 +130,14 @@ def compare_to_by_eye(fitspath: str, dataset: str):
130130
np.where(
131131
(ID == 0) | (ID == 1) | (ID == 2) | (ID == 7) | (ID == 9) |
132132
(ID == 10) | (ID == 11) | (ID == 13))[0]
133-
if dataset == 'n_Bins':
133+
# make_validation_table will now produce correct detection values
134+
'''if dataset == 'n_Bins':
134135
det_4363 = np.where(
135136
(ID == 10) | (ID == 14) | (ID == 15) | (ID == 20) |
136137
(ID == 23) | (ID == 26))[0]
137138
rlimit = \
138-
np.where(
139-
(ID == 5) | (ID == 7) | (ID == 8) | (ID == 11) | (ID == 13)
140-
| (ID == 16) | (ID == 17) | (ID == 19) | (ID == 22))[0]
139+
np.where((ID == 8) | (ID == 11) | (ID == 13)| (ID == 16)
140+
| (ID == 17) | (ID == 19) | (ID == 22))[0]'''
141141

142142
# Caroline: Add you conditions here
143143

0 commit comments

Comments
 (0)