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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to read in wavelength unit with MUSE data cubes? #2502

Open
ke27whal opened this issue Oct 10, 2023 · 10 comments
Open

Not able to read in wavelength unit with MUSE data cubes? #2502

ke27whal opened this issue Oct 10, 2023 · 10 comments
Labels
bug Something isn't working cubeviz performance Performance related

Comments

@ke27whal
Copy link

ke27whal commented Oct 10, 2023

Two problems

  1. Parsing logic needs fixing, see BUG: Cubeviz to recognize VLT MUSE data聽#2504 for the fix. 馃惐
  2. Performance issue when large cube is loaded into Cubeviz. For example, when I create a second elliptical Subset (there is already a circular one), and then I use Subset Tool to rotate it, it eats up CPU resource and took a very long time (a few minutes) to update but there is no indication that anything is happening anywhere in the app. 馃惐

Jdaviz component

Cubeviz

Description

Hi,

I'm trying to analyze VLT MUSE data cubes and I'm running into a problem where cubeviz is unable to recognize the wavelength units from the fits header. Opening the cube in DS9 allows me to toggle through the different wavelength bins, and looking at the header, the unit is given in CUNIT3='Angstrom.'

I was going to see if this was a display issue by trying to use the unit conversion functionality detailed in the documents, but that option is unavailable to me in the GUI (see screenshot in how to reproduce).

Also, is Cubeviz supposed to lag a bit?

Thanks for your help,
Kelly

How to Reproduce

See screenshot.
github_cubeviz_error

Expected behavior

I expected to be able to have the tab for unit conversion

Browser

No response

Jupyter

jupyter notebook version 7.0.2

Software versions

No response

@ke27whal ke27whal added bug Something isn't working needs-triage Issue opened via template and needs triaging labels Oct 10, 2023
@pllim pllim added the cubeviz label Oct 10, 2023
@pllim
Copy link
Contributor

pllim commented Oct 10, 2023

Thank you for reaching out to us.

unable to recognize the wavelength units from the fits header

Are you able to get anything useful only using specutils? https://specutils.readthedocs.io/en/stable/

from specutils import Spectrum1D

sp = Spectrum1D.read(filename)
sp.spectral_axis  # check the printed unit

is Cubeviz supposed to lag a bit?

Can you please clarify what you were doing when you saw the lag? Is the lag temporary or persistent?

@pllim
Copy link
Contributor

pllim commented Oct 10, 2023

Also to be sure I am not misunderstanding, is there an extra period in your CUNIT3 value? You said CUNIT3='Angstrom.'

@ke27whal
Copy link
Author

Thank you so much for your response!

Trying to read my fits file using specutils throws me the following error:

IORegistryError                           Traceback (most recent call last)

Cell In[11], line 3

      1 from specutils import Spectrum1D

----> 3 sp = Spectrum1D.read('/Users/kewhalen/seyferts_npp/data/ngc0863/CARS_ifu_ngc0863/ADP.2016-06-17T18:47:32.888.fits')#, format='MaNGA cube')

      4 sp.spectral_axis

 

File ~/miniforge3/envs/jdaviz-env/lib/python3.9/site-packages/astropy/nddata/mixins/ndio.py:59, in NDDataRead.__call__(self, *args, **kwargs)

     58 def __call__(self, *args, **kwargs):

---> 59     return self.registry.read(self._cls, *args, **kwargs)

 

File ~/miniforge3/envs/jdaviz-env/lib/python3.9/site-packages/astropy/io/registry/core.py:213, in UnifiedInputRegistry.read(self, cls, format, cache, *args, **kwargs)

    210             path = None

    211             fileobj = args[0]

--> 213     format = self._get_valid_format(

    214         "read", cls, path, fileobj, args, kwargs

    215     )

    217 reader = self.get_reader(format, cls)

    218 data = reader(*args, **kwargs)

 

File ~/miniforge3/envs/jdaviz-env/lib/python3.9/site-packages/astropy/io/registry/base.py:358, in _UnifiedIORegistryBase._get_valid_format(self, mode, cls, path, fileobj, args, kwargs)

    356 if len(valid_formats) == 0:

    357     format_table_str = self._get_format_table_str(cls, mode.capitalize())

