SN Spectroscopic Evolution

This project explores the evolution of Type Ia Supernova (SN Ia) spectra as a function of redshift and host galaxy properties.

Installation

This project uses the spec_analysis package which is available on GitHub:

git clone https://github.com/mwvgroup/SN-Spectral-Evolution/

Dependencies can be install via the pip package manager and the included requirements.txt file:

pip install -r requirements.txt

If building a new copy of the project documentation, you will need to install additional dependencies from the docs folder

pip install -r docs/requirements.txt

Getting Started

This project relies on a graphical interface to identify and measure spectroscopic features. This section of the documentation will walk you through how to configure and launch that interface.

Config Files

Setting for the graphical interface are defined in a yaml config file. Available settings include:

  1. Options for how to bin spectra and sample feature properties
  2. Definitions for each feature that will be measured
  3. A small subset of arguments for plot styling

A full config file is provided with the project source code under app_config.yml. A shorter example is provided below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Number of steps to take in either direction when varying feature bounds
# to determine sampling error
nstep: 5

# Settings used when correcting for extinction and binning the spectra
prepare:
  rv: 3.1
  bin_size: 10
  bin_method: median

# Definitions of the features we want to investigate
# Inspection is performed in the order they are defined below
features:
  pW1:
    feature_id: Ca ii H&K
    restframe: 3945.02
    lower_blue: 3500
    upper_blue: 3800
    lower_red: 3900
    upper_red: 4100

  pW2:
    feature_id: Si ii λ4130
    restframe: 4129.78
    lower_blue: 3900
    upper_blue: 4000
    lower_red: 4000
    upper_red: 4150

# Style arguments for the plotting elements
pens:
  observed_spectrum:
    color: [0, 0, 180, 80]

  binned_spectrum:
    width: 1.5
    color: k

  feature_fit:
    color: r

  lower_bound:
    width: 3
    color: r

  upper_bound:
    width: 3
    color: r

  # The below represent shaded regions and only colors can be set
  saved_feature:
    [0, 180, 0, 75]

  lower_region:
    [255, 0, 0, 50]

  upper_region:
    [0, 0, 255, 50]

Launching the GUI

The scripts/ directory provides pre-built scripts that launch the GUI for various supernova surveys. At their core, the scripts format the data from each survey to be compatible with the GUI and then launch the user interface.

Each script requires two command line arguments to run. The first argument is the path of a configuration file (more details above). The second argument is the path of the desired output file with a .csv file extension.

To run an analysis script, the syntax is as follows:

python scripts/[NAME OF SCRIPT] [PATH TO CONFIG FILE] [PATH OF OUTPUT FILE]

If you get interrupted during the analysis process, re-running the above command with the same output file path will resume your analysis from the last spectrum you were working on.

Using the GUI

Note

TODO: This documentation still needs to be added.

Data

This project considers data from multiple data releases. Brief descriptions of each data set are provided here.

CPS DR1 (Folatelli et al. 2013)

The first Carnegie Supernova Project (CSP) was a five-year survey run at Las Campanas Observatory (LCO) from 2004 through 2009 using the Swope 1 m and du-Pont 2.5 m telescopes. The first CSP data release (CSP DR1) includes 604 spectra of 93 SNe Ia. Observations cover phases ranging from -12 to over 150 days as measured from the estimated time of B-band maximum light and a redshift range of \(.005 < z < 0.085\). Since RA and Dec coordinates were missing from the publicly available CSP DR1 data files, coordinate values were used from the third public data release (DR3).

SDSS (Sako et al. 2018)

The Sloan Digital Sky Survey-II (SDSS-II) Supernova Survey was conducted between 2005 and 2007. The spectroscopic portion of the SDSS SN data release includes 1359 transient and variable objects, 692 of which were classified as being SNe Ia. Redshift values for the SDSS data sample run from \(.014 < z < 0.580\).

A number of SDSS spectra have visible H-alpha features that indicated an incomplete host galaxy subtraction. Furthermore, some spectra are too noisy to confidently identify the location or presence of various features. These spectra are identified by visual inspection, and are skipped at the discretion of the investigator.

Relevant Literature

This page outlines notes on a subset of relevant literature to our project.

Definitions of Spectrocopic Classification Schemes

  • Wang 2009

Branch 2006

Note

TLDR: SNe Ia are subclassed into shallow silicon, core-normal, broad line, and cool groups based on relative the strength of Si II features at 5750 and 6100 Angstroms.

