Skip to content

A collection of astronomical spectrum reduction and processing scripts.

License

Notifications You must be signed in to change notification settings

tseccull/spectools

Repository files navigation

spectools

GitHub Release DOI

Author: Tom Seccull

This is a personal collection of scripts that I use for reduction, processing, and analysis of astronomical spectroscopic data. Although these scripts are still undergoing active development, this repo is intended more as a citable record than a public software distribution. By all means feel free to use any of these scripts, either in whole or in part, but note that you do so at your own risk. I cannot guarantee that this software will either work or be beneficial to you. If you download a copy of this repo, be sure to select the most recent stable release at the link on the right.

If, against all odds, any of the scripts in this repo end up helping you in your work, please consider citing the repo with the details provided via the Zenodo DOI above.

The scripts in this repo rely on multiple Python packages that deserve recognition if they are used. Please be sure to cite them where necessary:

Astropy, Matplotlib, NumPy, SciPy

scrap.py

v1.0.6

This is essentially a Python wrapper for Astropy's Astroscrappy, which is itself a Python implementation of Pieter van Dokkum's LA Cosmic. This script is used for detecting, masking, and cleaning cosmic ray hits in 2D spectroscopic data. A modular design is intended to facilitate easy processing of data observed with a variety of instruments. If Astroscrappy is used, both McCully et al., and van Dokkum should be cited:

Astroscrappy Docs

McCully et al. 2018, Astropy/Astroscrappy: v1.0.5 Zenodo Release (v1.0.5). Zenodo

van Dokkum 2001, PASP, 113, 1420

Requires: Astropy, Astroscrappy, NumPy, SciPy
Supported Instruments: GMOS-N, GMOS-S

fronge.py

v1.0.3

This script is designed to correct fringing in 2D spectroscopic data by creating a median fringe frame and subtracting it from science data. A modular design is intended to facilitate easy processing of data observed with a variety of instruments.

Requires: Astropy, NumPy
Supported Instruments: GMOS-N, GMOS-S

extinct.py

v1.0.2

This script applies an average extinction correction to input 1D astronomical spectroscopic data based on the measured atmospheric extinction curve of the observing site. The spectrum and its uncertainties are each multiplied by 10 ^ (0.4 * airmass * k(lambda)), where airmass is the median airmass at which the spectrum was observed and k(lambda) is the wavelength dependent extinction curve at the observing site given in magnitudes per unit airmass. Note that the extinction curves used here are averages that do not account for variable atmospheric extinction due to variable concentrations of atmospheric water vapour or scattering particles. When comparing or calibrating one corrected spectrum with another it is assumed that atmospheric conditions were stable across the consecutive observations of both targets. This script does not create new files, but instead just updates the input files. If this script is used, be sure to cite the appropriate article or link for the extinction curve. extinct.py is only readily compatible with spectra extracted by MOTES, and it should be run on individual 1D spectra of a given target prior to stacking them.

Requires: Astropy, Matplotlib, NumPy, SciPy
Supported Instruments: GMOS-N, GMOS-S

Extinction Curve Sources:
GMOS-N - Buton et al. 2013, A&A, 549, A8
-------- see Gemini website for the 3100 angstrom point.
GMOS-S - Stritzinger et al. 2005, PASP, 117, 810

stack.py

v1.0.2

This script takes multiple 1D spectra and combines them to produce a stacked 1D spectrum with reduced noise. All input spectra are scaled to unity at either a user-selected wavelength or the central wavelength of the spectra. The spectra are then all randomly resampled within their uncertainties to estimate the total combined distribution of possible values for each wavelength in the stacked spectrum. The uncertainty distribution of each data point in each spectrum is assumed to be Gaussian with the mean defined by the value of the data point and the standard deviation defined by its uncertainty. For the resulting distribution of resampled points at each wavelength element, its mean and median are found to be within one standard error of the mean from each other in almost all cases. Given its close proximity to the mean and its robustness against outliers, the median of the combined distribution in each wavelength element is taken as the value of the stacked spectrum at that wavelength. The standard error of the mean of the distribution is taken to be the uncertainty each stacked data point. stack.py is only readily compatible with spectra extracted by MOTES.

Requires: Astropy, Matplotlib, NumPy
Supported Instruments: GMOS-N, GMOS-S

divide.py

v1.0.2

This script divides one 1D spectrum by another. divide.py expects both spectra to have wavelength axes of equal length and be the product of both extraction by MOTES and stacking by stack.py. Typical use of this script is to calibrate a spectrum of a minor planet with that of a solar twin or solar analog to derive the minor planet's reflectance spectrum.

Requires: Astropy, Matplotlib, NumPy

bingrad.py

v1.0.0

This script has two functions. Primarily it is used to bin spectroscopic data to boost its signal-to-noise ratio at the expense of spectral resolution. A binned spectrum can be plotted and/or saved to a new FITS file. The secondary function is to allow the continuum gradient of the spectrum to be measured across a user-defined wavelength range via linear regression. The resulting linear fit can be plotted and its parameters will be printed in the terminal. bingrad.py expects an input spectrum in the format produced by divide.py.

Requires: Astropy, Matplotlib, NumPy, SciPy

License

All scripts in this repo are licensed under GNU GPLv3