Modules

Core SPAMM Modules

Spectrum

class spamm.Spectrum.Spectrum(spectral_axis, flux, flux_error=None, spectral_axis_unit=Unit("Angstrom"), flux_unit=Unit("erg / (Angstrom cm2 s)"), *args, **kwargs)

Inherit from Spectrum1DRef in specutils. Wavelength (spectral_axis) and flux are unit-less in this child class. Units are instead stored as attributes.

Parameters
  • spectral_axis (array-like or astropy.units.Quantity) – Wavelength values.

  • flux (array-like or astropy.units.Quantity) – Flux values.

  • flux_error (array-like or astropy.units.Quantity, optional) – Error on flux values.

  • spectral_axis_unit (astropy.units.Unit, optional) – Wavelength unit

  • flux_unit (astropy.units.Unit, optional) – Flux unit.

flux

Unit-less flux values of Spectrum instance.

grid_spacing()

Return the spacing of the wavelength grid in Ångstroms. Does not support variable grid spacing.

norm_wavelength_flux

Returns the flux at the normalization wavelength.

spectral_axis

Returns a Quantity array with the values of the spectral axis.

Model

class spamm.Spectrum.Spectrum(spectral_axis, flux, flux_error=None, spectral_axis_unit=Unit("Angstrom"), flux_unit=Unit("erg / (Angstrom cm2 s)"), *args, **kwargs)

Inherit from Spectrum1DRef in specutils. Wavelength (spectral_axis) and flux are unit-less in this child class. Units are instead stored as attributes.

Parameters
  • spectral_axis (array-like or astropy.units.Quantity) – Wavelength values.

  • flux (array-like or astropy.units.Quantity) – Flux values.

  • flux_error (array-like or astropy.units.Quantity, optional) – Error on flux values.

  • spectral_axis_unit (astropy.units.Unit, optional) – Wavelength unit

  • flux_unit (astropy.units.Unit, optional) – Flux unit.

flux

Unit-less flux values of Spectrum instance.

grid_spacing()

Return the spacing of the wavelength grid in Ångstroms. Does not support variable grid spacing.

norm_wavelength_flux

Returns the flux at the normalization wavelength.

spectral_axis

Returns a Quantity array with the values of the spectral axis.

Analysis

class spamm.Spectrum.Spectrum(spectral_axis, flux, flux_error=None, spectral_axis_unit=Unit("Angstrom"), flux_unit=Unit("erg / (Angstrom cm2 s)"), *args, **kwargs)

Inherit from Spectrum1DRef in specutils. Wavelength (spectral_axis) and flux are unit-less in this child class. Units are instead stored as attributes.

Parameters
  • spectral_axis (array-like or astropy.units.Quantity) – Wavelength values.

  • flux (array-like or astropy.units.Quantity) – Flux values.

  • flux_error (array-like or astropy.units.Quantity, optional) – Error on flux values.

  • spectral_axis_unit (astropy.units.Unit, optional) – Wavelength unit

  • flux_unit (astropy.units.Unit, optional) – Flux unit.

flux

Unit-less flux values of Spectrum instance.

grid_spacing()

Return the spacing of the wavelength grid in Ångstroms. Does not support variable grid spacing.

norm_wavelength_flux

Returns the flux at the normalization wavelength.

spectral_axis

Returns a Quantity array with the values of the spectral axis.

Spectral Components

Component Base

class spamm.components.ComponentBase.Component

Description of Component class here.

This class is abstract; use (or create) subclasses of this class. Functionality that is common to all subclasses should be implemented here.

fast_interp

Determines if fast interpolation should be used instead of rebin_spec

grid_spacing()

Return the spacing of the wavelength grid in Ångstroms. Does not support variable grid spacing.

initial_values(spectrum=None)

