Repository navigation
Remove redundant SCAMP distorition parameters when SIP is also present - #1278
Conversation
|
Thanks for doing this -- it was hard for me to prioritize work on #299, since we don't use SCAMP files here. So when SCAMP files also have SIP the SIP is intended to supercede the |
There was a problem hiding this comment.
This change should not be made. If parsing of one of the header cards fails and the loop bails early, we still want access to the other ones, so we need to update npv as we go.
There was a problem hiding this comment.
Then we need to set (*npv) = i + 1; inside the loop and (*npv) = i; outside it at the end.
|
It seems like this PR removes I am not familiar with the SCAMP distortion model but I wonder if it's possible to convert it to the SIP convention (similar to how HST converted the IDCTAB distortion to SIP)? |
|
Very good point, @nden about overzealously removing I believe it is possible to convert the SCAMP distortion model to SIP, and this PR basically assumes that has already been done. I think that was the original proposal to fix #299, but it's more complex than this PR, of course. |
This behavior is suggested in the second bullet point in Section 7 of http://web.ipac.caltech.edu/staff/shupe/reprints/SIP_to_PV_SPIE2012.pdf.
You are right. We also should convert the SCAMP distortion parameters to SIP if the SCAMP parameters are present but not SIP. I'd just need an example of an output file of SCAMP that hasn't had the SIP distortion parameters added like PTF does. |
Yes, @nden, see http://web.ipac.caltech.edu/staff/shupe/reprints/SIP_to_PV_SPIE2012.pdf. |
Possibly... SCAMP sets the comments for the |
There was a problem hiding this comment.
This is no longer incorrect, but it's still redundant. And the end of the loop, i is incremented, it is no longer less than size so it terminates with a value of what was i + 1 at the bottom of the loop.
There was a problem hiding this comment.
@mdboom, that's a good point.
What do you think of having this function do all of the type marshaling before populating the WCS data structures, so that the data structure is updated if and only if the function has progressed past the point which any Python exceptions could possibly be raised?
There was a problem hiding this comment.
That seems like a good idea, and definitely better in terms of "transaction safety" than what we have now.
|
I'd prefer to detect the SCAMP file using something other than a comment. If that's the best we can do, so be it, but comments shouldn't be considered meaningful, in general. |
|
SCAMP always makes a fourth-order polynomial with no radial terms. I think that would be the best fingerprint. If SCAMP were changed to do something different, it would change which terms appear...I guess that could be handled later if it actually happens. I don't know of any other signature for the presence of the PV distortion keywords. The proposed "TPV" convention would change the CTYPEs to e.g. RA---TPV instead of RA---TAN, but this isn't the current behavior of SCAMP as far as I know. |
|
It needs a rebase, but I think it's fine otherwise. Not ideal, since it uses a strange heuristic to detect incorrect (or obsolete) use of the FITS WCS spec, but as a real world solution, I think it's the best we've got. |
|
Ideally, we should implement this condition:
|
|
@lpsinger: I agree. Are you able to implement that, or shall I take a crack at it? |
|
Feel free to take a crack at it if you want. I could get to it by late this week. |
The number of pv cards was being updated inside a loop. If there were 0 pv cards, then the loop body would never be executed, hence the number of pv values would not be updated. The loop counter itself, upon the end of the loop, is the number of pv cards.
The WCS.wcs.get_pv() accessor seems to correctly return an empty array if there are no PVi_Ma records.
Since the fix() method now repairs duplicate SCAMP/SIP distortion parameters, the validation now only fails if the WCS has not been fixed.
...so that it has a correct value even if the loop ends early because an error occurs.
Either the entire input is converted from Python types and updated successsfully, or no change to the internal data structures occur. Also, should be a little bit more lightweight due to using PySequence_Fast to eliminate need for bounds checking in loop.
SCAMP inserts PV parameters with no radial terms, so if there are any PV terms with indices that are used for storing radial parameters, we can conclude that the PV parameters do not come from SCAMP. See <http://web.ipac.caltech.edu/staff/shupe/reprints/SIP_to_PV_SPIE2012.pdf>.
|
I have both implemented the check for radial terms suggested by @stargaser and rebased the patches. I think that it is ready to go. |
|
Those failures don't look real to me, but they keep happening even when I restart... I think there might be some sort of network issue on travis' side? So is this ready to go, @mdboom, assuming that's the case? |
|
@eteq - yeah, Travis is broken currently, I guess we just need to be patient. |
|
@mdboom - I restarted the tests. Is this good to merge once the tests pass? |
|
Other than my one minor comment, this looks good once Travis is passing. |
|
All but one of the Travis tests passed; the last one timed out. I just restarted that job. |
|
All tests passed. |
|
@lpsinger - thanks! |
Remove redundant SCAMP distorition parameters when SIP is also present
Fixes #299.