This paper identifies classifications of SNe Ia using the width of the 5750 and 6100 features (usually attributed to Si ii at 5972 and 6355). To simplify the process of feature comparison, spectra are first tilted by multiplying the flux by \(\lambda^\alpha\) where \(\alpha\) is chosen such that the peak flux near 4600 and 6300 A are equal. The Equivalent widths are then plotted for the feature at 5750 A vs the feature at 6100 A. After applying a nearest neighbor algorithm, four groups emerged: shallow silicon, core-normal, broad line, and cool (which includes SN 1991bg).

Broad-line SNe Ia have absorption features at 6100 A absorptions that are broader and deeper than core-normal SNe Ia. However, SNe in this category do not appear to follow a simple one-dimensional sequence based on their distance from the core-normal population.

The shallow silicon group are not (necessarily) very different from the core normal group. Other than a narrower Si feature, they look remarkably similar. The primary reason for the spectroscopic differences seems to be the lower temperature, as indicated by low temperature ion signatures (e.g. Ti). Otherwise, they have the same ions evident in their spectra, just at very different optical depths. This aligns with their lower temperatures since “as noted by Hatano+ (2002) and Ho Flich+ (2002), there is a temperature threshold below which, owing to abrupt changes in key ionization ratios, line optical depths change abruptly (Hatano+ 1999).”

The core-normal subgroup have a very high degree of similarity, suggesting a standard, common physical mechanism involving no large inhomogeneities near the characteristic photosphere velocity of 12,000 km/s.

Papers investigating Host Galaxy Correlations

  • Gallagher 2008
  • Kelly 2010 (?)
  • Sullivan 2010 (?)
  • Lampeitl 2010
  • Gupta 2011
  • Rigault et al. 2013
  • Jones 2015
  • Moreno-Raya 2016
  • Uddin 2017
  • Kim 2018
  • Rigault 2018
  • Jones 2018
  • Rose 2019

Papers Investigating Redshift Evolution

Hoflich 1998

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Hook 2005

  • Sample Size: 14 SNe
  • Survey: Supernova Cosmology Project
  • Dates:
  • Sampling: Peak only
  • Redshift: 0.17 < z < 0.83

Conclusions:

No evidence was found for evolution in SNe Ia properties with redshift. Plotting the high-redshift sample against well-observed local SNe showed a clear indication that the overall trends spectroscopic evolution are the same at low and high z. Furthermore, measurements of the Ca ejecta velocity in the high-redshift spectra were also consistent with those measured from low-redshift, Branch-normal SNe Ia.

Bronder 2008

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

No evidence was found of SNe Ia evolution with redshift. Measured pseudo-equivalent widths (PEW) for a group of high and low redshift SNe and plotted feature strength with respect to redshift for MgII, SiII, and CaII, as well as CaII ejection velocity. This paper uses 3 guidelines for calculating PEW. First, the measurements for the PEW bounds must fall within the ranges defined in Table 3. Second, the boundaries should be chosen to maximize the PEW area. Third, the measurements should be taken in the rest frame. The core normal SNe showed no consistent trend. They did observe a correlation between the strength of the SiII feature and the peak magnitude. However, this trend did not significantly improve standardization over stretch parameter corrections.

Hatano 2000

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Lentz 2000

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Blondin 2018

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Siebert 2019

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Kang 2020

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Rose 2020

  • Sample Size:
  • Survey:
  • Dates:
  • Sampling:
  • Redshift:

Conclusions:

Papers Investigating Inherent Spectroscopic Diversity

Blondin 2012

  • Sample Size: 2603 spectra of 462 SNe Ia
  • Survey: Center for Astrophysics (CfA) Supernova Program
  • Dates: October 1993 through August 2008.
  • Sampling: 313 SNe have two or more spectra, and of these each SN has an average of 8 observed spectra.
  • Redshift: z < 0.1 with a median \(z ~ 0.023\). One high redshift target (SN 1996ab) at \(z ~ 0.123\).

Conclusions:

Using the classification schemes of Branch 2006 Wang 2009 there was found to be a continuum of spectroscopic properties (i.e., no strict boundaries) between the different subclasses that was unlikely to be explained by a single parameter.

In Branch 2009 it was proposed that SNe Ia from the Core Normal subclass 1) have a significantly smaller scatter in intrinsic peak brightness, and 2) decline photometrically at the same rate as the Shallow Silicon (SS) subclass. The first claim is rejected and the second is shown not to be universally true. It was also found that SS, CN, and Broad Line (BL) SNe form a sequence of increasingly steep width-luminosity relations. The same is true for the 91T, Normal, High-velocity sequence used in the Wang 2009 classification scheme