Return type must be a list (not an np.array.

initialize(data_spectrum=None)
ln_priors(params)

Return a list of the ln of all of the priors.

@param params

native_wavelength_grid()

Returns the wavelength grid native to this component.

This needs to be overridden by subclasses.

parameter_count

Returns the number of parameters of this component.

parameter_index(parameter_name)

Balmer Continuum

class spamm.components.BalmerContinuumCombined.BalmerCombined(BalmerContinuum=False, BalmerPseudocContinuum=False)

Model of the combined BalmerContinuum (BC) based on Grandi et al. (1982) and Kovacevic & Popovic (2014).It contains two components: an analytical function to describe optically thick clouds with a uniform temperature for wavelength <3646A and the sum of higher order Balmer lines which merge into a pseudo-continuum for wavelength >=3646A. The resulting flux is therefore given by the combination of these two components, here BC_flux + BpC_flux. When initialising set which components to use

BC_flux(spectrum=None, parameters=None)

Analytic model of the BalmerContinuum (BC) based on Grandi et al. (1982) and Kovacevic & Popovic (2013).

F(lambda) = F(3646 A) * B(T_e) * (1 - e^-tau(lambda)) tau(lambda) = tau(3646) * (lambda/3646)^3

This component has 5 parameters:

parameter1 : The flux normalization at the Balmer Edge lambda = 3646 A, F(3646) parameter2 : The electron temperture T_e for the Planck function B(T_e) parameter3 : The optical depth at the Balmer edge, tau(3646) parameter4 : A shift of the line centroids parameter5 : The width of the Gaussians

note that all constants, and the units, are absorbed in the parameter F(3646 A). To impliment this appropriately, the planck function is normalized at 3646 A, so that F(3646) actually represents the flux at this wavelength.

priors: p1 : Flat between 0 and the measured flux at 3466 A. p2 : Flat between 5 000 and 20 000 Kelvin p3 : Flat between 0.1 and 2.0 p4 : Determined from Hbeta, if applicable. p5 : Determined from Hbeta, if applicable.

BpC_flux(spectrum=None, parameters=None)

Analytic model of the high-order Balmer lines, making up the Pseudo continuum near 3666 A.

Line profiles are Gaussians (for now). The line ratios are fixed to Storey &^ Hummer 1995, case B, n_e = 10^10 cm^-3. This component has 3 parameters:

parameter1 : The flux normalization near the Balmer Edge lambda = 3666 A, F(3666) parameter4 : A shift of the line centroids parameter5 : The width of the Gaussians parameter6 : The log of the electron density

note that all constants, and the units, are absorbed in the parameter F(3656 A).

priors: p1 : Flat, between 0 and the observed flux F(3656). p4 : Determined from Hbeta, if applicable. p5 : Determined from Hbeta, if applicable. p6 : Flat between 2 and 14.

note that all constants, and the units, are absorbed in the parameter F(3656 A).

balmer_ratio(n_e, line_orders, T)

Calculate the ratio between Balmer lines. (Intensity values from Storey and Hammer 1`995 results and Kovacevic et al 2014)

Parameters
  • n_e (float) – Electron density.

  • () (T) – Electron Temperature

  • lines (int array) – array of lines to include.

Returns

Ratio of Balmer lines, with Htheta (N=10 -> N=2) first.

Return type

array (array)

balmerseries(line_orders)

Calculate a Balmer series line wavelength [Angstroms]

Parameters

line_orders (int or array of ints) – Quantum number of the electron.

Returns

Wavelength of the transition from n=n to n=2.

Return type

float (float)

flux(spectrum=None, parameters=None)

Returns the flux for this component for a given wavelength grid and parameters.

initial_values(spectrum=None)

Needs to sample from prior distribution. These are the first guess for the parameters to be fit for in emcee, unless specified elsewhere.

ln_priors(params)

Return a list of the ln of all of the priors.

@param params

log_conv(wavelength, orig_flux, width_lines)

Perform convolution in log space.

Parameters
  • () (width_lines) – wavelength of original spectrum

  • () – Flux of spectrum before convolution

  • () – width of the lines wanted in v/c

Returns

Return type

array (array)

makelines(sp_wavel, T, n_e, shift, width)
Parameters
  • sp_wavel (array) – Wavelengths at which to evaluate the line fluxes.

  • T (int or float) – Electron temperature.

  • n_e (float) – Electron density.

  • shift (int or float) – Offset from expected Balmer wavelengths.

  • width (int or float) – Width of emission line.

Broad Lines

Iron Forest

class spamm.components.FeComponent.FeComponent

Fe II and III pseudo-continuum of blended emission lines.

We will use a linear combination of N broadened and scaled iron templates: $F_{lambda,,{

m Fe}} = sum_{i=1}^N F_{{ m Fe},,0,,i} FeTemplate_{lambda,,i}(sigma_i)$

where $FeTemplate_{lambda,,i}$ is iron template $i$ at wavelength $lambda$, $F_{{

m Fe},,0,,i}$ is the template normalization, and $simga_i$ is the width

of the broadening kernal.

This component has 2 kinds of parameters:
  • template normalization for each template

  • FWHM of iron lines being tested for the templates (in units of km/s)

Parameters by number 0-(i-1): normalizations of templates 1-i i-(2i-1): FWHM of the lines in templates 1 - i

Attributes:

flux(spectrum, parameters)

Returns the flux for this component for a given wavelength grid and parameters. The parameters should be a list of length (2 x Number of templates)

Parameters
  • spectrum (Spectrum object) –

  • () (parameters) –

    ?

Returns

?

Return type

flux_arrays ()

initial_values(spectrum)

Needs to sample from prior distribution. Return type must be a single list (not an np.array). These are the first guess for the parameters to be fit for in emcee. In the case of the Fe Component, this would be the normalization and, for now, FWHM of iron lines. Note that the returns will be a list, the first ‘i’ elements of which are the normalizations and the second ‘i’ elements of which are the FWHM for a loaded number of ‘i’ templates.

Parameters

spectrum (Spectrum object) –

Returns

Return type

list (list)

initialize(data_spectrum)

Perform all necessary initializations for the iron component, such as reading in teh templates, rebinning them, and interpolating them on the grid scale of the data spectrum.

is_analytic()

Method that stores whether component is analytic or not.

Returns

True is component is analytic.

Return type

Bool (Bool)

ln_priors(params)

Return a list of the ln of all of the priors.

Parameters

() (params) –

?

Returns

List of the ln of all priors.

Return type

ln_priors (list)

load_templates()

Read in all of the Fe templates.

parameter_count

Returns the number of parameters of this component.

Returns

Number of componenet parameters.

Return type

no_parameters (int)

Host Galaxy

class spamm.components.HostGalaxyComponent.HostGalaxyComponent

Host Galaxy Component:

$ F_{lambda, m Host}=sum_{1}^{N} F_{ m Host,i}

HostTempl_{lambda,i}(sig_*)

$
This component has N templates and N+1 parameters.

normalization:

$ F_{ m Host,i} $ for each of the N templates.

stellar line dispersion:

$ sig_* $

Attributes:

host_gal (list): List of Spectrum objects for each template file. interp_host (list): interp_norm_flux (list):

#TODO should name be in Component?

name (str): Name of component, i.e. “Nuclear” norm_min (): norm_max (): stellar_disp_min (): stellar_disp_max ():

flux(spectrum, parameters)

Returns the flux for this component for a given wavelength grid and parameters. Will use the initial parameters if none are specified.

Parameters
  • spectrum (Spectrum object) –

  • () (parameters) –

    ?

Returns

?

Return type

flux_arrays ()

initial_values(spectrum)

Needs to sample from prior distribution.

Parameters

spectrum (Spectrum object) –

?

Returns

Return type

list (list)

initialize(data_spectrum)

Perform any initializations using the data spectrum.

Parameters

data_spectrum (Spectrum object) –

?

is_analytic()

Method that stores whether component is analytic or not.

Returns

True is component is analytic.

Return type

Bool (Bool)

ln_priors(params)

Return a list of the ln of all of the priors.

Parameters

() (params) –

?

Returns

List of the ln of all priors.

Return type

ln_priors (list)

load_templates()

Read in all of the host galaxy models.

parameter_count

Returns the number of parameters of this component.

Returns

Number of componenet parameters.

Return type

no_parameters (int)

Nuclear Continuum

class spamm.components.NuclearContinuumComponent.NuclearContinuumComponent(broken=None)

AGN Continuum Component

$ F_{lambda,{ m PL}}=F_{ m PL,0}

left(

rac{lambda}{lambda_0} ight)^{lpha} $

This component has two parameters:

normalization :

$ F_{ m PL,0} $

slope :

$ lpha $

Attributes:

broken_powerlaw (Bool): True if a broken power law should be used. model_parameter_names (list): List of model parameter names,

e.g. slope1, wave_break

name (str): Name of component, i.e. “Nuclear” norm_min (): norm_max (): slope_min (): slope_max (): wave_break_min (): wave_break_max ():

flux(spectrum, parameters=None)

Compute the flux for this component for a given wavelength grid and parameters. Use the initial parameters if none are specified.

Parameters
  • spectrum (Spectrum object) –

    ?

  • () (parameters) –

    ?

Returns

Flux of the componenet.

Return type

flux ()

initial_values(spectrum)

Needs to sample from prior distribution. Return type must be a list (not an np.array).

Called by emcee.

Parameters

spectrum (Spectrum object) –

?

Returns

slope_init (array):

Return type

norm_init (array)

is_analytic

Method that stores whether component is analytic or not

Returns

True if componenet is analytic.

Return type

Bool (Bool)

ln_priors(params)

Return a list of the ln of all of the priors.

# norm: Uniform linear prior between 0 and the maximum of the # spectral flux after computing running median. # slope: Uniform linear prior in range [-3,3]??

Args:

params (): ?

Returns:

ln_priors (list): ln of all the priors.