[AstroPy] [pywcs] Unit question
mdroe at stsci.edu
Tue Apr 5 08:02:12 EDT 2011
On 04/05/2011 03:16 AM, Ole Streicher wrote:
> Dear Michael,
> Am 04.04.2011 15:45, schrieb Michael Droettboom:
>> I'm having a little trouble following what you are trying to do.
> I am going to write a small program to cut out parts of an 2d/3d image
> based on WCS coordinates and/or wavelength.
> The easy part is now to convert these coordinates into pixel coords
> using pywcs and slicing the required part of the image.
> But the resulting image needs now a new WCS header since the origin may
> have been changed, and I am wondering how one could easily built one.
> For CRVALx I have to calculate the world coordinates of the origin of
> the resulting image within the coordinate system of the primary image,
> in the units defined by CUNITx.
I see. That makes sense. So the user input is in some unit, and you
need to get to the world units used by the existing WCS. The
UnitConverter class with have = input_unit (whatever that may be) and
want = wcs.wcs.cuint[wcs.wcs.spec] should do what you need.
>> To get the units returned by wcs_pix2sky, use wcs.wcs.units[wcs.wcs.spec].
> This is what I needed, thank you (wcs.wcs.cunit). BTW, I would propose
> to implement an iterator there (or as wcs.unit)?
I'm not sure what you mean by having an iterator there. Right now it
returns a list, with one entry for each axis. As the number of axes is
always really small, I'm not sure what advantage an iterator would have.
> Best regards
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
More information about the AstroPy