radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
95 stars 62 forks source link

Issue with cube.to_yt #530

Closed mbhaswati closed 5 years ago

mbhaswati commented 5 years ago

I have some difficulties in visualization of 3d data cubes with yt.

I used the following lines to visualize a FITS datacube that is converted from GILDAS format:

#!/usr/bin/env python
import numpy as np
from spectral_cube import SpectralCube
import astropy.units as u
from astropy.utils import data
import yt
cube = SpectralCube.read(data.fits', format='fits')
print(cube)
ytcube = cube.to_yt(spectral_factor=0.75, nprocs=None)

And I get the following error

Traceback (most recent call last):
  File "./view.py", line 13, in <module>
    ytcube = cube.to_yt()
  File "/usr/local/lib/python2.7/dist-packages/spectral_cube/spectral_cube.py", line 1948, in to_yt
    spectral_factor=spectral_factor, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/yt/data_objects/static_output.py", line 256, in __new__
    obj.__init__(filename, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'spectral_factor'

The header of the FITS file is:

# HDU 0 in g287p84_OI_0p5kms.fits:
SIMPLE  =                    T         /                                        
BITPIX  =                   32         /                                        
NAXIS   =                    3         /                                        
NAXIS1  =                   77         /                                        
NAXIS2  =                   59         /                                        
NAXIS3  =                  150         /                                        
BSCALE  =  0.3835487518700E-06         /                                        
BZERO   = -0.1763357543945E+03         /                                        
BLANK   =           2147483647         / Blanking value                         
DATAMIN = -0.1000000427246E+04         /                                        
DATAMAX =  0.6473285522461E+03         /                                        
BUNIT   = 'K (Ta*)     '               /                                        
CTYPE1  = 'RA---GLS    '               /                                        
CRVAL1  =  0.1614793800000E+03         /                                        
CDELT1  = -0.1027777759626E-02         /                                        
CRPIX1  =  0.3598832945397E+02         /                                        
CROTA1  =  0.0000000000000E+00         /                                        
CTYPE2  = 'DEC--GLS    '               /                                        
CRVAL2  = -0.5995463900000E+02         /                                        
CDELT2  =  0.1027777759626E-02         /                                        
CRPIX2  =  0.3559428927095E+02         /                                        
CROTA2  =  0.0000000000000E+00         /                                        
CTYPE3  = 'VRAD        '               /                                        
CRVAL3  = -0.2500000000000E+05         /                                        
CDELT3  =  0.5000000000000E+03         /                                        
CRPIX3  =  0.7600000000000E+02         /                                        
CROTA3  =  0.0000000000000E+00         /     
keflavich commented 5 years ago

Could you add which version of yt you're using?

Also, in general on github, you can quote code blocks with triple-backticks (these: ```) to format the code.

mbhaswati commented 5 years ago

 yt-3.5.0

I just downloaded and installed yt for the first time.

On Tuesday 05 February 2019 05:19 AM, Adam Ginsburg wrote:

Could you add which version of |yt| you're using?

Also, in general on github, you can quote code blocks with triple-backticks (these: ```) to format the code.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/radio-astro-tools/spectral-cube/issues/530#issuecomment-460459559, or mute the thread https://github.com/notifications/unsubscribe-auth/AtJYxv27FolW6LAQcHUvTV2XyC1_nGpgks5vKMb2gaJpZM4aiRar.

-- ######################################################################### Dr Bhaswati Mookerjea Phone: +91 22 22782294 Associate Professor Department of Astronomy & Astrophysics Tata Institute of Fundamental Research Homi Bhabha Road, Colaba Mumbai 400005 #########################################################################

keflavich commented 5 years ago

This is a bug. yt has changed their FITS interface such that we need to change the type of yt object we create. I'm working on implementing the fix.

keflavich commented 5 years ago

531 contains a fix. Try it out when you get a chance

keflavich commented 5 years ago

Closed by #531