question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

1D wcs transformations not returning single array

See original GitHub issue

The documentation for wcs transformations state that the all_world2pix, etc, operations return a single array if the input is a single array. However, currently, they return a list of length 1 with the single array of pixel coordinates (in the case of all_world2pix/world_to_pixel):

In [6]: my_wcs = fitswcs.WCS(header={'CDELT1': 1, 'CRVAL1': 6562.8, 'CUNIT1': 'Angstrom', 'CTYPE1': 'WAVE', 'RESTFRQ': 1400000000, 'CRPIX1': 25})

In [7]: my_wcs.world_to_pixel(np.arange(10) * u.nm)
Out[7]:
[array([-6538.8, -6528.8, -6518.8, -6508.8, -6498.8, -6488.8, -6478.8,
        -6468.8, -6458.8, -6448.8])]

This is also inconsistent with the current GWCS interface that returns a single array of coordinates.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
astrofrogcommented, May 3, 2019

Relating to some of the discussion above, I’m not interested in changing the default behavior of the ‘native’ methods for GWCS and FITS-WCS, just the APE 14 API - which I think is still fine to do since it was new in 3.1.

1reaction
astrofrogcommented, May 3, 2019

Thinking about this some more, I’d be ok with returning variables not in a list/tuple in the single coordinate case, but this means that chaining as:

wcs2.pixel_to_world(*wcs1.world_to_pixel(...))

won’t work. One way around this is to say that pixel_to_world and world_to_pixel should be able to accept a tuple, and in this case, it should auto-expand it, so that we could then do:

wcs2.pixel_to_world(wcs1.world_to_pixel(...))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for astropy.wcs.wcs
RETURNS ('pixel coordinates', 8)} Notes ----- The order of the axes for the input world array is determined by the ``CTYPEia`` keywords in...
Read more >
Shared Python interface for World Coordinate Systems
The WCS class implements what is considered the most common 'standard' for representing world coordinate systems in FITS files, but it cannot represent ......
Read more >
Tutorial wcs module — Kapteyn Package (home)
Module celestial provides a rotation matrix for sky transformations and is more or less embedded in wcs , so (for standard work) there...
Read more >
Home · WCS.jl - JuliaAstro
There are many ways to utilize WCS transformations. Let's make one for a 2-dimensional array (like an image) from scratch. ... Now we...
Read more >
astropy.wcs.wcs — Astropy v0.4.2
`wcslib`_ WCS transformation (by a `~astropy.wcs. ... The number of coordinate axes in the transformation is not determined directly from the ``NAXIS`` ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found