Spectra.jl

Utilities for interfacing with astronomical spectra and synthetic spectra libraries.

Installation

From the REPL, press ] to enter Pkg mode

pkg> add https://github.com/JuliaAstro/Spectra.jl

julia> using Spectra

Quick Start

Here is a quick demo of some of our features.

Spectrum construction

julia> using Spectra, FITSIO, Unitful, UnitfulAstro, Plots

julia> # fitsurl = "https://dr14.sdss.org/optical/spectrum/view/data/format=fits/spec=lite?plateid=1323&mjd=52797&fiberid=12";

julia> # f = FITS(HTTP.get(fitsurl).body)

julia> f = FITS("sdss.fits")
File: sdss.fits
Mode: "r" (read-only)
HDUs: Num  Name     Type
      1             Image
      2    COADD    Table
      3    SPECOBJ  Table
      4    SPZLINE  Table

julia> wave = (10 .^ read(f[2], "loglam"))u"angstrom";

julia> flux = (read(f[2], "flux") .* 1e-17)u"erg/s/cm^2/angstrom";

julia> spec = spectrum(wave, flux)
SingleSpectrum(Quantity{Float32, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Quantity{Float64, 𝐌 𝐋^-1 𝐓^-3, Unitful.FreeUnits{(Å^-1, erg, cm^-2, s^-1), 𝐌 𝐋^-1 𝐓^-3, nothing}})
  spectral axis (3827,): 3815.0483f0 Å .. 9206.613f0 Å
  flux axis (3827,): 2.182261505126953e-15 erg Å^-1 cm^-2 s^-1 .. 1.7559197998046877e-15 erg Å^-1 cm^-2 s^-1
  meta: Dict{Symbol, Any}()

julia> plot(spec);

For constructing higher dimensional spectra, e.g., for echelle or IFU spectra, see the docstrings for EchelleSpectrum and IFUSpectrum, respectively.

Citation

If you found this software or any derivative work useful in your academic work, I ask that you please cite the code.

TODO

Contributing

Please see Contributing for information on contributing and extending Spectra.jl.