Repository navigation
Lookup-table WCS for irregular spectral sampling doesn't look up #5462
Description
Bearing in mind this may be a) not implemented or b) user error, I seem to be having difficulties expressing the -TAB coordinate type. I have a (4096, 4096, 19) (in FITS axes order) datacube with 19 planes representing simulated observations through different filters.
I want to assign a bogus WCS so that I can visualize angular dimensions on each plane in ds9 or similar. It occurred to me that the third dimension actually is wavelength, and I think I can represent it in FITS WCS using a lookup table. However, when I try to do mywcs.all_pix2world I get unexpected behavior that might even be uninitialized memory (i.e. calling the same function twice gives two different results for the wavelength axis).
I call mywcs.all_pix2world([[2048, 2048, i],], 0) where i is in [0, 19). The first two dimensions come out as I expect (that is, 0, 0) but the last is usually 0 and sometimes a very small float value (like 1e-322):
>>> mywcs.all_pix2world([[2048, 2048, 2],], 0)
array([[ 5.55555555e-005, 5.55555556e-005, 1.58101007e-322]])Here's my WCS header:
WCSAXES = 3 / Number of coordinate axes
CRPIX1 = 2048.0 / Pixel coordinate of reference point
CRPIX2 = 2048.0 / Pixel coordinate of reference point
CRPIX3 = 0.0 / Pixel coordinate of reference point
CDELT1 = 5.5555555555556E-05 / [deg] Coordinate increment at reference point
CDELT2 = 5.5555555555556E-05 / [deg] Coordinate increment at reference point
CDELT3 = 1.0 / [m] Coordinate increment at reference point
CUNIT1 = 'deg' / Units of coordinate increment and value
CUNIT2 = 'deg' / Units of coordinate increment and value
CUNIT3 = 'm' / Units of coordinate increment and value
CTYPE1 = 'RA---TAN' / Right ascension, gnomonic projection
CTYPE2 = 'DEC--TAN' / Declination, gnomonic projection
CTYPE3 = 'WAVE-TAB' / Vacuum wavelength
CRVAL1 = 0.0 / [deg] Coordinate value at reference point
CRVAL2 = 0.0 / [deg] Coordinate value at reference point
CRVAL3 = 0.0 / [m] Coordinate value at reference point
PS3_0 = 'FILTERS' / Coordinate transformation parameter
PS3_1 = 'lambda_eff' / Coordinate transformation parameter
LONPOLE = 180.0 / [deg] Native longitude of celestial pole
LATPOLE = 0.0 / [deg] Native latitude of celestial pole
RADESYS = 'ICRS' / Equatorial coordinate system
Here's the code to build it up:
mywcs = wcs.WCS(fobj=hdulist, naxis=3)
pixel_scale = 0.2
mywcs.wcs.ctype = ['RA---TAN', 'DEC--TAN', 'WAVE-TAB']
mywcs.wcs.cunit = ['deg', 'deg', 'm']
mywcs.wcs.cdelt = [
pixel_scale / 60 / 60,
pixel_scale / 60 / 60,
1
]
mywcs.wcs.crpix = [2048, 2048, 0]
mywcs.wcs.crval = [0, 0, 0]
mywcs.wcs.set_ps([(3, 0, 'FILTERS'),
(3, 1, 'lambda_eff')])
mywcs.to_header()
Here's the header of the extension FILTERS:
XTENSION= 'BINTABLE' / binary table extension
BITPIX = 8 / 8-bit bytes
NAXIS = 2 / 2-dimensional binary table
NAXIS1 = 86 / width of table in bytes
NAXIS2 = 19 / number of rows in table
PCOUNT = 0 / size of special data area
GCOUNT = 1 / one data group (required keyword)
TFIELDS = 8 / number of fields in each row
EXTNAME = 'FILTERS ' / name of this binary table extension
TTYPE1 = 'filter ' / label for field
TFORM1 = '30A ' / format of field
TUNIT1 = 'Filter name'
TTYPE2 = 'lambda_eff' / label for field
TFORM2 = 'D ' / format of field
TUNIT2 = 'm '
TTYPE3 = 'ewidth_lambda' / label for field
TFORM3 = 'D ' / format of field
TUNIT3 = 'm '
TTYPE4 = 'ewidth_nu' / label for field
TFORM4 = 'D ' / format of field
TUNIT4 = 'Hz '
TTYPE5 = 'L_lambda_eff0' / label for field
TFORM5 = 'D ' / format of field
TUNIT5 = 'W/m '
TTYPE6 = 'AB_mag0 ' / label for field
TFORM6 = 'D ' / format of field
TTYPE7 = 'L_lambda_eff_nonscatter0' / label for field
TFORM7 = 'D ' / format of field
TUNIT7 = 'W/m '
TTYPE8 = 'AB_mag_nonscatter0' / label for field
TFORM8 = 'D ' / format of field
I'm following (or trying to follow) the explanation of the -TAB standard in Griesen et al. 2006 (PDF). (more links)
Activity
astrofrog commentedon Apr 20, 2017
Note that this is also discussed in #2362 - astropy doesn't currently support -TAB I think.
Cadair commentedon Apr 20, 2017
This is a very important feature for ground based solar physics datasets, I would very much appreciate it working!
astrofrog commentedon Apr 20, 2017
@Cadair - do you have example FITS spectra that use the
-TABconvention?Cadair commentedon Apr 20, 2017
No, they use something that should be represented as a non-uniformly spaced TAB but they don't actually follow the standard that would be loopy.
nden commentedon Apr 20, 2017
GWCScan do thisCadair commentedon Apr 20, 2017
@nden yeah GWCS is my current plan. In fact I need to talk GWCS with you at some point.
nden commentedon Apr 20, 2017
@Cadair Email me if you want to set up a hangout or just email me your questions.
Cadair commentedon Apr 20, 2017
@nden will do. Need to get my cards in order first :D
josePhoenix commentedon Apr 20, 2017
@nden could you elaborate?
nden commentedon Apr 20, 2017
gwcs is meant to be flexible in terms of what transforms it uses and hence has a different than FITS WCS representation. In general the WCS pipeline is represented as a list of steps where each step contains a starting coordinate frame and the transform to the next frame. The simplest case using a a Loookup table would be
where LookupTable() is an instance of `modeling.models.Tabulr2D().
I guess I should write a complete example of this in the GWCS documentation showing also how to save this to a file.
parejkoj commentedon Oct 4, 2019
Is there a gwcs issue tracking this one? It was not immediately obvious from the gwcs docs how to create a gwcs-based
-TABFITS WCS.timj commentedon Oct 31, 2019
LSST are trying to generate some data using
-TABso we have test files if people tell me where you would like one uploaded. wcsLib also has an example FITS file using-TABfor multiple axes.mcara commentedon Nov 21, 2019
In PR #9641 I implemented support for the
-TABalgorithm in FITS WCS defined in WCS Paper III.mcara commentedon Jan 16, 2020
To those (still) interested: #9641 has been merged and
WCS-TABshould now be supported inastropy.wcs. Please give it a try.pllim commentedon Jan 16, 2020
Closing as solved. Thanks, @mcara !