Skip to content

Add host galaxy spectrum download feature - #437

Open
dhvanildesai wants to merge 17 commits into
scimma:mainfrom
dhvanildesai:dhvanil-spectra
Open

Add host galaxy spectrum download feature#437
dhvanildesai wants to merge 17 commits into
scimma:mainfrom
dhvanildesai:dhvanil-spectra

Conversation

@dhvanildesai

@dhvanildesai dhvanildesai commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Resolves #432

Draft PR — not ready for merge. Opening for design feedback, especially on workflow placement and model structure.

Summary

Adds host galaxy spectrum download functionality to the Blast pipeline. Archival spectra are fetched from SPARCL (DESI-DR1, SDSS-DR17, BOSS-DR17) with a NED fallback, stored as FITS files via a new HostSpectrum model. The downstream goal is to feed these spectra into STARLIGHT for stellar population fitting (something like HostSpectrumFitting).

Changes

New model: HostSpectrum

  • Stores one spectrum per host galaxy as a FITS file in ObjectStore
  • Linked to Host via ForeignKey
  • Tracks source (DESI/SDSS/BOSS/NED), retrieval status, and other metadata

New pipeline: fetch_host_spectrum() (app/host/host_spectrum.py)

  • Queries SPARCL with a unified interface across DESI-DR1, SDSS-DR17, BOSS-DR17 in priority order
  • Falls back to NED if SPARCL returns no results

New task: host_spectrum_download

  • Wired into the main workflow after host_information and alongside mwebv_host, global_aperture_construction, local_aperture_photometry

Workflow placement (feedback please)

group(
    mwebv_host.si(transient_name),
    host_spectrum_download.si(transient_name),   # <-- placed here
    chain(
        global_aperture_construction.si(transient_name),
        ...
    ),
    chain(
        local_aperture_photometry.si(transient_name),
        ...
    ),
),

Not sure if this is the right place in the chain — flagging for review.

Bug Fix

TaskLock name mismatch in query_sdss() (app/host/host_utils.py)

The SDSS query lock was being acquired under one name and released under a different one.

  • Before: TaskLock.objects.release_lock('sdss_query') (lowercase)
  • After: TaskLock.objects.release_lock('SDSS_query') (matches acquire)

Next steps for me

@djones1040

Copy link
Copy Markdown
Collaborator

A couple additional to-do things we discussed today:
-> test NED download and FITS formatting. Ideally would be consistent w/ SPARCL format when saved.
-> place in workflow after host information
-> consider adding a "location" entry in the table indicating whether the spectrum is at the host center or the SN location (otherwise this could be added in the message field perhaps, with RA/dec info also)

And future feature requests to enable spectra in blast will include:
-> spectra downloadable via the API
-> allow users to upload custom spectra in some format
-> add spectral plotting, include PNG generation in the workflow

@dhvanildesai

Copy link
Copy Markdown
Collaborator Author

As of commit 0a04198, I have added the generation and display of the host spectrum plot on the transient page under the SED plot, done in the same way as the SED plot. The layout of the page might need to be revisited because the alignment and blank spaces are a bit awkward now.
Page_layout_example

This resolves Issue #433.

For now, I have commented out the download of spectra from NED because it is a very heterogenous dataset and homogenizing them all for plotting and the future spectral fitting might be a headache. The code currently only queries SPARCL for DESI and SDSS spectra, which are returned and placed in a uniform fits format.

I have also bumped the Python version from 3.11 to 3.13 in .readthedocs.yml, so now the Docs build is successful in Github.

Next steps will be to integrate spectral fitting into the workflow, but I will open a new Issue and PR for that.

@dhvanildesai
dhvanildesai marked this pull request as ready for review July 30, 2026 07:28
@dhvanildesai dhvanildesai changed the title WIP: Add host galaxy spectrum download feature Add host galaxy spectrum download feature Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding host spectra download in the transient workflow

3 participants