Skip to content

Commit

Permalink
analysis.composite_indv_detect.main: Rename det3_table to indv_em_lin…
Browse files Browse the repository at this point in the history
…e_table (iss #21)
  • Loading branch information
astrochun committed Mar 1, 2020
1 parent fddd7da commit ce87545
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Metallicity_Stack_Commons/analysis/composite_indv_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ def main(fitspath, dataset, composite_file, indv_em_line_file, indv_bin_file, ou
bin_temp = composite_table['T_e'].data

# Read in tables containing line ratios, bins, etc.
det3_table = asc.read(join(fitspath, indv_em_line_file))
indv_em_line_table = asc.read(join(fitspath, indv_em_line_file))
bin_table = asc.read(join(fitspath, dataset+indv_bin_file))
# Not used for now
# average_table = asc.read(join(fitspath, dataset+'_Average_R23_O32_Values.tbl'))

# Populate composite temperature for individual galaxies
adopted_temp = np.zeros(len(det3_table))
adopted_temp = np.zeros(len(indv_em_line_table))
for comp_bin, comp_temp in zip(bin_id, bin_temp):
bin_idx = np.where(bin_table['bin_ID'].data == comp_bin)[0]
adopted_temp[bin_idx] = comp_temp

O2 = det3_table['OII_3727_Flux_Observed'].data # [OII]3726,3728 fluxes
O3 = det3_table['OIII_5007_Flux_Observed'].data * OIII_r # [OIII]4959,5007 fluxes (Assume 3.1:1 ratio)
Hb = det3_table['HBETA_Flux_Observed'].data # H-beta fluxes
O2 = indv_em_line_table['OII_3727_Flux_Observed'].data # [OII]3726,3728 fluxes
O3 = indv_em_line_table['OIII_5007_Flux_Observed'].data * OIII_r # [OIII]4959,5007 fluxes (Assume 3.1:1 ratio)
Hb = indv_em_line_table['HBETA_Flux_Observed'].data # H-beta fluxes

if det3:
com_O_log, metal_dict = metallicity_calculation(adopted_temp, O2/Hb, O3/Hb)
Expand All @@ -63,18 +63,18 @@ def main(fitspath, dataset, composite_file, indv_em_line_file, indv_bin_file, ou
temp_com_O_log, temp_metal_dict = \
metallicity_calculation(adopted_temp[det3], O2[det3]/Hb[det3],
O3[det3]/Hb[det3])
com_O_log = np.zeros(len(det3_table))
com_O_log = np.zeros(len(indv_em_line_table))
com_O_log[det3] = temp_com_O_log

# Update [det3_table] to include two new columns
col_temp = Column(adopted_temp, name='T_e')
col_metal = Column(com_O_log, name='12+log(O/H)')
det3_table.add_columns([col_temp, col_metal]) # Add at the end (default)
indv_em_line_table.add_columns([col_temp, col_metal]) # Add at the end (default)

# Write Astropy ASCII table containing composite T_e and derived metallicity

if exists(outfile):
print("File exists! Overwriting : ", outfile)
else:
print("Writing : ", outfile)
det3_table.write(outfile, overwrite=True, format='ascii.fixed_width_two_line')
indv_em_line_table.write(outfile, overwrite=True, format='ascii.fixed_width_two_line')

0 comments on commit ce87545

Please sign in to comment.