Skip to content
Sophia Flury edited this page Jan 25, 2024 · 1 revision

redneb module

dependencies:

numpy 1.17.3 pyneb 1.1.10 scipy 1.4.1 pandas 1.2.1

note:

pandas dependency for dered_iter only

author:

Sophia Flury 2022.02.15

balmer_red

redneb.balmer_red(waves, f_intr, ew, ebmv, star_abs, ext_law='ccm89', j=0)

Function to artificially redden intrinsic Balmer decrements and introduce stellar absorption effects. Used by calc_ebmv_from_balmer to fit intrinsic decrements obtained from temperatures and densities to observed decrements.

Model is

f_obs/f_obs,H-beta = f_intr/f_intr,Hbeta * (EW_obs + EW_abs)/(EW_obs) * (EW_obs,Hbeta)/(EW_obs,Hbeta + EW_abs) * 10**( -0.4*E[B-V]*(k_H-k_Hbeta) )

calc_ebmv_from_balmer

redneb.calc_ebmv_from_balmer(wave, flux, flux_err=None, temp=10000.0, dens=100.0, ext_law='ccm89')
Name

calc_ebmv_from_balmer

Purpose

Calculate E(B-V) for a desired extinction using Balmer line fluxes alpha, beta, gamma, and delta. Computes recombination coefficients and extinction coefficients to populate a NxN matrix containing E(B-V) values from all N available Balmer fluxes. Rows and columns organized as below by the pair of lines used to compute E(B-V) where the ith row is the numerator and the jth column is the denominator (although this does not matter since the flux ratio cancels the sign). Diagonal elements set to nan since a single line yields no selective extinction. Example matrix if Ha, Hb, Hy, and Hd fluxes provided to the script:

   Ha  Hb  Hy  Hd
Ha --
Hb     --
Hy         --
Hd             --

Returns the upper diagonal elements of this matrix, ordered row by row.

Arguments
wave (np.ndarray):

1xN array of the Balmer line wavelengths

flux (np.ndarray):

1xN array of the Balmer line fluxes

Keyword Arguments
tem (float):

Balmer electron temperature in K. Default is 10^4 K.

den (float):

Balmer electron density in cm^-3. Default is 10^2 cm^-3.

ext_law (str):

String containing the name of the extinction law. Currently supports ‘ccm89’, ‘calzetti’,’smc’, and ‘fitz99’. Default is ‘ccm89’.

Returns
eBmV (np.ndarray):

a 1xC array of E(B-V) values derived from the observed Balmer flux ratios using Case B recombination coefficients and an assumed extinction law. When flux is not reported or computed E(B-V) is negative, E(B-V) is set to zero. C is given by the number of combinations of flux ratios without duplicates such that C=1/2 N!/(N-2)! for n emission line fluxes.

dered_iter

redneb.dered_iter(flux0, eqwd, ext_law='ccm89', abs_corr=False, verbose=True)
Name

dered_iter

Purpose

Compute E(B-V) from Balmer lines using the temperature and density computed from the emission lines to determine the intrinsic Balmer decrement. Fluxes are corrected for inferred, error-weighted E(B-V) value, temp and dens are recomputed from corrected lines, and process is iteratively repeated until converging on a consistent solution for E(B-V).

Arguments
flux0 (pd.DataFrame):

single-row pandas dataframe with emission line fluxes anderrors in columns labeled in PyNeb fashion: ElemSpec_waveA and ElemSpec_waveAe. Recombination lines require additional r after the species number. E.g., for H-alpha, H1r_6563A for flux and H1r_6563Ae for error and for [O III]5007, O3_5007A for flux and O3_5007Ae for error. Fluxes are assumed to have been corrected for MilkyWay extinction prior to passing to dered_iter.

eqwd (pd.DataFrame):

single-row pandas dataframe with emission line fluxes and errors in columns labeled as flux0.

Keyword Arguments
ext_law (str):

string indicating the extinction law to use. Currently supports ‘ccm89’, ‘calzetti’,’smc’, and ‘fitz99’. Default is ‘ccm89’.

abs_corr (bool):

boolean indicating whether to include stellar absorption correction in the E(B-V) estimate. If True, will use scipy.optimize.curve_fit to fit the intrinsic ratios to the observed ratios of Balmer fluxes assuming

f_obs/f_obs,Hb = f_0/f_0,Hb*10^(-0.4*E[B-V]*(k-k_Hb))

(ew+ew_abs)/ew*ew_Hb/(ew_Hb+ew_abs)

If False, will calculate the E(B-V) for all possible Balmer flux ratio permutations assuming

f_obs1/f_obs2 = f_0,1/f_0,2*10^(-0.4*E[B-V]*(k_1-k_2))

and take the error-weighted average to be the characteristic extinction. Default is False.

verbose (bool):

boolean indicating whether to print used Balmer lines, observed fluxes (normalized to H-beta), corrected fluxes (normalized to H-beta), and characteristic E(B-V) and stellar absorption correction.

Returns
ebmv (float):

variance-weighted E(B-V) estimated from Balmer lines

ebmv (float):

error in E(B-V). If abs_corr=True, this is computed from the covariance matrix of the best-fit parameters. If abs_corr=False (default), this is computed from the variance weights used to compute the characteristic E(B-V).

star_abs (float):

