Re: [SciPy-user] FITS images with header-supplied axes?
On Mar 28, 2008, at 8:28 PM, Keflavich wrote:
Is there any plotting routine in scipy / matplotlib that can plot a fits image with correct WCS coordinates on the axes? I know pyfits can load fits files, astLib has routines to interpret header coordinates, and I think you can make the axes different using matplotlib transforms, but is there anything that puts all three together currently available?
Thanks, Adam
Well, we (STScI) recently wrapped WCSLIB to obtain a mapping function between pixel and sky coordinates for python (you can find it as pywcs in astrolib on scipy; that may have been what you were referring to). But I'm not sure you understand what you are asking for with regard to matplotlib. The new transforms stuff should make it much easier to display the sky coordinates in the interactive display. The axis labeling is a different matter. Suppose your image (let's say it's 1Kx1K for the sake of discussion) is rotated 45 degrees with regard to north (either way, it doesn't really matter). What would you expect to see for axis labels? I don't think it is at all obvious how people would want labeling to be done along the edges of the image. I can imagine someone wanting axes or grids superimposed on the image itself, but that's not quite the same thing. Do you want the image rotated so that it is resampled on to RA and Dec and displayed that way? In any event, no we haven't yet done anything to try to integrate all three things. Among other things we wanted to make sure that the api for the wcs info was suitable before doing a lot with it (and in the meantime, Mike is working on rewriting drizzle which is taking a lot of his time). Perry
But I'm not sure you understand what you are asking for with regard to matplotlib. The new transforms stuff should make it much easier to display the sky coordinates in the interactive display. The axis labeling is a different matter. Suppose your image (let's say it's 1Kx1K for the sake of discussion) is rotated 45 degrees with regard to north (either way, it doesn't really matter). What would you expect to see for axis labels? I don't think it is at all obvious how people would want labeling to be done along the edges of the image. I can imagine someone wanting axes or grids superimposed on the image itself, but that's not quite the same thing. Do you want the image rotated so that it is resampled on to RA and Dec and displayed that way?
I was thinking no resampling, just put an RA/DEC grid and fit the image into it as well as it can be. I don't know if it's possible to display rotated pixels, but that would be the most useful behavior in this case. I'm not sure I understand how the transforms would make it easier to display sky coordinates without labeling axes, though. Are you saying that if the image is already sampled in RA/DEC (or whatever coordinate system) space, then it should be easy to display the RA/DEC coordinates on the axes? Thanks, Adam
On Mar 30, 2008, at 12:38 PM, Keflavich wrote:
I was thinking no resampling, just put an RA/DEC grid and fit the image into it as well as it can be. I don't know if it's possible to display rotated pixels, but that would be the most useful behavior in this case.
Just to clarify, do you mean nearest neighbor regridding? It does sound like you mean that you would like to see the image rotated to have north up. Right?
I'm not sure I understand how the transforms would make it easier to display sky coordinates without labeling axes, though. Are you saying that if the image is already sampled in RA/DEC (or whatever coordinate system) space, then it should be easy to display the RA/DEC coordinates on the axes?
The transforms machinery would allow displaying the image in its original orientation and then when the cursor was moved over the image, the displayed x, y coordinates could display RA, DEC instead of pixel coordinates. But if you desire to rotate the image and have it aligned with north, that capability isn't really important. Doing the rotated image needs some tool to do the rotation (quickly presumably rather than a precise mapping) and then display that as part of a larger tool. That would be much more straightforward. But we haven't made such a tool yet. If someone does it first, it sure would be nice to add, at least as part of an astronomy toolkit. Perry
On Mar 31, 7:59 pm, Perry Greenfield <pe...@stsci.edu> wrote:
On Mar 30, 2008, at 12:38 PM, Keflavich wrote:
I was thinking no resampling, just put an RA/DEC grid and fit the image into it as well as it can be. I don't know if it's possible to display rotated pixels, but that would be the most useful behavior in this case.
Just to clarify, do you mean nearest neighbor regridding? It does sound like you mean that you would like to see the image rotated to have north up. Right?
That's correct.
I'm not sure I understand how the transforms would make it easier to display sky coordinates without labeling axes, though. Are you saying that if the image is already sampled in RA/DEC (or whatever coordinate system) space, then it should be easy to display the RA/DEC coordinates on the axes?
The transforms machinery would allow displaying the image in its original orientation and then when the cursor was moved over the image, the displayed x, y coordinates could display RA, DEC instead of pixel coordinates. But if you desire to rotate the image and have it aligned with north, that capability isn't really important. Doing the rotated image needs some tool to do the rotation (quickly presumably rather than a precise mapping) and then display that as part of a larger tool. That would be much more straightforward. But we haven't made such a tool yet. If someone does it first, it sure would be nice to add, at least as part of an astronomy toolkit.
OK, I didn't realize that the transforms work as you describe, I'll have to test that. If I can get something like the tool you described running, I'll post my results here, but I'm going to may slow progress if any. I'm not clear how I would go about making usable paper figures in Python without this capability, though, so what does everyone else do? Just use other tools for figure generation? Re: Nicolas and Tom Is the astropy mailing list active? I've attempted to subscribe but haven't received confirmation or any list e-mails. Otherwise, perhaps just listing things on the wiki is enough, or keeping a list via this group? Adam
participants (2)
-
Keflavich
-
Perry Greenfield