[AstroPy] Running wcs_pix2world for all image pixels

Maik Riechert maik.riechert at arcor.de
Wed Oct 16 09:58:15 EDT 2013


Hi Tom,

That's exactly what I needed. Thanks!

It takes around 3s on my machine for a 4200x2800 image. Is that to be 
expected or are there some speedup tricks?

Maik

On 16/10/13 15:15, Thomas Robitaille wrote:
> Hi Maik,
>
> Someone asked a very similar question just yesterday on GitHub:
>
> https://github.com/astropy/astropy/issues/1587
>
> In short, the solution in your case is:
>
> NAXIS1 = 4256
> NAXIS2 = 2832
> x = np.arange(NAXIS1)
> y = np.arange(NAXIS2)
> X, Y = np.meshgrid(x, y)
> ra, dec = wcs.wcs_pix2world(X, Y, 0)
>
> Any luck?
>
> Tom
>
>
>
>
> On 16 October 2013 14:48, Maik Riechert <maik.riechert at arcor.de> wrote:
>> Hi,
>>
>> I'm quite new to python and astropy and got stuck at the following which
>> probably is extremely easy to do.
>>
>> I created a WCS object out of a FITS header and wanted to get the RA/Dec
>> coordinates of each image pixel. I tried:
>>
>> w.wcs_pix2world(np.ndindex(4256, 2832), 0)
>>
>> where 4256x2832 are the image dimensions. This returns 'ValueError:
>> object of too small depth for desired array'. I was trying to avoid
>> allocating an array with all pixel coordinates and thought an iterator
>> would work too.
>>
>> What would you recommend for my case (translating every pixel)?
>>
>> Cheers and thanks,
>> Maik
>>
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy




More information about the AstroPy mailing list