0 votes
by (120 points)
Is there a way to get a FITS (or VOTable) file for an co-added merged spectrum of a given target by ID?

For example, I'm looking at this spectrum:

https://www.legacysurvey.org/viewer/desi-spectrum/edr/targetid39628427912810449

and I'd like to get it as a FITS or VOTable (with all the corresponding metadata including LSF width).

1 Answer

0 votes
by (690 points)

Unfortunately the interactive viewer does not (yet?) have a "click to download..." feature.  Your simplest option might be to use the SPARCL server at NOIRLab; see https://astrosparcl.datalab.noirlab.edu and https://github.com/astro-datalab/notebooks-latest/blob/master/04_HowTos/SPARCL/How_to_use_SPARCL.ipynb for info and examples.

For this particular case (and using python), you would install sparcl with

pip install sparclclient

and then get the target with
from sparcl.client import SparclClient
client = SparclClient()
    
spectra = client.retrieve_by_specid([39628427912810449,],
    include=['wavelength', 'flux', 'ivar', 'model', 'wave_sigma'])
spec = spectra.records[0]
# example plotting
import matplotlib.pylab as plt
plt.plot(spec.wavelength, spec.flux)
plt.plot(spec.wavelength, spec.model)
plt.show()
You can use the data in the spec object to save into a fits file, but we don't yet provide an immediate "just give me a fits file for this object" tool.  The sparcl notebook above also has examples for how to query by other parameters like ra,dec if you don't already know the targetid.
For the spectra metadata, the only way I've found to discover the options is to request something that doesn't exist (like "lsf") and then it will print a helpful error message with what you can request:

BadInclude: [BADINCL] The INCLUDE list (flux,ivar,lsf,model,wavelength) contains invalid data field names for Data Sets (BOSS-DR16,DESI-EDR,SDSS-DR16). Unknown fields are: lsf. Available fields are: data_release, datasetgroup, dateobs, dateobs_center, dec, dirpath, exptime, extra_files, filename, filesize, flux, instrument, ivar, mask, model, ra, redshift, redshift_err, redshift_warning, site, sparcl_id, specid, specprimary, spectype, survey, targetid, telescope, updated, wave_sigma, wavelength, wavemax, wavemin.

Other options

The underlying DESI file that contains the original spectrum is https://data.desi.lbl.gov/public/edr/spectro/redux/fuji/healpix/sv3/bright/103/10378/coadd-sv3-bright-10378.fits, but that is inconveniently large to download just to get a single spectrum [1.4GB], and it requires downloading a large redshift catalog like https://data.desi.lbl.gov/public/edr/vac/edr/zcat/fuji/v1.0/zall-pix-edr-vac.fits to map which SURVEY (sv3) and PROGRAM (bright) go with that target, and some ra,dec -> healpix (nested nside=64) wrangling to get the healpixel (10378), which is admittedly a pain.
Another user-provided option is https://github.com/segasai/desi_retriever/tree/master/py/desi_retriever, which can download only the subset of the spectra file you need, though I think that doesn't support public-access to EDR itself (the author is a DESI collaborator and uses it for fetching proprietary data...).
Welcome to DESI Data Q&A, where you can ask questions and receive answers about Dark Energy Spectroscopic Instrument (DESI) data from other members of the community.
...