From bd91d19a16a3155ec4d9b7ca74d3e85d025005e6 Mon Sep 17 00:00:00 2001 From: Chun Ly Date: Wed, 3 Jun 2020 17:00:54 -0700 Subject: [PATCH 1/4] column_names: Fix bin_valid_rev definition (iss #13) --- Metallicity_Stack_Commons/column_names.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Metallicity_Stack_Commons/column_names.py b/Metallicity_Stack_Commons/column_names.py index 757cd2e..f191615 100644 --- a/Metallicity_Stack_Commons/column_names.py +++ b/Metallicity_Stack_Commons/column_names.py @@ -71,7 +71,6 @@ def line_fit_suffix_add(line_name0, line_type0): # Bin-related files filename_dict['bin_info'] = 'bin_info.tbl' filename_dict['bin_valid'] = 'bin_validation.tbl' -filename_dict['bin_valid_rev'] = 'bin_validation_revised.tbl' filename_dict['bin_valid_rev'] = filename_dict['bin_valid'].replace('.tbl', '.revised.tbl') filename_dict['bin_fit'] = 'bin_emission_line_fit.tbl' filename_dict['bin_fit_rev'] = filename_dict['bin_fit'].replace('.tbl', '.revised.tbl') From 9362e4b66fa5f4e587a2009d1a118d358e78d973 Mon Sep 17 00:00:00 2001 From: Chun Ly Date: Wed, 3 Jun 2020 17:02:01 -0700 Subject: [PATCH 2/4] valid_table: Use os.path.join (iss #13) --- Metallicity_Stack_Commons/valid_table.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Metallicity_Stack_Commons/valid_table.py b/Metallicity_Stack_Commons/valid_table.py index e13c062..fcdb9ea 100644 --- a/Metallicity_Stack_Commons/valid_table.py +++ b/Metallicity_Stack_Commons/valid_table.py @@ -1,5 +1,7 @@ # from os.path import exists import numpy as np +from os.path import join + from astropy.io import ascii as asc from astropy.table import Table, Column @@ -36,8 +38,8 @@ def make_validation_table(fitspath): OIII4363_S/N """ - bin_table = asc.read(fitspath + filename_dict['bin_info']) - em_table = asc.read(fitspath + filename_dict['bin_fit']) + bin_table = asc.read(join(fitspath, filename_dict['bin_info'])) + em_table = asc.read(join(fitspath, filename_dict['bin_fit'])) bin_ID = em_table['bin_ID'].data raw_OIII4363 = em_table['OIII_4363_Flux_Observed'].data @@ -115,7 +117,8 @@ def compare_to_by_eye(fitspath, dataset): Notes """ - ver_table = fitspath + filename_dict['bin_valid'] + + ver_table = join(fitspath, filename_dict['bin_valid']) ver_tab = asc.read(ver_table) indicate = ver_tab['Detection'] ID = ver_tab['bin_ID'] From ea4f63b6a6e1449d694b77069433f168d6ad15f9 Mon Sep 17 00:00:00 2001 From: Chun Ly Date: Wed, 3 Jun 2020 21:48:59 -0700 Subject: [PATCH 3/4] valid_table.compare_to_by_eye: Check if file exists (iss #10) --- Metallicity_Stack_Commons/valid_table.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Metallicity_Stack_Commons/valid_table.py b/Metallicity_Stack_Commons/valid_table.py index fcdb9ea..06b62b1 100644 --- a/Metallicity_Stack_Commons/valid_table.py +++ b/Metallicity_Stack_Commons/valid_table.py @@ -1,6 +1,6 @@ # from os.path import exists import numpy as np -from os.path import join +from os.path import join, exists from astropy.io import ascii as asc from astropy.table import Table, Column @@ -118,10 +118,14 @@ def compare_to_by_eye(fitspath, dataset): """ - ver_table = join(fitspath, filename_dict['bin_valid']) - ver_tab = asc.read(ver_table) - indicate = ver_tab['Detection'] - ID = ver_tab['bin_ID'] + valid_rev_file = join(fitspath, filename_dict['bin_valid_rev']) + if exists(valid_rev_file): + print("!!! Revised validation table exists. Not overwriting! : ", valid_rev_file) + else: + valid_file = join(fitspath, filename_dict['bin_valid']) + valid_tab = asc.read(valid_file) + indicate = valid_tab['Detection'] + ID = valid_tab['bin_ID'] # Detections By Eye if dataset == 'Voronoi20': From f12fd689aaaf0b1f0dfed9b2fd5fb50fce308965 Mon Sep 17 00:00:00 2001 From: Chun Ly Date: Wed, 3 Jun 2020 21:54:04 -0700 Subject: [PATCH 4/4] valid_table.compare_to_by_eye: Raise error; Strip out manual coding (iss #10) --- Metallicity_Stack_Commons/valid_table.py | 60 ++---------------------- 1 file changed, 5 insertions(+), 55 deletions(-) diff --git a/Metallicity_Stack_Commons/valid_table.py b/Metallicity_Stack_Commons/valid_table.py index 06b62b1..5a5fa21 100644 --- a/Metallicity_Stack_Commons/valid_table.py +++ b/Metallicity_Stack_Commons/valid_table.py @@ -121,65 +121,15 @@ def compare_to_by_eye(fitspath, dataset): valid_rev_file = join(fitspath, filename_dict['bin_valid_rev']) if exists(valid_rev_file): print("!!! Revised validation table exists. Not overwriting! : ", valid_rev_file) + raise FileExistsError else: valid_file = join(fitspath, filename_dict['bin_valid']) valid_tab = asc.read(valid_file) indicate = valid_tab['Detection'] ID = valid_tab['bin_ID'] - # Detections By Eye - if dataset == 'Voronoi20': - det_4363 = np.where((ID == 0) | (ID == 2) | (ID == 3) | (ID == 5) | (ID == 6))[0] - if dataset == 'Voronoi14': - det_4363 = np.where((ID == 0) | (ID == 7) | (ID == 10) | (ID == 11) | (ID == 12))[0] - if dataset == 'Voronoi10': - det_4363 = np.where((ID == 1) | (ID == 9) | (ID == 18) | (ID == 21))[0] - if dataset == 'Grid': - det_4363 = np.where((ID == 11) | (ID == 13) | (ID == 19) | (ID == 20) | (ID == 21))[0] - if dataset == 'R23_Grid': - det_4363 = np.where((ID == 0) | (ID == 4) | (ID == 5) | (ID == 6))[0] - if dataset == 'O32_Grid': - det_4363 = np.where((ID == 6))[0] - if dataset == 'Double_Bin': - det_4363 = np.where((ID == 0) | (ID == 1) | (ID == 2) | (ID == 7) | (ID == 9) | - (ID == 10) | (ID == 11) | (ID == 13))[0] - if dataset == 'n_Bins': - det_4363 = np.where((ID == 10) | (ID == 11) | (ID == 14) | (ID == 15) | (ID == 20) | - (ID == 23) | (ID == 26))[0] - rlimit = np.where((ID == 5) | (ID == 7) | (ID == 8) | (ID == 13) | (ID == 16) | - (ID == 17) | (ID == 19) | (ID == 22))[0] - - # Caroline: Add you conditions here - - check_ID = np.zeros(len(ID)) - - check_ID[det_4363] = 1 - if dataset == 'n_Bins': - check_ID[rlimit] = 0.5 - - for ii in range(len(ID)): - if check_ID[ii] == indicate[ii]: - print(ID[ii], 'matches with by eye validation') - else: - print('*****', ID[ii], 'does not match calculated values. Please check!') - - # This is where I need to add the column for notes - if dataset == 'n_Bins': - notes = ['N/A', 'N/A', 'N/A', 'N/A', 'N/A', - 'N/A', 'N/A', 'Broad features, but reliable OIII5007 and HGAMMA', - 'Bad fit, but good OIII5007', 'N/A', - 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', - 'High Temperature', 'not fit well, but reliable OIII5007 and HGAMMA', - 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A'] - note_add = Column(name='Notes', data=notes) - ver_tab.add_column(note_add, 5) - - # Caroline: Add your notes column here and copy the note_add and ver_tab.add_column lines to your if statement - - ver_tab.remove_column('Detection') - - detect_add = Column(name='Detection', data=check_ID) - ver_tab.add_column(detect_add, 2) + # Will need to provide a config file that contains the manual inspections + + # Will need to modify table Detection Column - asc.write(ver_tab, fitspath + filename_dict['bin_valid_rev'], format='fixed_width_two_line') - asc.write(ver_tab, fitspath + 'bin_validation_revised.csv', format='csv') + asc.write(valid_tab, valid_rev_file, format='fixed_width_two_line')