<div dir="ltr"><div><div>I think this should be part of the fits verification, not any thing else. This should be easy to do as an additional check. <br><br></div>I'll send a note to the fitsio people as well.<br><br></div>
Paul<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 1, 2013 at 5:43 PM, Perry Greenfield <span dir="ltr"><<a href="mailto:stsci.perry@gmail.com" target="_blank">stsci.perry@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">At the very least, there should be a easy-to-use test of the supplied inverse to see how accurately it round trips, and a means of specifically using an iterative inverse based on the forward transform, even if an inverse has been provided.<br>

<span class="HOEnZb"><font color="#888888"><br>
Perry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Nov 1, 2013, at 1:40 PM, David Berry wrote:<br>
<br>
> I've seen several SIP headers where the inverse transformation given by the AP* BP* headers is a poor inverse of the forward transformation given by the A* B* headers. In fact this issue was discussed recently on the astropy list (subject "Running wcs_pix2world for all image pixels") in the context of a header presented by Maik Riechert, which showed a similar problem. From that case I came to the conclusion that astropy ignroes the AP/BP headers and creates its own inverse transformation based on the forward transformation - maybe I was wrong.<br>

><br>
> For what it's worth, pyast does in fact do this - so it should always provide a good inverse for a SIP header.<br>
><br>
> David<br>
><br>
><br>
> On 1 November 2013 11:56, Michael Droettboom <<a href="mailto:mdroe@stsci.edu">mdroe@stsci.edu</a>> wrote:<br>
> On 10/31/2013 08:08 PM, Jacob Vanderplas wrote:<br>
> > Hello,<br>
> > I'm working on a problem that requires the inversion of SIP<br>
> > corrections: that is, I have points in world coordinates that I want<br>
> > to project onto an image plane.<br>
> ><br>
> > My FITS header contains both the (A_p_q, B_p_q) coefficients for the<br>
> > forward transformation, as well as the (AP_p_q, BP_p_q) required for<br>
> > the backward transformation, according to the Shupe et al 2005<br>
> > reference.<br>
> ><br>
> > The astropy WCS object has methods sip_foc2pix() and sip_pix2foc(),<br>
> > which appeared to be what I needed, but these don't seem to actually<br>
> > invert each other. That is:<br>
> ><br>
> >>>> from astropy.wcs import WCS<br>
> >>>> wcs = WCS(header)<br>
> >>>> Xpix = [[1, 1]]<br>
> >>>> Xfoc = wcs.sip_pix2foc(Xpix, 0)<br>
> >>>> print wcs.sip_foc2pix(Xfoc, 0)<br>
> > [[ 1.2522118   1.74039233]]<br>
> ><br>
> > I would have expected this to recover the input pixels, but it's<br>
> > clearly not the case.  Is there any functionality in astropy that will<br>
> > utilize the available AP/BP coefficients in my header to perform the<br>
> > inverse SIP distortion?  Is there anything I'm doing wrong or missing<br>
> > here?<br>
> I would have expected the above to work.  Are we sure the AP* and BP*<br>
> coeffs are a true inverse of the A* and B* ones?  You can send me the<br>
> FITS file directly (off-list) and I'd be happy to have a look.<br>
><br>
> Mike<br>
><br>
><br>
> --<br>
>                     _<br>
> |\/|o _|_  _. _ | | \.__  __|__|_|_  _  _ ._ _<br>
> |  ||(_| |(_|(/_| |_/|(_)(/_|_ |_|_)(_)(_)| | |<br>
><br>
> <a href="http://www.droettboom.com" target="_blank">http://www.droettboom.com</a><br>
><br>
> _______________________________________________<br>
> AstroPy mailing list<br>
> <a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/astropy" target="_blank">http://mail.scipy.org/mailman/listinfo/astropy</a><br>
><br>
> _______________________________________________<br>
> AstroPy mailing list<br>
> <a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/astropy" target="_blank">http://mail.scipy.org/mailman/listinfo/astropy</a><br>
<br>
_______________________________________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/astropy" target="_blank">http://mail.scipy.org/mailman/listinfo/astropy</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><br>* * * * * * * * <a href="http://www.mssl.ucl.ac.uk/~npmk/" target="_blank">http://www.mssl.ucl.ac.uk/~npmk/</a> * * * *<br>Dr. N.P.M. Kuin      (<a href="mailto:n.kuin@ucl.ac.uk" target="_blank">n.kuin@ucl.ac.uk</a>)      <br>
phone +44-(0)1483 (prefix) -204927 (work) <br>mobile +44(0)7806985366  skype ID: npkuin<br>Mullard Space Science Laboratory  – University College London  –<br>Holmbury St Mary – Dorking – Surrey RH5 6NT–  U.K.</div>
</div>