Using early-time spectra to probe the outermost ejecta, Silicon is shown to absorb at velocities that are larger than expected for a pure deflagration model.

In Mazzali 1998 the correlation of Δm15(B) and the FWHM of the iron emission feature at ∼4700 Å was interpreted as a correlation between luminosity and explosion kinetic energy. This paper finds that the correlation is largely driven by SN 1991bg-like SNe and that by excluding low luminosity SNe (Δm15(B) < 1.6 mag), there is no correlation between both quantities (r=−0.17)

spec_analysis

The spec_analysis package provides utilities for measuring the spectroscopic properties of Type Ia Supernovae (SNe Ia). This includes a both a dedicated Python API and a graphical interface for measuring individual spectral features. The package is designed to be compatible with spectroscopic data releases provided by the sndata package - including combined and custom data sets.

spec_analysis.exceptions

The exceptions module defines custom Python exceptions.

Exception Summaries

spec_analysis.exceptions.FeatureNotObserved Feature was not observed or does not span indicated wavelength range
spec_analysis.exceptions.SamplingRangeError Resampling process extends beyond available wavelength range

spec_analysis.features

The features is responsible for measuring the properties of individual spectral features. Individual classes are used to represent separate calculations of feature properties. These classes may be used individually, however, it is recommended you use the ObservedFeature class which combines all of the calculations into a single object.

spec_analysis.features.FeatureArea Represents the area calculation for a spectroscopic feature
spec_analysis.features.FeaturePEW Represents the pEW calculation for a spectroscopic feature
spec_analysis.features.FeatureVelocity Represents the velocity calculation for a spectroscopic feature
spec_analysis.features.ObservedFeature Represents a spectral observation spanning a single absorption feature

Usage Examples

Included in the ObservedFeature class is the ability to calculate the area, pseudo equivalent width (PEW), and flux of a given feature. Feature classes are instantiated using the rest frame wavelength, flux, and binned flux (e.g., the flux through a median filter).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import numpy as np
from scipy.ndimage.filters import median_filter

from spec_analysis.features import find_peak_wavelength
from spec_analysis.simulate import gaussian

wave = np.arange(1000, 2000)
flux, flux_err = gaussian(wave, stddev=100)
bin_flux = median_filter(flux, size=10)

feature = ObservedFeature(wave, flux, bin_flux)

Feature properties can be accessed using attributes:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# From the area calculation
area = feature.area            # Feature area

# From the PEW calculation
continuum = feature.continuum  # Sudo continuum flux per wavelength
norm_flux = feature.norm_flux  # Normalized flux per wavelength
pew = feature.pew              # Pseudo equivalent width

# From the velocity calculation
velocity = feature.velocity    # velocity of the feature in km / s
amp = feature.gauss_amplitude  # Amplitude of fitted gaussian
avg = feature.gauss_avg        # Average of fitted gaussian
stddev = feature.gauss_stddev  # Standard deviation of fitted gaussian
offset = feature.gauss_offset  # y-offset of fitted gaussian

Note that the velocity is determined by fitting the normalized flux using an inverted Gaussian of the form

