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

ValueError: Original doppler_convention not set #930

Open
Firestar-Reimu opened this issue Nov 3, 2024 · 6 comments
Open

ValueError: Original doppler_convention not set #930

Firestar-Reimu opened this issue Nov 3, 2024 · 6 comments

Comments

@Firestar-Reimu
Copy link

Firestar-Reimu commented Nov 3, 2024

What is the problem this feature will solve?

I have 2 FITS data cubes, one use VRAD as velocity, the other use VOPT as velocity, I want to convert one velocity to another and write to a new FITS file.

I read fits standard and get:

By convention, the ‘radio’ velocity is given by c(ν0 − ν)/ν0 and the ‘optical’ velocity is given by c(λ − λ0)/λ0.

If I just edit CTYPE3 of Header 1 to VOPT, cube.reproject returns:

ValueError: Original doppler_convention not set

I know that in both headers, the CRVAL3 CRPIX3 CDELT3 have the (almost) same values

but it is necessary to re-calculate the velocities:

VRAD * (λ/λ0) = VOPT, VOPT * (ν/ν0) = VRAD

Header 1

SIMPLE  =                    T / conforms to FITS standard                      
BITPIX  =                  -64 / array data type                                
NAXIS   =                    3 / number of array dimensions                     
NAXIS1  =                  266                                                  
NAXIS2  =                  506                                                  
NAXIS3  =                  933                                                  
OBJECT  = 'HI4PI   '           / The HI 4-PI Survey                             
TELESCOP= 'Effelsberg 100m RT; ATNF Parkes 64-m' / Telescope names              
ORIGIN  = 'AIfA/MPIfR Bonn; ATNF Sydney' / Organisations or Institutions        
REFERENC= 'HI4PI Collaboration 2016' / A&A                                      
RESTFRQ =        1420405751.77                                                  
RESTWAV =       0.211061140541                                                  
WCSAXES =                    3                                                  
CDELT1  = -0.08333333330000001                                                  
CTYPE1  = 'GLON-CAR'                                                            
CUNIT1  = 'deg     '                                                            
CDELT2  =  0.08333333330000001                                                  
CTYPE2  = 'GLAT-CAR'                                                            
CUNIT2  = 'deg     '                                                            
CRPIX1  =                134.0                                                  
CRPIX2  =       133.0000000528                                                  
CRVAL1  =                230.0                                                  
CRVAL2  =                  0.0                                                  
LONPOLE =                  0.0                                                  
LATPOLE =                 90.0                                                  
CRVAL3  =                  0.0                                                  
CRPIX3  =     466.921630003202                                                  
CDELT3  =     1288.21496912415                                                  
CUNIT3  = 'm/s     '                                                            
CTYPE3  = 'VRAD    '                                                            
CNAME3  = 'LSRK radio velocity'                                                 
SPECSYS = 'LSRK    '                                                            
SSYSOBS = 'LSRK    '                                                            
SSYSSRC = 'LSRK    '                                                            
VELOSYS =                  0.0                                                  
ZSOURCE =                  0.0                                                  
BUNIT   = 'K       '                                                            
BPA     =                  0.0                                                  
BMAJ    =               0.2706                                                  
BMIN    =               0.2706                                                  
EQUINOX =               2000.0                                                  
CHECKSUM= 'fnfjfnZhfnfhfnZh'   / HDU checksum updated 2016-09-15T05:24:58       
DATASUM = '3382179965'         / data unit checksum updated 2016-09-15T05:24:58 
END

Header 2

SIMPLE  =                    T / conforms to FITS standard                      
BITPIX  =                  -32 / array data type                                
NAXIS   =                    3 / number of array dimensions                     
NAXIS1  =                  196                                                  
NAXIS2  =                  403                                                  
NAXIS3  =                  447                                                  
SLICE   = '[[(49, 496, None), (1914, 2317, None), (390, 586, None)]]'           
WCSAXES =                    3 / Number of coordinate axes                      
CRPIX1  =       798.5770727918 / Pixel coordinate of reference point            
CRPIX2  =  -161.44939806140894 / Pixel coordinate of reference point            
CRPIX3  =                -48.0 / Pixel coordinate of reference point            
CDELT1  =           -0.0250001 / [deg] Coordinate increment at reference point  
CDELT2  =            0.0250001 / [deg] Coordinate increment at reference point  
CDELT3  =       -201.283594733 / [m/s] Coordinate increment at reference point  
CUNIT1  = 'deg'                / Units of coordinate increment and value        
CUNIT2  = 'deg'                / Units of coordinate increment and value        
CUNIT3  = 'm/s'                / Units of coordinate increment and value        
CTYPE1  = 'GLON-CAR'           / Galactic longitude, plate caree projection     
CTYPE2  = 'GLAT-CAR'           / Galactic latitude, plate caree projection      
CTYPE3  = 'VOPT'               / Optical velocity (linear)                      
CRVAL1  =      213.90250007494 / [deg] Coordinate value at reference point      
CRVAL2  =                    0 / [deg] Coordinate value at reference point      
CRVAL3  =       199802.5500448 / [m/s] Coordinate value at reference point      
LONPOLE =                  0.0 / [deg] Native longitude of celestial pole       
LATPOLE =      88.106401681489 / [deg] Native latitude of celestial pole        
MJDREF  =                  0.0 / [d] MJD of fiducial time                       
SPECSYS = 'LSRK'               / Reference frame of spectral coordinates        
BUNIT   = 'K       '                                                            
END   
@keflavich
Copy link
Contributor

Right, it looks like the cube reader isn't picking up the velocity convention from the header, and it could be. That should be an easy fix.

@Firestar-Reimu
Copy link
Author

Or is there a method that I can reproject just the celestial coordinates, not the velovity coordinates?

@keflavich
Copy link
Contributor

I think you just need to change the target header's RESTFRQ - it's unset, so the velocity isn't translatable to frequency/wavelength

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Nov 4, 2024

OK, setting the RESTFRQ solves the problem, thanks!

it gives me 2 warnings

WARNING: PossiblySlowWarning: This function (<function BaseSpectralCube.reproject at 0x775dd14667a0>) requires loading the entire cube into memory and may therefore be slow. [spectral_cube.utils]
WARNING: No observer defined on WCS, SpectralCoord will be converted without any velocity frame change [astropy.wcs.wcsapi.fitswcs]

But there is another issue: if I have DATA1 which covers -1919km/s ~ 810km/s, and DATA2 covers 114km/s ~ 514km/s

and I want to convert DATA1 to DATA2.header

can the reprojection of DATA1 still cover all the original velocities, that is -1919km/s ~ 810km/s

@keflavich
Copy link
Contributor

No, data2.header specifies the range. It's unclear what you're actually asking for. Do you want data1 reprojected to the same grid as data2? That's what you've done so far.

It seems that maybe you want data1 reprojected to the same velocity resolution as data2, but you do not want them on the same grid? In that case, just modify data2.header to have more pixels (and maybe adjust CRVAL3 or CRPIX3 accordingly).

Right now, it's unclear what your end goal is.

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Nov 5, 2024

For example, data1 is -1000 -900 -800 -700 ... 800 900 1000km/s

data2 is 50 60 70 80 90 100

so when I reproject data1 to data2, data1 should be -1000 -990 ... 50 60 70 80 90 100 ... 990 1000

or is there a keyword which I can only reproject just the celestial coordinates, not the velocity coordinates, so that after reprojection data1 is still -1000 -900 -800 -700 ... 800 900 1000km/s?

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

2 participants