Skip to content

Commit

Permalink
Merge branch 'hotfix/0.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed Apr 7, 2020
2 parents b90b266 + 0f524fc commit f7bcd49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
22 changes: 7 additions & 15 deletions Metallicity_Stack_Commons/analysis/composite_indv_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,20 @@ def main(fitspath, dataset, revised=False, det3=True):

O2 = indv_em_line_table['OII_3727_Flux_Gaussian'].data # [OII]3726,3728 fluxes
O3 = indv_em_line_table['OIII_5007_Flux_Gaussian'].data # [OIII]5007 fluxes
O3 = O3 * (1+1/OIII_r) #Scale to include OIII4959; Assume 3.1:1 ratio
O3 = O3 * (1+1/OIII_r) # Scale to include OIII4959; Assume 3.1:1 ratio
Hb = indv_em_line_table['HBETA_Flux_Gaussian'].data # H-beta fluxes

if not det3:
com_O_log, metal_dict = metallicity_calculation(adopted_temp, O2/Hb, O3/Hb)
metal_dict = metallicity_calculation(adopted_temp, O2/Hb, O3/Hb)
else:
det3 = np.where((detect_indv == 1.0) | (detect_indv == 0.5))[0]
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(indv_em_line_table))
com_O_log[det3] = temp_com_O_log

metal_dict = dict()
for key0 in temp_metal_dict.keys():
metal_dict[key0] = np.zeros(len(indv_em_line_table))
metal_dict[key0][det3] = temp_metal_dict[key0]
det3_idx = np.where((detect_indv == 1.0) | (detect_indv == 0.5))[0]
metal_dict = \
metallicity_calculation(adopted_temp, O2/Hb, O3/Hb, det3=det3_idx)

# Define [indv_derived_prop_table] to include ID, bin_ID, composite T_e,
# and 12+log(O/H)
arr0 = [indv_em_line_table[ID_name], bin_id_indv, adopted_temp, com_O_log]
names0 = [ID_name, bin_ID_name] + temp_metal_names0[:2]
arr0 = [indv_em_line_table[ID_name], bin_id_indv, adopted_temp]
names0 = [ID_name, bin_ID_name, temp_metal_names0[0]]

# Include other metallicities
arr0 += list(metal_dict.values())
Expand Down
28 changes: 20 additions & 8 deletions Metallicity_Stack_Commons/temp_metallicity_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def temp_calculation(R):
return T_e


def metallicity_calculation(T_e, TWO_BETA, THREE_BETA):
def metallicity_calculation(T_e, TWO_BETA, THREE_BETA, det3=None):
"""
Determines 12+log(O/H) from electron temperature and [OII]/Hb and [OIII]/Hb flux ratio
Expand All @@ -59,15 +59,27 @@ def metallicity_calculation(T_e, TWO_BETA, THREE_BETA):
:return metal_dict: dictionary containing 12+log(O/H), O+/H, O++/H, log(O+/H), log(O++/H)
"""

t_3 = T_e * 1e-4
t_2 = 0.7 * t_3 + 0.17
x2 = 1e-4 * 1e3 * t_2 ** (-0.5)
n_sample = len(T_e)
t_3 = np.zeros(n_sample)
t_2 = np.zeros(n_sample)
x2 = np.zeros(n_sample)

if det3 is None:
det3 = np.arange(n_sample)

t_3[det3] = T_e[det3] * 1e-4
t_2[det3] = 0.7 * t_3[det3] + 0.17
x2[det3] = 1e-4 * 1e3 * t_2[det3] ** (-0.5)

O_s_ion_log = np.zeros(n_sample)
O_d_ion_log = np.zeros(n_sample)

# Equations from Izotov et al. (2006)
O_s_ion_log = np.log10(TWO_BETA) + 5.961 + 1.676 / t_2 - 0.4 * np.log10(t_2) \
- 0.034 * t_2 + np.log10(1 + 1.35 * x2) - 12
O_d_ion_log = np.log10(THREE_BETA) + 6.200 + 1.251 / t_3 \
- 0.55 * np.log10(t_3) - 0.014 * (t_3) - 12
O_s_ion_log[det3] = np.log10(TWO_BETA[det3]) + 5.961 + 1.676 / t_2[det3] \
- 0.4 * np.log10(t_2[det3]) - 0.034 * t_2[det3] + \
np.log10(1 + 1.35 * x2[det3]) - 12
O_d_ion_log[det3] = np.log10(THREE_BETA[det3]) + 6.200 + 1.251 / t_3[det3] \
- 0.55 * np.log10(t_3[det3]) - 0.014 * (t_3[det3]) - 12

O_s_ion = 10 ** O_s_ion_log
O_d_ion = 10 ** O_d_ion_log
Expand Down

0 comments on commit f7bcd49

Please sign in to comment.