Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.5' (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed Jul 24, 2020
2 parents 80d1c03 + 9429667 commit 264a6c6
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions Metallicity_Stack_Commons/analysis/ratios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,40 @@

from .. import line_name_short, OIII_r
from .temp_metallicity_calc import R_calculation
from ..column_names import bin_ratios0, indv_names0


def flux_ratios(flux_dict, EBV=None, get_R=True):
def flux_ratios(flux_dict, flux_type='individual', EBV=None, get_R=True):
"""
Purpose:
Primary code to determine a variety of line ratios based on a dictionary
containing emission-line fluxes
:param flux_dict: dictionary containing line ratios
:param flux_type: str describing input type. Either 'composite' or 'individual'
:param EBV: array of E(B-V). Same dimensions as contents of flux_dict
:param get_R: Boolean to indicate whether to get OIII4363/OIII5007 flux ratio for temp calculation
:return flux_ratios_dict: dictionary containing flux ratios
"""

if flux_type not in ['composite', 'individual']:
print("Incorrect [flux_type]")
raise ValueError

two_beta_key = indv_names0[5]
three_beta_key = indv_names0[6]
logR23_key = indv_names0[1]
logO32_key = indv_names0[2]
R_key = indv_names0[7]

if flux_type == 'composite':
two_beta_key = bin_ratios0[2]
three_beta_key = bin_ratios0[3]
logR23_key = bin_ratios0[0]
logO32_key = bin_ratios0[1]
R_key = bin_ratios0[4]

# Retrieve emission line fluxes
OII = flux_dict[line_name_short['OII']]
OIII = flux_dict[line_name_short['OIII']]
Expand All @@ -32,16 +51,17 @@ def flux_ratios(flux_dict, EBV=None, get_R=True):

# Define dictionary of flux ratios
flux_ratios_dict = dict()
flux_ratios_dict['two_beta'] = two_beta
flux_ratios_dict['three_beta'] = three_beta
flux_ratios_dict['logR23'] = logR23
flux_ratios_dict['logO32'] = logO32

flux_ratios_dict[two_beta_key] = two_beta
flux_ratios_dict[three_beta_key] = three_beta
flux_ratios_dict[logR23_key] = logR23
flux_ratios_dict[logO32_key] = logO32

if EBV is None:
print("Not applying dust attenuation correction")
EBV = np.zeros(OIII.shape)

if get_R:
flux_ratios_dict['R'] = R_calculation(OIII4363, OIII, EBV)
flux_ratios_dict[R_key] = R_calculation(OIII4363, OIII, EBV)

return flux_ratios_dict

0 comments on commit 264a6c6

Please sign in to comment.