if abs_corr=True, the error-weighted stellar absorption correction; if abs_corr=False, zero.

star_abs (float):

if abs_corr=True, the error in the stellar absorption correction computed from the covariance matrix of best-fit parameters; if abs_corr=False, zero.

fit_ebmv_starabs

redneb.fit_ebmv_starabs(wave, flux, ew, flux_err=None, ebmv_guess=None, temp=10000.0, dens=100.0, ext_law='ccm89')
Name

fit_ebmv_starabs

Purpose

Calculate E(B-V) and stellar absorption correction for a desired extinction law using provided Balmer line fluxes. Computes recombination coefficients using PyNeb and extinction coefficients using the assumed extinction law. Uses scipy.optimize.curve_fit implementation of Levenberg-Marquardt to fit intrinsic emissivities to observed fluxes with E(B-V) and stellar absorption lines as free parameters.

Arguments
flux (np.ndarray):

1xn array of the Balmer line fluxes ordered by decreasing wavelength as floats, starting with H alpha (3->2, w=6563 Ang), proceeding to H beta (4->2, w=4861 Ang), H gamma (5->2, w=4340 Ang), etc. Substitute zeros for undetected lines. Supports up to H eta (9->2, w=3835 Ang).

ew (np.ndarray):

1xn array of the Balmer line equivalent widths ordered in the same manner as flux.

Keyword Arguments
ebv_guess (float):

Best guess for E(B-V). Default is None.

tem (float):

Balmer electron temperature in K. Default is 10^4 K.

den (float):

Balmer electron density in cm^-3. Default is 10^2 cm^-3.

ext_law (str):

String containing the name of the extinction law. Currently supports ‘ccm89’, ‘calzetti’,’smc’, and ‘fitz99’. Default is ‘ccm89’.

Returns
eBmV (np.ndarray):

best-fit E(B-V), accounting for uncertainty in Balmer lines and equivalent widths

star_abs (np.ndarray):

best-fit stellar absorption in Ang, accounting for uncertainty in Balmer lines and equivalent widths

eBmV_err (np.ndarray):

uncertainty in best-fit E(B-V)

star_abs_err (np.ndarray):

uncertainty in best-fit stellar absorption

fit_starabs

redneb.fit_starabs(wave, flux, ew, ebmv=0.0, flux_err=None, temp=10000.0, dens=100.0, ext_law='ccm89')
Name

fit_starabs

Purpose

Calculate stellar absorption correction for a desired extinction law and known/assumed E(B-V) using provided Balmer line fluxes and equivalent widths. Computes recombination coefficients using PyNeb and extinction coefficients using the assumed extinction law.Uses scipy.optimize.curve_fit implementation of Levenberg-Marquardt to fit intrinsic emissivities to observed fluxes with stellar absorption lines as the free parameter.

Arguments
flux (np.ndarray):

1xn array of the Balmer line fluxes ordered by decreasing wavelength as floats, starting with H alpha (3->2, w=6563 Ang), proceeding to H beta (4->2, w=4861 Ang), H gamma (5->2, w=4340 Ang), etc. Substitute zeros for undetected lines. Supports up to H eta (9->2, w=3835 Ang).

ew (np.ndarray):

1xn array of the Balmer line equivalent widths ordered in the same manner as flux.

Keyword Arguments
ebmv (float):

Assumed E(B-V). Default is 0.0.

tem (float):

Balmer electron temperature in K. Default is 10^4 K.

den (float):

Balmer electron density in cm^-3. Default is 10^2 cm^-3.

ext_law (str):

String containing the name of the extinction law. Currently supports ‘ccm89’, ‘calzetti’,’smc’, and ‘fitz99’. Default is ‘ccm89’.

Returns
star_abs (np.ndarray):

best-fit stellar absorption in Ang, accounting for uncertainty in Balmer lines and equivalent widths

star_abs_err (np.ndarray):

uncertainty in best-fit stellar absorption

get_ext_coeff

redneb.get_ext_coeff(wave, ext_law='ccm89')
Purpose

Obtain extinction coefficients for desired extinction law at given wavelengths.

Arguments
wave (float or np.ndarray):

wavelength(s) in Ang at which to evaluate the extinction law

Keyword Arguments
ext_law (str):

Extinction law to evaluate. Currently supports ‘ccm89’, ‘calzetti’,’smc’, and ‘fitz99’. Default is ‘ccm89’.

Returns

Extinction coefficient(s) A_lambda / E(B-V) evaluated at the given wavelength(s) for the desired extinction law

red_corr

redneb.red_corr(wave, flux, eBmV, ext_law='ccm89')
Purpose

Apply reddening correction to given fluxes at given wavelengths for a value of E(B-V) and desired extinction law.

Arguments
wave (float or np.ndarray):

wavelength(s) in Ang at which to evaluate the extinction law

flux (float or np.ndarray):

fluxes corresponding to wave which to correct for reddening

eBmV (float):

E(B-V) value to scale extinction coefficients for reddening correction

Keyword Arguments
ext_law (str):

Extinction law to evaluate. Currently supports ‘ccm89’, ‘calzetti’,’smc’, and ‘fitz99’. Default is ‘ccm89’.

Returns

Reddening-corrected fluxes for the assumed extinction law scaled by given E(B-V).

Clone this wiki locally