Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reagen committed Apr 27, 2021
2 parents 503bd52 + ecf1abe commit 67c4c6b
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions Metallicity_Stack_Commons/valid_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from astropy.io import ascii as asc
from astropy.table import Table, Column

from .column_names import filename_dict, valid_table_names0 # , bin_names0, remove_from_list
from .column_names import filename_dict, valid_table_names0


def make_validation_table(fitspath: str):
def make_validation_table(fitspath: str, vmin_4363SN=3, vmin_5007SN=100,
vmax_4363sig=1.6, rlmin_4363SN=3,
rlmax_4363sig=1.6, rlmin_5007SN=100):
"""
This function creates a validation table for a given binning set.
The validation table contains a OIII4363 detection column where 1.0
Expand All @@ -20,6 +22,12 @@ def make_validation_table(fitspath: str):
:param fitspath: Full file path where the input file is and where the
output file will be placed.
:param vmin_4363SN: int. minimum OIII4363 S/N for valid detection
:param vmin_5007SN: int. minimum OIII5007 S/N for valid detection
:param vmax_4363sig: int. maximum OIII4363 sigma for valid detection
:param rlmin_4363SN: int. minimum OIII4363 S/N for robust limit
:param rlmax_4363sig: int. maximum OIII4363 sigma for robust limit
:param rlmin_5007SN: int. minimum OIII5007 S/N for robust limit
Outputs:
fitspath + 'bin_validation.tbl'
Expand All @@ -45,12 +53,17 @@ def make_validation_table(fitspath: str):
OIII4363 = np.zeros(len(bin_ID))
up_limit = (Hgamma/Hgamma_SN) * 3

valid_stacks_idx = np.where((O_4363_SN >= 3) & (O_5007_SN > 100) & (O_4363_sigma < 1.6))[0]
reliable_5007_stacks = np.where((O_4363_SN < 3) & (O_5007_SN > 100))[0]
wide_lines_valid = np.where((O_4363_SN >= 3) & (O_5007_SN > 100) & (O_4363_sigma >= 1.6))[0]
detection[valid_stacks_idx] = 1
valid_stacks_idx = np.where((O_4363_SN >= vmin_4363SN) &
(O_5007_SN > vmin_5007SN) &
(O_4363_sigma < vmax_4363sig))[0]
reliable_5007_stacks = np.where((O_4363_sigma < rlmax_4363sig) &
(O_5007_SN > rlmin_5007SN))[0]
wide_line_valid = np.where((O_4363_SN >= rlmin_4363SN) &
(O_5007_SN > rlmin_5007SN) &
(O_4363_sigma >= rlmax_4363sig))[0]
detection[reliable_5007_stacks] = 0.5
detection[wide_lines_valid] = 0.5
detection[wide_line_valid] = 0.5
detection[valid_stacks_idx] = 1
print(detection)

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

ver_tab = fitspath + filename_dict['bin_valid']
tab1 = Table([bin_ID, N_stack, detection, OIII4363, O_4363_SN], names=valid_table_names0)
tab1 = Table([bin_ID, N_stack, detection, OIII4363, O_4363_SN],
names=valid_table_names0)
asc.write(tab1, ver_tab, format='fixed_width_two_line')
'''
# Write revised file for human editing
ver_tab_revised = fitspath + filename_dict['bin_valid_rev']
if not exists(ver_tab_revised):
asc.write(tab1, ver_tab_revised, format='fixed_width_two_line')
print(" ")
print("URGENT!!! HUMAN EDITING OF FILE NEEDED : "+ver_tab_revised)
print(" ")
else:
print(" ")
print("ERROR!!! FILE EXISTS!!! WILL NOT OVERWRITE !!!")
print("ERROR!!! PLEASE RENAME/DELETE FILE TO REGENERATE !!!")
print(" ")
'''


def compare_to_by_eye(fitspath: str, dataset: str):
Expand Down Expand Up @@ -130,14 +130,14 @@ def compare_to_by_eye(fitspath: str, dataset: str):
np.where(
(ID == 0) | (ID == 1) | (ID == 2) | (ID == 7) | (ID == 9) |
(ID == 10) | (ID == 11) | (ID == 13))[0]
if dataset == 'n_Bins':
# make_validation_table will now produce correct detection values
'''if dataset == 'n_Bins':
det_4363 = np.where(
(ID == 10) | (ID == 14) | (ID == 15) | (ID == 20) |
(ID == 23) | (ID == 26))[0]
rlimit = \
np.where(
(ID == 5) | (ID == 7) | (ID == 8) | (ID == 11) | (ID == 13)
| (ID == 16) | (ID == 17) | (ID == 19) | (ID == 22))[0]
np.where((ID == 8) | (ID == 11) | (ID == 13)| (ID == 16)
| (ID == 17) | (ID == 19) | (ID == 22))[0]'''

# Caroline: Add you conditions here

Expand Down

0 comments on commit 67c4c6b

Please sign in to comment.