\[- A * e^{(-(x - \mu)^2 / (2 \sigma^2)} + c\]

This function is accessible programmatically as spec_analysis.features.gaussian, or the evaluated fit can be determined using

gauss_fit = feature.gaussian_fit()

API Documentation

spec_analysis.features.gaussian(x, depth, avg, std, offset)[source]

Evaluate a negative gaussian

f = -depth * e^(-((x - avg)^2) / (2 * std ** 2)) + offset

Parameters:
  • x (ndarray) – Values to evaluate the gaussian at
  • depth (float) – Amplitude of the gaussian
  • avg (float) – Average of the gaussian
  • std (float) – Standard deviation of the gaussian
  • offset (float) – Vertical offset
Returns:

The evaluated gaussian

class spec_analysis.features.FeatureArea(wave, flux, bin_flux)[source]

Represents the area calculation for a spectroscopic feature

__init__(wave, flux, bin_flux)[source]

Calculates the area of a spectroscopic feature

Parameters:
  • wave (ndarray) – The wavelength values of the feature
  • flux (ndarray) – The flux values for the feature
  • bin_flux (ndarray) – The binned flux values for the feature
area

The area of the feature

Area is determined between the sudo continuum of the binned flux and the flux values from the non-binned flux.

class spec_analysis.features.FeaturePEW(wave, flux, bin_flux)[source]

Represents the pEW calculation for a spectroscopic feature

__init__(wave, flux, bin_flux)[source]

Calculates the pEW of a spectroscopic feature

Parameters:
  • wave (ndarray) – The wavelength values of the feature
  • flux (ndarray) – The flux values for the feature
  • bin_flux (ndarray) – The binned flux values for the feature
continuum

Array of values for the fitted sudo continuum

norm_flux

The flux normalized by the sudo continuum

pew

Calculate the pseudo equivalent-width of the feature

Returns:The pseudo equivalent-width of the feature
class spec_analysis.features.FeatureVelocity(wave, flux, bin_flux, rest_frame)[source]

Represents the velocity calculation for a spectroscopic feature

__init__(wave, flux, bin_flux, rest_frame)[source]

Calculates the pEW of a spectroscopic feature

Parameters:
  • wave (ndarray) – The wavelength values of the feature
  • flux (ndarray) – The flux values for each feature
gauss_amplitude

The fitted gaussian amplitude

gauss_avg

The fitted gaussian average

gauss_offset

The fitted gaussian offset

gauss_stddev

The fitted gaussian standard deviation

gaussian_fit()[source]

Evaluate the gaussian fit of the normalized flux for feature wavelengths

Returns:An array of normalized flux values
velocity

Calculate the velocity of a feature

Fit a feature with a negative gaussian and determine the feature’s velocity. Returned value is np.nan if the fit fails.

Returns:The velocity of the feature in km / s
class spec_analysis.features.ObservedFeature(wave, flux, bin_flux, rest_frame)[source]

Represents a spectral observation spanning a single absorption feature

__init__(wave, flux, bin_flux, rest_frame)[source]

Represents a spectral observation spanning a single absorption feature

Parameters:
  • wave (ndarray) – The wavelength values of the feature
  • flux (ndarray) – The flux values for each feature

spec_analysis.spectra

The spectra module provides object representations of spectra and is responsible for processing spectra (e.g. extinction correction) and sampling any spectral features.

Note

Where applicable, this module uses the Schlegel et al. 1998 dust map and Fitzpatrick et al. 1999 extinction law.

Usage Examples

Spectrum objects are used to represent individual spectra and provide functionality for correcting MW extinction, rest-framing, and binning the spectra (in that specific order!). A handful of examples demonstrating this functionality is provided below:

Working with a Single Spectrum

First we define a demo spectrum with dummy values for wavelength, flux, redshift, right ascension (RA) and declination (Dec). All values are defined in the observer frame.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import numpy as np

from spec_analysis import simulate, spectra

# Define feature using rest and observer frame average wavelength
wave = np.arange(4000, 5000)
lambda_rest = np.mean(wave)
lambda_observed = lambda_rest - 10
flux, eflux = simulate.gaussian(wave, mean=lambda_observed, stddev=100)

# Prepare a demo spectrum object
cls.spectrum = Spectrum(wave, flux, ra=0, dec=-1, z=0)

To correct for MW extinction and bin the spectrum, use the prepare_spectrum method. Several filters are available for binning the spectrum. Here we use a median filter with a window size of 10:

1
2
3
4
5
spectrum.prepare_spectrum(bin_size=10, method='median')

rest_wave = spectrum.rest_wave  # Rest-framed wavelengths
rest_flux = spectrum.rest_flux  # Extinction corrected flux
bin_flux = spectrum.bin_flux    # Filtered, extinction corrected flux

Once the spectrum is prepared, you can measure it’s properties for a given feature. This requires knowing the start / end wavelength of the feature in the current spectrum, and the feature’s rest frame wavelength.

1
2
3
feat_start = spectrum.rest_wave[10]
feat_end = spectrum.rest_wave[-10]
spectrum.sample_feature_properties(feat_start, feat_end, lambda_rest)

Custom Callbacks

If you want to inject your own custom calculations to the sampling process, this can be added by specifying the callback argument.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def my_callback(feature):
    '''This function will be called for every iteration / sample

    Args:
        feature (ObservedFeature): The sampled flux as a feature object
    '''

    pass

spectrum.sample_feature_properties(
    feat_start, feat_end, rest_frame, callback=my_callback)

Iterating over a Data Release

The SpectraIterator class is used to iterate over spectra from data releases provided by the sndata package. Various arguments can be specified to account for variations in data formatting between different surveys. As an example, we consider the SDSS survey, which is accessed as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from sndata.sdss import Sako18Spec
from spec_analysis.spectra import SpectraIterator

# Make sure data is downloaded to your local machine
data_release = Sako18Spec()
data_release.download_module_data()

# Just so we can see the SDSS data model
demo_table = next(data_release.iter_data())
print(demo_table)

The data tables from SDSS include multiple spectra, including host galaxy spectra and multiple observations of the supernova. We use a pre-processing function to remove the galaxy spectra, and distinguish between different spectra using their observation time (the time column in the data tables)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Function called to process data tables before plotting / analysis
def pre_process(table):
    """Pre-process spectral data

    Args:
        table: An astropy table with unprocessed data

    Returns:
        An astropy table with processed data
    """

    # Remove galaxy spectra from data tables
    # (and any other spectral data you don't want to consider)
    return table[table['type'] != 'Gal']

data_iter = SpectraIterator(data_release, pre_process=pre_process, group_by='time')

If we only wanted to consider data for a subset of targets, we can specify those targets using their object Id.

1
2
3
obj_ids = ['722', '739', '744', '762', '774']
data_iter = SpectraIterator(
    data_release, obj_ids=obj_ids, pre_process=pre_process, group_by='time')

Note

The pre_process function is called before spectra are grouped using the group_by keyword. This allows you to add a custom group_by value to the data tables if necessary.

The SpectraIterator class expects data tables to have the ra, dec, ad z keys specified in their meta data. If those values are not available, they can be added in the pre-processing function.

API Documentation

class spec_analysis.spectra.Spectrum(wave, flux, ra, dec, z, **kwargs)[source]

Object representation of an observed spectrum

__init__(wave, flux, ra, dec, z, **kwargs)[source]

Measures pEW and calc_area of spectral features

Parameters:
  • wave (ndarray) – Observer frame wavelength
  • flux (ndarray) – Observer frame flux
  • ra (float) – The target’s right ascension
  • dec (float) – The target’s declination
  • z (float) – The target’s redshift
  • kwargs to set as instance attributes (Additional) –
prepare_spectrum(rv=3.1, bin_size=5, bin_method='median')[source]

Correct for extinction, rest-frame, and bin the spectrum

Parameters:
  • bin_size (float) – Bin size in units of Angstroms
  • bin_method (str) – Either ‘median’, ‘average’, ‘sum’, or ‘gauss’
  • rv (float) – Rv value to use for extinction (Default: 3.1)
sample_feature_properties(feat_start, feat_end, rest_frame, nstep=0, callback=None)[source]

Calculate the properties of a single feature in a spectrum

Velocity values are returned in km / s. Error values are determined both formally (summed in quadrature) and by re-sampling the feature boundaries nstep flux measurements in either direction.

Parameters:
  • feat_start (float) – Starting wavelength of the feature
  • feat_end (float) – Ending wavelength of the feature
  • rest_frame (float) – Rest frame location of the specified feature
  • nstep (int) – Number of samples taken in each direction
  • callback (callable) – Call a function after every iteration. Function is passed the sampled feature.
Returns:

  • The line velocity
  • The formal error in velocity
  • The sampling error in velocity
  • The equivalent width
  • The formal error in equivalent width
  • The sampling error in equivalent width
  • The feature calc_area
  • The formal error in calc_area
  • The sampling error in calc_area

class spec_analysis.spectra.SpectraIterator(data_release, obj_ids=None, pre_process=None, group_by='time')[source]

Iterator over individual spectra from an sndata data release

__init__(data_release, obj_ids=None, pre_process=None, group_by='time')[source]

An iterator over individual spectra in a data release

Instantiates an iterator over spectra in a sndata data release. Spectra are yielded individually as Spectrum objects. Any meta data for a given spectrum is added as an attribute to the corresponding Spectrum object. The time of the observation is also included as an attribute.

Parameters:
  • data_release (SpectroscopicRelease) – An sndata style data release
  • obj_ids (list) – Optionally only consider a subset of Id’s
  • pre_process (Callable) – Function to prepare data before plotting
Yields:

Spectrum objects

spec_analysis.app

The app module defines the objects and logic that drive the graphical interface. It includes dedicated classes for each application window, and a run function for launching the GUI application. For usage examples, see the GettingStarted_ guide.

API Documentation

spec_analysis.app.run(spectra_iter, out_path, config)[source]

Run the graphical interface

Parameters:
  • spectra_iter (SpectraIterator) – Iterator over the data to measure
  • out_path (str) – Name of CSV file where results are saved
  • config (dict) – Application config settings

GUI Classes

class spec_analysis.app.MainWindow(spectra_iter, out_path, config)[source]

The run_sako18spec window for visualizing and measuring spectra

__init__(spectra_iter, out_path, config)[source]

Visualization tool for measuring spectroscopic features

Parameters:
  • spectra_iter (SpectraIterator) – Iterator over the data to measure
  • out_path (str) – Name of CSV file where results are saved
  • config (dict) – Application config settings
calculate()[source]

Logic for the calculate button

Measure the current spectral feature and store to the feature_measurements attribute.

clear_feature_fits()[source]

Clear any plotted feature fits from the plot

clear_plotted_pew(clear_single=False)[source]

Clear any plotted feature boundaries from the plot

Parameters:clear_single (bool) – Clear only the current feature (False)
current_feat_def

The definition of the current feature as a dict

current_feat_name

The name of the current feature

finished()[source]

Logic for the finished button

Skip inspection for all features in the current spectrum

last_feat()[source]

Logic for the last feature button

Skip inspection for the current feature

next_feat()[source]

Logic for the next feature button

Skip inspection for the current feature

plot_saved_feature()[source]

Clear any plotted feature boundaries from the plot

reset_plot()[source]

Reset the plot to display the current spectrum with default settings

Auto zooms the plot and repositions plot widgets to their default locations.

save()[source]

Logic for the save button

Save current feature measurements to internal DataFrame.

spec_analysis.simulate

The simulate module provides functions for simulating spectra (wavlength and lfux arrays) with absorption features according to various toy models. This is useful when testing or visualizing the behavior of an analysis procedure.

Usage Examples:

We here demonstrate the simulation of an absoprion feature with a gaussian profile. For a list of available profiles, see the API Documentation.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import numpy as np
from matplotlib import pyplot as plt
from spec_analysis.simulate import gaussian

# Simulate a gaussian with a peak at 1200 wavelength units
wave = np.arange(1000, 2000)
flux, flux_err = gaussian(wave, stddev=100)

# Visualize the result
plt.errorbar(wave, flux, yerr=flux_err, linestyle='', alpha=.5, label='Error')
plt.plot(wave, flux, color='k', label='Flux')
plt.xlabel('Wavelength')
plt.ylabel('Flux')
plt.legend()
plt.show()

API Documentation

spec_analysis.simulate.delta_func(wave, m=0, b=0, peak_wave=(), amplitude=1, seed=None)[source]

Simulate linear flux with interspersed delta functions and normal errors

Parameters:
  • wave (ndarray) – Array of wavelengths to simulate flux for
  • m (float) – Slope of the continuum
  • b (float) – Y-intercept of the continuum
  • peak_wave (tuple) – Wavelengths of the delta functions
  • amplitude (float) – Height of the delta functions
  • seed (float) – Optional seed for random number generator
Returns:

  • An array of flux values
  • An array of error values

spec_analysis.simulate.gaussian(wave, amplitude=-1, mean=None, stddev=1, offset=100, seed=0)[source]

Simulate gaussian flux with normal errors

Parameters:
  • wave (ndarray) – Array of wavelengths to simulate flux for
  • amplitude (float) – Amplitude of the Gaussian
  • mean (float) – Average of the Gaussian (default: mean of wave)
  • stddev (float) – Standard deviation of the Gaussian
  • offset (float) – Vertical offset of the Gaussian
  • seed (float) – Seed for random number generator
Returns:

  • An array of flux values
  • An array of error values

spec_analysis.simulate.tophat(wave, m=0, b=1, start=100, end=-100, height=0, seed=0)[source]

Simulate a top-hat absorption feature with normal errors

Setting height=None will simulate just the continuum

Parameters:
  • wave (ndarray) – Array of wavelengths to simulate flux for
  • m (float) – Slope of the continuum (default: 0)
  • b (float) – Y-intercept of the continuum (default: 1)
  • start (int) – Starting index for the top-hat (default: 100)
  • end (int) – Ending index for the top-hat (default: -100)
  • height (float) – Height of the top-hat (default: 0)
  • seed (float) – Seed for random number generator (default: 0)
Returns:

  • An array of flux values
  • An array of error values