Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

UVOIRSpectra.jl

Utilities for loading extracted ultraviolet, optical, and infrared spectra into SpectrumBase.jl.

This package is under active development. The first release supports extracted JWST x1d and c1d FITS products. It does not yet support spectral images, cubes, ordinary images, or time-series x1dints products.

The loader has been tested with NIRSpec fixed-slit, IFU, and MSA products; NIRISS WFSS and SOSS products; NIRCam WFSS products; and MIRI LRS and MRS products.

Development setup

The current NIRISS WFSS files need the local FITSFiles fixes for one-dimensional TDIM values and scaled unsigned integer columns. From the gsoc directory:

import Pkg

Pkg.activate("UVOIRSpectra")
Pkg.develop(path="../FITSFiles.jl")
Pkg.develop(path="../Spectra.jl")
Pkg.instantiate()

Reading one spectrum

Use read_spectrum when the file contains exactly one spectrum, such as a NIRSpec fixed-slit or extracted IFU x1d product.

using UVOIRSpectra
using SpectrumBase: flux_axis, spectral_axis

spec = read_spectrum("jw07929088001_03102_00010_nrs1_x1d.fits.gz")

spectral_axis(spec)
flux_axis(spec)
spec.errors
spec.quality
spec.instrument
spec.exposure_type

Wavelength and flux units are attached using Unitful. Values are not converted: a FITS wavelength stored as 1.2 with TUNIT = "um" becomes 1.2 μm.

Reading a collection

Use read_spectra whenever a product contains more than one spectrum. This includes multi-source NIRISS and NIRCam WFSS products, as well as NIRISS SOSS products containing multiple spectral orders.

spectra = read_spectra("jw01571-c1071_t000_niriss_f115w-gr150r_c1d.fits")

length(spectra)
spectra[1].source_id
spectra[1].spectral_order
spectra[1].columns

Each element is a SpectrumBase.SingleSpectrum. Source, order, slit, and FITS extension information are stored in its metadata. A source ID may come from either a table column or an HDU header. Non-finite wavelength padding is removed. Rows containing no valid wavelength samples are skipped with one summary warning per file.

Inspecting a product

inspect_product reads FITS headers without loading the science arrays.

info = inspect_product("observation_s3d.fits.gz")

info.product
info.kind
info.instrument
info.exposure_type
info.hdus

Supported products are classified as either :single_spectrum or :spectra_collection. Unsupported cal, s2d, s3d, i2d, rate, rateints, and x1dints files are identified but rejected by the spectrum readers with an ArgumentError.

Tests

The portable test suite generates small FITS products:

import Pkg
Pkg.test()

The optional real-data checks use the files in the GSoC test directory:

UVOIR_SPECTRA_TEST_DATA=/path/to/gsoc/tests \
    julia --project=. test/real_data.jl

These checks cover the major one-dimensional table layouts currently supported by the loader. The FITS files remain outside the package and are not required by Pkg.test().

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors