analysis subpackage

Submodules

Metallicity_Stack_Commons.analysis.attenuation module

Metallicity_Stack_Commons.analysis.attenuation.Hb_SFR(log_LHb, EBV, verbose=False, log=<Logger stdout_logger (INFO)>)

Determine dust-corrected SFR using the H-beta luminosity and a measurement for nebular attenuation

Equation below is based on Eq. 2 in Ly et al. (2015), ApJ, 805, 45

DOI: https://doi.org/10.1088/0004-637X/805/1/45

Parameters
  • log_LHb (Union[float, ndarray]) – Logarithm of H-beta luminosity in units of erg/s

  • EBV (Union[float, ndarray]) – E(B-V) value(s)

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

Union[float, ndarray]

Returns

SFRs in logarithmic units of M_sun/yr

Metallicity_Stack_Commons.analysis.attenuation.compute_A(EBV, verbose=False, log=<Logger stdout_logger (INFO)>)

Compute A(Lambda) for all possible emission lines

Parameters
  • EBV (float) – E(B-V) value Has not been configured to handle a large array. Some array handling would be needed

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

dict

Returns

A(lambda) with keys identical to k_dict

Metallicity_Stack_Commons.analysis.attenuation.compute_EBV(ratio, source='HgHb', zero_neg=True, verbose=False, log=<Logger stdout_logger (INFO)>)

Determines E(B-V) from Hg/Hb or Hd/Hb flux ratios using Case B assumptions

Parameters
  • ratio (Union[float, ndarray]) – Float or array containing Hg/Hb or Hd/Hb values

  • source (str) – Indicate ratio type. Either ‘HgHb’ or ‘HdHb’. Default: ‘HgHb’

  • zero_neg (bool) – Indicate whether to zero out negative reddening. Default: True

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

Union[float, ndarray, Tuple[ndarray, ndarray]]

Returns

E(B-V) values, E(B-V) peak values

Note:

When only E(B-V) values is returned, correction does not account for negative reddening

Metallicity_Stack_Commons.analysis.attenuation.line_ratio_atten(ratio, EBV, wave_top, wave_bottom, verbose=False, log=<Logger stdout_logger (INFO)>)

Determine dust-corrected emission-line ratios

Parameters
  • ratio (Union[float, ndarray]) – Float or array of observed flux ratios

  • EBV (Union[float, ndarray]) – E(B-V) value(s)

  • wave_top (str) – Emission-line name for flux ratio numerator

  • wave_bottom (str) – Emission-line name for flux ratio denominator

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

Union[float, ndarray]

Returns

Float or array of dust-corrected flux ratios

Metallicity_Stack_Commons.analysis.composite_indv_detect module

Metallicity_Stack_Commons.analysis.composite_indv_detect.main(fitspath, dataset, revised=False, det3=True, verbose=False, log=<Logger stdout_logger (INFO)>)

Reads in composite table(s) containing bin information to determine temperature-based metallicity from composite average T_e and individual line ratios ([OII]/H-beta, [OIII]/H-beta)

Parameters
  • fitspath (str) – Folder full path

  • dataset (str) – Sub-folder path (specific to stacking approach)

  • revised (bool) – Indicates whether to use revised bin properties (e.g., revised.tbl files). Default: False

  • det3 (bool) – Indicates whether individual galaxy files is limited to those satisfying emission-line det3 requirement Default: True

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Files identified by default:

composite_file: Filename of composite data

e.g., ‘[dataset]/bin_derived_properties.tbl’, ‘[dataset]/bin_derived_properties.revised.tbl’

indv_em_line_file: Filename that contains emission-line information

for each galaxy e.g., ‘individual_properties.tbl’

indv_bin_file: Filename that contains bin information for each galaxy

e.g., ‘[dataset]/individual_bin_info.tbl’

outfile: Filename of output file

e.g., ‘[dataset]/individual_derived_properties.tbl’

Metallicity_Stack_Commons.analysis.error_prop module

