A simple tool to manipulate and visualize UV/optical/NIR spectra for astronomical research.
Project description
specbox
A simple tool to manipulate and visualize UV/optical/NIR spectra for astronomical research.
Documentation
Online documentation is hosted on Read the Docs: https://specbox.readthedocs.io/en/latest/index.html
Citing
Zenodo will automatically archive GitHub Releases for this repository once the GitHub↔Zenodo integration is enabled. After the first release is published, add the Zenodo DOI badge above and cite the DOI.
GitHub can also display citation metadata from CITATION.cff.
License
GPLv3. See LICENSE.
Installation
Dependencies
numpyscipyastropypyqtgraphPySide6specutilsmatplotlibpandaspyarroworfastparquet(optional, for reading parquet spectra tables)requestspillow(PIL)astroquery
To install the latest version of specbox, run the following command in your terminal:
git clone https://github.com/rudolffu/specbox.git
# or git clone https://gitee.com/rudolffu/specbox.git
cd specbox
python -m pip install .
Usage
Main classes and functions
The main classes and functions of specbox are:
basemodule.py:
SpecLAMOSTandSpecSDSS: classes to read and manipulate spectra from the LAMOST and SDSS surveys, respectively.SpecIRAF: class to read and manipulate spectra from the IRAF format.SpecPandasRow: generic reader for "table-of-spectra" files readable by pandas (parquet/csv/feather/...), where each row stores arrays (e.g. wavelength/flux/ivar).SpecSparcl: SPARCL parquet/table reader (e.g., for filesparcl_spectra.parquet). Common metadata columns includedata_release,targetid, and (optional)euclid_object_idfor Euclid overlay.
qtmodule.py:
PGSpecPlot: class to plot spectra in apyqtgraphplot.PGSpecPlotApp: class to create apyqtgraphplot with aQApplicationinstance.PGSpecPlotThread: class to create apyqtgraphplot in a thread.
Examples
Plotting a spectrum from the LAMOST survey
from specbox import SpecLAMOST
spec = SpecLAMOST('input_file.fits')
spec.plot()
# Smooth the spectrum
spec.smooth(5, 3, inplace=False)
Reading a SPARCL parquet spectra table (one row per spectrum)
from specbox.basemodule import SpecSparcl
# ext is a 1-based row index (ext=1 -> first row)
sp1 = SpecSparcl("sparcl_spectra.parquet", ext=1)
sp1.plot()
Run a PGSpecPlotThread for visual inspection of a list of spectra
from specbox import SpecLAMOST
from specbox.qtmodule import PGSpecPlotThread
from glob import glob
basepath = 'lamost_spec/fits_files/'
flist = glob(basepath+'*fits.gz')
flist.sort()
flist = flist[0:60]
a = PGSpecPlotThread(speclist=flist, SpecClass=SpecLAMOST, output_file='vi_output_test60.csv')
a.run()
Run a viewer over a multi-row parquet file (SPARCL/table-of-spectra)
from specbox.basemodule import SpecSparcl
from specbox.qtmodule import PGSpecPlotThreadEnhanced
viewer = PGSpecPlotThreadEnhanced(
spectra="sparcl_spectra.parquet",
SpecClass=SpecSparcl,
# Optional: overlay Euclid spectrum when the parquet has `euclid_object_id`
# and the Euclid combined FITS uses that ID as `EXTNAME`.
euclid_fits="COMBINED_EUCLID_SPECS.fits",
output_file="sparcl_vi_results.csv",
z_max=6.0,
load_history=True,
)
viewer.run()
Notes:
- Results CSV includes
targetidanddata_release(when available from the input table). - The enhanced viewer has a
Save PNGbutton that writes screenshots to./saved_pngs/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file specbox-1.0.0rc1.tar.gz.
File metadata
- Download URL: specbox-1.0.0rc1.tar.gz
- Upload date:
- Size: 395.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da7e8170da14aba63f2b7644aa36fb7e3b99bb25d15637fe8d6e870eb44c5faf
|
|
| MD5 |
b0d3a7e087a17be6c7346e16f481720b
|
|
| BLAKE2b-256 |
e6be0b0168dae350d92b73f8fd90caebfa52656a5b47588d6a50b4f00c351b93
|
Provenance
The following attestation bundles were made for specbox-1.0.0rc1.tar.gz:
Publisher:
python-publish.yml on rudolffu/specbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
specbox-1.0.0rc1.tar.gz -
Subject digest:
da7e8170da14aba63f2b7644aa36fb7e3b99bb25d15637fe8d6e870eb44c5faf - Sigstore transparency entry: 928241090
- Sigstore integration time:
-
Permalink:
rudolffu/specbox@c4b88719d13e9d3da3f8c8ef46cc24cc6d9d45bc -
Branch / Tag:
refs/tags/v1.0.0rc1 - Owner: https://github.com/rudolffu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c4b88719d13e9d3da3f8c8ef46cc24cc6d9d45bc -
Trigger Event:
release
-
Statement type:
File details
Details for the file specbox-1.0.0rc1-py3-none-any.whl.
File metadata
- Download URL: specbox-1.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 397.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6365432a07175981caf894ff0e00a3344aca01648bd4ed0ad1d0e029ac9de5df
|
|
| MD5 |
8b394b872e291ac1887f4e3f4b4d3100
|
|
| BLAKE2b-256 |
b03e0aa245ed2814506f4e3e5cc9198d2627f850f2d49e992f5081b379f9a456
|
Provenance
The following attestation bundles were made for specbox-1.0.0rc1-py3-none-any.whl:
Publisher:
python-publish.yml on rudolffu/specbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
specbox-1.0.0rc1-py3-none-any.whl -
Subject digest:
6365432a07175981caf894ff0e00a3344aca01648bd4ed0ad1d0e029ac9de5df - Sigstore transparency entry: 928241092
- Sigstore integration time:
-
Permalink:
rudolffu/specbox@c4b88719d13e9d3da3f8c8ef46cc24cc6d9d45bc -
Branch / Tag:
refs/tags/v1.0.0rc1 - Owner: https://github.com/rudolffu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c4b88719d13e9d3da3f8c8ef46cc24cc6d9d45bc -
Trigger Event:
release
-
Statement type: