Skip to content

Heptazhou/SDSS-SpecViewer

Repository files navigation

SDSS SpecViewer

CI status codecov.io

authors: Dr. Jennifer Li (UIUC) and Meg Davis (UConn, [email protected]), 2021
authors: Pat Hall and Zezhou Zhu (YorkU, [email protected], [email protected]), 2023-2025

This is a multi-epoch spectral viewer for SDSSV-BHM using plotly/dash. The goal is to build a web application that allows quick spectral visualization for SDSSV BHM data. The current version will access the data via url and it takes a few seconds to load the spectra.

Usage: Please see the Getting Started section, below, before launching the tool. To launch the web app, you run the script sdssv_spec_appREMOTE.py as a regular python file. The web app will be at http://127.0.0.1:8050/, which you can open with any web browser.


Getting Started

Authentication

You must have the proper SDSS-V Proprietary Data username and password in the authentication.txt (created upon first run) to use this tool, the program will prompt you to input required authentication if the file does not exist yet. The code will immediately check the authentication upon start up.

Installation

Cloning this repository using Git and/or GitHub Desktop is the best way to install this tool. Doing so will allow you to easily keep up to date with any updates.

For all users, it is recommanded to set this (once):

git config --global pull.rebase true

For macOS users, it is recommanded to do this (once):

mkdir -p ~/.config/git && echo .DS_Store >> ~/.config/git/ignore

Dependencies

Please install the following Python packages to use this tool, with the minimum required versions shown as such. See also the file pixi.toml for a list of recommended package versions with which SpecViewer is guaranteed to work.

  • astropy-base >= 4.3.1
  • dash >= 2.13.0
  • numpy >= 1.21.4
  • plotly >= 5.0.0
  • pyzstd >= 0.15.9
  • requests >= 2.23.0

Note

Python v3.10 or higher is required (status of Python versions).


If you have pixi, you may simply do

pixi run main

to run the tool. Otherwise, see the following.


If you are using conda or mamba, you may run (preferably, within a separate environment):

conda install astropy-base dash numpy plotly pyzstd requests types-requests

Also, to update:

conda update astropy-base dash numpy plotly pyzstd requests types-requests

If you are using pip, you may run (preferably, within a separate environment):

pip install astropy dash numpy plotly pyzstd requests types-requests

Also, to update:

pip install -U astropy dash numpy plotly pyzstd requests types-requests

Then, run this to start the tool:

python sdssv_spec_appREMOTE.py

Keeping up-to-date

The bhm.json.zst compressed dictionary file is the backbone to this tool. (It can be uncompressed using unzstd if desired.) By running the update_dictionaries.jl file, it will look for FITS file(s) (e.g., spAll-lite-master.fits; note: v6_1_1 or higher required) on your machine and update said dictionary file. Runtime with 1 input file was ~50s on AMD Zen 1, or ~30s on AMD Zen 3, FWIW. The dictionary file is not included in this repository itself to avoid issues with large/binary files.

To update bhm.json.zst, install the latest version of Julia, and set environment variable JULIA_NUM_THREADS=auto,auto so you can omit the -t auto argument (read more).

Then, having the FITS files or archive files (each archive should contain only one FITS file, and would be used only if the filename to be extracted does not exist) accessible in the current directory (either hard copies or via symbolic links), run:

julia -t auto update_dictionaries.jl

Alternatively, provide paths as arguments (use -k to keep raw file after compressed):

julia -t auto update_dictionaries.jl [-k] <path/to/file>...

PS: The filename(s) shall match the pattern /\bspall\b.*\.fits(\.tmp)?$/i and not match /\ballepoch\b/i.

User's guide

  • Rest-frame wavelengths appear along the top of the plot and observed-frame wavelengths along the bottom of the plot.
  • Emission-line labels appear above the top of the plot, and their wavelengths are shown with solid vertical lines. Absorption-line labels appear at the bottom of the plot, and their wavelengths are shown with dotted vertical lines. In both cases, the wavelength(s) of the line(s) associated with that label are shown when the cursor hovers over the label.
  • You can upload and add to the display a spectrum from a file with three (and only three) columns: wavelength (or log wavelength), flux, and error. Wavelength units should be in Ang (or log Ang) and flux units in 1E-17 erg/s/cm2/Ang. Space, tab, and comma separated value files should be supported, as should comment lines (that don't start with numbers) at the start of the file. To load such a file, check the "file uploader" box. Note that an SDSS or SDSS-V spectrum must also be loaded for the uploaded spectrum to display.

Wish list of features to be added

  • renormalization of spectra/spectrum (based on specific wavelength or line, or input value)

About

SDSS SpecViewer

Resources

License

Stars

Watchers

Forks

Packages

No packages published