Metallicity_Stack_Commons.analysis.error_prop.fluxes_derived_prop(path, raw=False, binned_data=True, apply_dust=False, revised=True, verbose=False, log=<Logger stdout_logger (INFO)>)

Use measurements and their uncertainties to perform a randomization approach. The randomization is performed on individual emission lines. It carries that information to derived flux ratios and then determines electron temperature and metallicity

Parameters
  • path (str) – Full path

  • raw (bool) – Do a simple calculation, no randomization. Default: False

  • binned_data (bool) – Whether to analyze binned data. Default: True

  • apply_dust (bool) – Whether to apply dust attenuation. Default: False

  • revised (bool) – Indicate if revised validation table is used. Default: True

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Metallicity_Stack_Commons.analysis.error_prop.replace_oiii4363(flux_file, detection, flux_dict, log=<Logger stdout_logger (INFO)>)
Metallicity_Stack_Commons.analysis.error_prop.write_npz(path, npz_files, dict_list, verbose=False, log=<Logger stdout_logger (INFO)>)

Write numpy files with provided dictionaries

Parameters
  • path (str) – Prefix for filename output

  • npz_files (list) – NPZ file names

  • dict_list (list) – List of dict for each corresponding npz file

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Metallicity_Stack_Commons.analysis.fitting module

Metallicity_Stack_Commons.analysis.fitting.OIII4363_flux_limit(combine_flux_file, verbose=False, log=<Logger stdout_logger (INFO)>)

Determine 3-sigma limit on [OIII]4363 based on H-gamma measurements

Parameters
  • combine_flux_file (str) – Filename of ASCII file containing emission-line flux measurements

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

Optional[ndarray]

Returns

Array containing 3-sigma flux limit

Metallicity_Stack_Commons.analysis.fitting.double_gauss(x, xbar, s1, a1, c, s2, a2)

Function providing double Gaussian profile (emission and absorption) for curve_fit

Parameters
  • x (ndarray) – Wavelength array

  • xbar (float) – Central wavelength of Gaussian fit

  • s1 (float) – Sigma (width) of first Gaussian fit (positive)

  • a1 (float) – Amplitude of first Gaussian fit

  • c (float) – Continuum constant for Gaussian fit

  • s2 (float) – Sigma (width) of second Gaussian fit (absorption)

  • a2 (float) – Amplitude of second Gaussian fit

Return type

array

Returns

Double Gaussian fit

Metallicity_Stack_Commons.analysis.fitting.gauss(x, xbar, s, a, c)

Function providing Gaussian profile for curve_fit

Parameters
  • x (ndarray) – Wavelength array

  • xbar (float) – Central wavelength of Gaussian fit

  • s (float) – Sigma (width) of Gaussian fit

  • a (float) – Amplitude of Gaussian fit

  • c (float) – Continuum constant for Gaussian fit

Return type

ndarray

Returns

Gaussian fit

Metallicity_Stack_Commons.analysis.fitting.movingaverage_box1D(values, width, boundary='fill', fill_value=0.0)

Applies as boxcar kernel to smooth spectra

Parameters
  • values (ndarray) – Array containing the spectrum

  • width (float) – Width for smoothing

  • boundary (str) – Handling of boundary values. Options are: ‘None’, ‘fill’, ‘wrap’, and ‘extend’ See astropy.convolution.convolve for more information

  • fill_value (float) – Indicate fill value for default boundary=’fill’

Return type

ndarray

Returns

Array contained the smoothed/convolved spectrum

Metallicity_Stack_Commons.analysis.fitting.oxy2_gauss(x, xbar, s1, a1, c, s2, a2)

Function providing [OII] doublet Gaussian profile for curve_fit

Parameters
  • x (ndarray) – Wavelength array

  • xbar (float) – Central wavelength of [OII]3726 Gaussian fit

  • s1 (float) – Sigma (width) of [OII]3726 Gaussian fit

  • a1 (float) – Amplitude of [OII]3726 Gaussian fit

  • c (float) – Continuum constant for Gaussian fit

  • s2 (float) – Sigma (width) of [OII]3728 Gaussian fit

  • a2 (float) – Amplitude of [OII]3728 Gaussian fit

Return type

ndarray

Returns

[OII] doublet Gaussian fit

Metallicity_Stack_Commons.analysis.fitting.rms_func(wave, dispersion, lambda_in, y0, sigma_array, mask_flag, verbose=False, log=<Logger stdout_logger (INFO)>)

Compute rms in the spectra

Parameters
  • wave (ndarray) – Array of rest wavelengths

  • dispersion (float) – Spectral dispersion in AA/pix

  • lambda_in (float) – Central wavelength of fit

  • y0 (ndarray) – Array of fluxes in units of erg/s/cm2/AA

  • sigma_array (float) – Gaussian sigma (AA)

  • mask_flag (ndarray) – Indicates spectra are masked for OH skyline contamination

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Returns

Metallicity_Stack_Commons.analysis.ratios module

Metallicity_Stack_Commons.analysis.ratios.flux_ratios(flux_dict, binned_data=False, get_R=True, verbose=False, log=<Logger stdout_logger (INFO)>)

Primary code to determine a variety of line ratios based on a dict containing emission-line fluxes

Parameters
  • flux_dict (dict) – Contains emission-line fluxes

  • get_R (bool) – Indicates populating OIII4363/OIII5007 flux ratio

  • binned_data (bool) – Whether to analyze binned data. Default: False

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

dict

Returns

Emission-line flux ratios

Metallicity_Stack_Commons.analysis.temp_metallicity_calc module

Metallicity_Stack_Commons.analysis.temp_metallicity_calc.R_calculation(OIII4363, OIII5007, verbose=False, log=<Logger stdout_logger (INFO)>)

Computes the excitation flux ratio of [OIII]4363 to [OIII]5007. Adopts a 3.1-to-1 ratio for 5007/4959

Parameters
  • OIII4363 (Union[float, ndarray]) – OIII4363 fluxes

  • OIII5007 (Union[float, ndarray]) – OIII5007 fluxes

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

Union[float, ndarray]

Returns

O++ excitation flux ratio

Metallicity_Stack_Commons.analysis.temp_metallicity_calc.metallicity_calculation(T_e, TWO_BETA, THREE_BETA, EBV=None, det3=None, verbose=False, log=<Logger stdout_logger (INFO)>)

Determines 12+log(O/H) from electron temperature and [OII]/Hb and [OIII]/Hb flux ratio

Parameters
  • T_e (ndarray) – Array of electron temperatures (see temp_calculation)

  • TWO_BETA (ndarray) – Array of [OII]/Hb flux ratios

  • THREE_BETA (ndarray) – Array of [OIII]/Hb flux ratios

  • EBV (Optional[ndarray]) – Optional array containing EBV distribution

  • det3 (Optional[ndarray]) –

    Optional array to pass in to identify those satisfying det3 requirements. Default: None means full array is considered

    Note: for Monte Carlo inputs, a 1-D np.array index satisfying

    det3 requirements will suffice

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

dict

Returns

Contains 12+log(O/H), O+/H, O++/H, log(O+/H), log(O++/H)

Metallicity_Stack_Commons.analysis.temp_metallicity_calc.temp_calculation(R, EBV=None, verbose=False, log=<Logger stdout_logger (INFO)>)

Computes electron temperature (T_e) from O++ excitation flux ratio

Formula is:

T_e = a(-log(R)-b)^(-c) where a = 13025, b=0.92506, and c=0.98062 (Nicholls et al. 2014)

Parameters
  • R (ndarray) – Array of O++ excitation flux ratio (see R_calculation)

  • EBV (Optional[ndarray]) – Array of E(B-V). Set to zero if not applying attenuation

  • verbose (bool) – Write verbose message to stdout. Default: file only

  • log (Logger) – logging.Logger object

Return type

ndarray

Returns

Array of T_e (Kelvins)

Module contents