[AstroPy] Grid lines on FITS images

Michael Droettboom mdroe at stsci.edu
Wed Jun 3 10:34:12 EDT 2015


On 06/03/2015 10:20 AM, Demitri Muna wrote:

> Hi,
>
> On Jun 1, 2015, at 12:20 PM, Thomas Robitaille 
> <thomas.robitaille at gmail.com <mailto:thomas.robitaille at gmail.com>> wrote:
>
>> I think that WCSAxes (http://wcsaxes.readthedocs.org 
>> <http://wcsaxes.readthedocs.org/>) will do what you
>> need? Let me know if you have any issues using it.
>
> Thanks Tom. I went through the documentation/tutorial and created a 
> sample script. It doesn't do exactly what I'm looking for - as far as 
> I can tell. I'm using matplotlib.patches.Polygon to define my polygon, 
> supplying a world transform based on the FITS header.
>
> I don't know how the underlying drawing mechanism works. If it is 
> taking the world coordinates that I apply, e.g. the four corners of a 
> polygon, converting them to pixel coordinates, and then drawing 
> straight lines on the canvas between them, then they are not proper 
> representations as they are not following great circles. If the 
> transform is applied to each pixel drawn, then it might be. My (pure) 
> guess is that it's doing the former. (I would like to test this, but 
> that will have to wait until after SciCoder.)

Can’t speak specifically for wcsaxes, but for “raw” matplotlib it would 
do the former. There is, however, a quick-and-dirty way to interpolate 
your polygon using a private method intended for the built-in geo 
projections in matplotlib. If |poly| is your |Polygon| object and |N| is 
the number of line segments to create for each existing line segment:

|    poly._path = poly._path.interpolated(N)
|

On-the-fly interpolation for projections has been on the TODO list for 
matplotlib for many years. It just hasn’t got done (and will probably 
require a C++ implementation to be performant enough).

Mike

>
> I think in the end PyAST will do what I need, but I may still use 
> parts of WSCAxes.
>
> Thanks,
> Demitri
>
> _________________________________________
> Demitri Muna
>
> Department of Astronomy
> Ohio State University
>
> http://trillianverse.org
> http://scicoder.org
>
>
>
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150603/e814ebb3/attachment.html>


More information about the AstroPy mailing list