1+ from logging import Logger
2+ from typing import Union , Tuple
3+
14import numpy as np
25
36from .. import k_dict , line_name_short
1922k_HDELTA = k_dict [HD ]
2023
2124
22- def compute_EBV (ratio , source = 'HgHb' , zero_neg = True , verbose = False , log = None ):
23- """
24- Purpose:
25- Determines E(B-V) from Hg/Hb or Hd/Hb flux ratios using Case B assumptions
26-
27- :param ratio: float or numpy array containing Hg/Hb or Hd/Hb
28- :param source: str indicate ratio type. Either 'HgHb' or 'HdHb'. Default: 'HgHb'
29- :param zero_neg: boolean to indicate whether to zero out negative reddening. Default: True
30- :param verbose: bool to write verbose message to stdout. Default: file only
31- :param log: LogClass or logging object
32-
33- :return EBV: float or numpy array containing E(B-V).
34- Note: Not correcting for negative reddening
35- :return EBV_peak: float or numpy array return when it is a 2-D distribution
25+ def compute_EBV (ratio : Union [float , np .ndarray ], source : str = 'HgHb' ,
26+ zero_neg : bool = True , verbose : bool = False ,
27+ log : Logger = log_stdout ()) -> \
28+ Union [float , np .ndarray , Tuple [np .ndarray , np .ndarray ]]:
3629 """
30+ Determines E(B-V) from Hg/Hb or Hd/Hb flux ratios using Case B assumptions
31+
32+ :param ratio: Float or array containing Hg/Hb or Hd/Hb values
33+ :param source: Indicate ratio type. Either 'HgHb' or 'HdHb'.
34+ Default: 'HgHb'
35+ :param zero_neg: Indicate whether to zero out negative reddening.
36+ Default: True
37+ :param verbose: Write verbose message to stdout. Default: file only
38+ :param log: logging.Logger object
3739
38- if log is None :
39- log = log_stdout ()
40+ :return: E(B-V) values, E(B-V) peak values
41+
42+ Note:
43+ When only E(B-V) values is returned, correction does not account
44+ for negative reddening
45+ """
4046
4147 log_verbose (log , "starting ..." , verbose = verbose )
4248
@@ -87,42 +93,56 @@ def compute_EBV(ratio, source='HgHb', zero_neg=True, verbose=False, log=None):
8793 return EBV
8894
8995
90- def compute_A (EBV , verbose = False , log = None ):
96+ def compute_A (EBV : float , verbose : bool = False ,
97+ log : Logger = log_stdout ()) -> dict :
9198 """
92- Purpose:
93- Compute A(Lambda) for all possible emission lines
99+ Compute A(Lambda) for all possible emission lines
94100
95- :param EBV: float value of E(B-V)
96- Has not been configured to handle a large array. Some array handling would be needed
97- :param verbose: bool to write verbose message to stdout. Default: file only
98- :param log: LogClass or logging object
101+ :param EBV: E(B-V) value
102+ Has not been configured to handle a large array.
103+ Some array handling would be needed
99104
100- :return A_dict: dict containing A(lambda) with keys identical to k_dict
101- """
105+ :param verbose: Write verbose message to stdout.
106+ Default: file only
107+ :param log: logging.Logger object
102108
103- if log is None :
104- log = log_stdout ()
109+ :return: A(lambda) with keys identical to ``k_dict``
110+ """
105111
106112 log_verbose (log , "starting ..." , verbose = verbose )
107113
108- k_arr = np .array (list (k_dict .values ()))
114+ k_arr = np .array (list (k_dict .values ()))
109115
110- A_arr = k_arr * EBV
116+ A_arr = k_arr * EBV
111117 A_dict = dict (zip (list (k_dict .keys ()), A_arr ))
112118
113119 log_verbose (log , "finished." , verbose = verbose )
114120 return A_dict
115121
116122
117- def line_ratio_atten (ratio , EBV , wave_top , wave_bottom , verbose = False ,
118- log = None ):
123+ def line_ratio_atten (ratio : Union [float , np .ndarray ],
124+ EBV : Union [float , np .ndarray ],
125+ wave_top : str , wave_bottom : str ,
126+ verbose : bool = False ,
127+ log : Logger = log_stdout ()) -> \
128+ Union [float , np .ndarray ]:
129+ """
130+ Determine dust-corrected emission-line ratios
119131
120- if log is None :
121- log = log_stdout ()
132+ :param ratio: Float or array of observed flux ratios
133+ :param EBV: E(B-V) value(s)
134+ :param wave_top: Emission-line name for flux ratio numerator
135+ :param wave_bottom: Emission-line name for flux ratio denominator
136+ :param verbose: Write verbose message to stdout.
137+ Default: file only
138+ :param log: logging.Logger object
139+
140+ :return: Float or array of dust-corrected flux ratios
141+ """
122142
123143 log_verbose (log , "starting ..." , verbose = verbose )
124144
125- k_top = k_dict [wave_top ]
145+ k_top = k_dict [wave_top ]
126146 k_bottom = k_dict [wave_bottom ]
127147
128148 ratio_atten = ratio * 10 ** (0.4 * EBV * (k_top - k_bottom ))
@@ -131,28 +151,26 @@ def line_ratio_atten(ratio, EBV, wave_top, wave_bottom, verbose=False,
131151 return ratio_atten
132152
133153
134- def Hb_SFR (log_LHb , EBV , verbose = False , log = None ):
154+ def Hb_SFR (log_LHb : Union [float , np .ndarray ],
155+ EBV : Union [float , np .ndarray ],
156+ verbose : bool = False ,
157+ log : Logger = log_stdout ()) -> \
158+ Union [float , np .ndarray ]:
135159 """
136- Purpose:
137- Determine dust-corrected SFR using the H-beta luminosity and a
138- measurement for nebular attenuation
160+ Determine dust-corrected SFR using the H-beta luminosity and a
161+ measurement for nebular attenuation
139162
140163 Equation below is based on Eq. 2 in Ly et al. (2015), ApJ, 805, 45
141164 DOI: https://doi.org/10.1088/0004-637X/805/1/45
142165
143- :param log_LHb: numpy array or float containing logarithm of H-beta
144- luminosity in units of erg/s
145- :param EBV: numpy array or float providing E(B-V)
146- :param verbose: bool to write verbose message to stdout. Default: file only
147- :param log: LogClass or logging object
166+ :param log_LHb: Logarithm of H-beta luminosity in units of erg/s
167+ :param EBV: E(B-V) value(s)
168+ :param verbose: Write verbose message to stdout. Default: file only
169+ :param log: logging.Logger object
148170
149- :return logSFR: numpy array or float containing the SFR in
150- logarithmic units of M_sun/yr
171+ :return: SFRs in logarithmic units of M_sun/yr
151172 """
152173
153- if log is None :
154- log = log_stdout ()
155-
156174 log_verbose (log , "starting ..." , verbose = verbose )
157175
158176 logSFR = np .log10 (4.4e-42 * HaHb_CaseB ) + 0.4 * EBV * k_HBETA + log_LHb
0 commit comments