astropy / astropy/specutils

Can spectrum object be lazy?

Open
#1,090 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
204
Forks
135
Avg merge
12h 55m
Merged PRs (30d)
1

Description

I noticed that when I pass in a big flux array, it takes a while to create the Spectrum1D object. I am not even doing anything with it yet, just initializing it. Is it possible for it to be as lazy as possible? If so, is such performance tips documented somewhere?

Example usage

Data file is from http://archive.eso.org/wdb/wdb/adp/phase3_main/query?collection_name=MUSE&version=&object===HE%202302-0857&order_main=wavelmin%2Cfilter%2Cexp_start%2Cexptime%2Corigfile&top=10000

from astropy import units as u
from astropy.io import fits
from astropy.wcs import WCS
from specutils import Spectrum1D

filename = "ADP.2016-06-17T18_47_32.888.fits"  # 3 GB, 2 extensions each (321, 315, 3682) float32
pf = fits.open(filename)
wcs = WCS(pf[1].header)
flux = pf[1].data << u.Unit(pf[1].header["BUNIT"])  # This is fast
sp = Spectrum1D(flux=flux, wcs=wcs)  # Takes a long time

xref https://github.com/spacetelescope/jdaviz/issues/2502

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Spectrum1D(flux=flux, wcs=wcs) construction shown in the issue and reproduce it using the linked 3 GB FITS example. Investigate which initialization steps account for the delay and review the jdaviz issue for related context; done means establishing whether lazy construction is feasible and documenting any supported performance guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.