Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can spectrum object be lazy? #1090

Open
pllim opened this issue Oct 11, 2023 · 0 comments
Open

Can spectrum object be lazy? #1090

pllim opened this issue Oct 11, 2023 · 0 comments

Comments

@pllim
Copy link
Member

pllim commented Oct 11, 2023

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 spacetelescope/jdaviz#2502

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

No branches or pull requests

1 participant