--> 358     raise IORegistryError(

    359         "Format could not be identified based on the"

    360         " file name or contents, please provide a"

    361         " 'format' argument.\n"

    362         f"The available formats are:\n{format_table_str}"

    363     )

    364 elif len(valid_formats) > 1:

    365     return self._get_highest_priority_format(mode, cls, valid_formats)

 

IORegistryError: Format could not be identified based on the file name or contents, please provide a 'format' argument.

The available formats are:

      Format      Read Write Auto-identify

----------------- ---- ----- -------------

      6dFGS-split  Yes    No           Yes

    6dFGS-tabular  Yes    No           Yes

    APOGEE apStar  Yes    No           Yes

   APOGEE apVisit  Yes    No           Yes

APOGEE aspcapStar  Yes    No           Yes

            ASCII  Yes    No           Yes

             ECSV  Yes    No           Yes

          HST/COS  Yes    No           Yes

         HST/STIS  Yes    No           Yes

             IPAC  Yes    No           Yes

         JWST c1d  Yes    No           Yes

         JWST s2d  Yes    No           Yes

         JWST s3d  Yes    No           Yes

         JWST x1d  Yes    No           Yes

      MUSCLES SED  Yes    No           Yes

       MaNGA cube  Yes    No           Yes

        MaNGA rss  Yes    No           Yes

     SDSS spPlate  Yes    No           Yes

SDSS-I/II spSpec  Yes    No           Yes

SDSS-III/IV spec  Yes    No           Yes

Subaru-pfsObject  Yes    No           Yes

             iraf  Yes    No           Yes

     tabular-fits  Yes   Yes           Yes

       wcs1d-fits  Yes   Yes           Yes


And, apologies, autocorrect threw the period in there. It's CUNIT3='Angstrom'

@ke27whal
Copy link
Author

It lags on the order for 3-10s whenever I try to use any of the plugin tools. I have had to refresh my page a few times, as well.

@pllim
Copy link
Contributor

pllim commented Oct 11, 2023

I think to effectively debug this, we would need a copy of the data or something equivalent if the original data is not public. Is this from VLT MUSE archive or something? How are we able to get a copy? Thanks.

@pllim
Copy link
Contributor

pllim commented Oct 11, 2023

Thanks! Looks like the cube is a whooping 3 GB. I'll post more when it is done downloading... 馃槄

Filename: ADP.2016-06-17T18_47_32.888.fits
No.    Name      Ver    Type      Cards   Dimensions   Format
  0  PRIMARY       1 PrimaryHDU    1291   ()      
  1  DATA          1 ImageHDU        43   (321, 315, 3682)   float32   
  2  STAT          1 ImageHDU        43   (321, 315, 3682)   float32   

@pllim
Copy link
Contributor

pllim commented Oct 11, 2023

First of all, the slider tool is broken because of the wonky wavelength axis in spectrum viewer. Still investigating why spectral axis won't load. Looks like Cubeviz isn't using Spectrum1D.read after all, so thanks for checking.

Secondly, any tool that results in re-collapsing the cube (e.g., drawing a circle on the image viewer) would be laggy. Otherwise, if I just pan/zoom on the image, I do not see any lag, so please be more specific on what tool you were using and how. Maybe would also be helpful to pull up your OS memory monitoring app to make sure it is not memory swapping. This is because to collapse a 3 GB cube for the spectrum viewer would require pulling in the whole cube into memory; I saw my RAM usage jump a whole 20% during that process on load (and also waiting a long time for it).

@ke27whal
Copy link
Author

Okay, great, thank you for checking.

Ahh, gotcha. Yes, I was trying to draw circles and to select a spectral region so that makes sense. Thanks for clearing that up.

@pllim
Copy link
Contributor

pllim commented Oct 11, 2023

So, I fixed the unit in #2504 (feel free to try it out if you know how to install Jdaviz from an unmerged PR branch). Unfortunately the performance issues are real and not trivial to fix, so I will bring them back to the team and add info to your original post above.

Thank you for reporting this!

@pllim pllim added performance Performance related and removed needs-triage Issue opened via template and needs triaging labels Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cubeviz performance Performance related
Projects
None yet
Development

No branches or pull requests

2 participants