Skip to content

Commit

Permalink
Add comments to SIP coefficients in WCS.to_header
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed Jun 10, 2020
1 parent e5c1d56 commit 85e9497
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ astropy.visualization
astropy.wcs
^^^^^^^^^^^

- ``WCS.to_header()`` now appends comments to SIP coefficients. [#10480]


API Changes
-----------
Expand Down
9 changes: 7 additions & 2 deletions astropy/wcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,12 +1190,17 @@ def write_array(name, a):
if a is None:
return
size = a.shape[0]
keywords[f'{name}_ORDER'] = size - 1
trdir = 'sky to detector' if name[-1] == 'P' else 'detector to sky'
comment = ('SIP polynomial order, axis {:d}, {:s}'
.format(ord(name[0]) - ord('A'), trdir))
keywords[f'{name}_ORDER'] = size - 1, comment

comment = 'SIP distortion coefficient'
for i in range(size):
for j in range(size - i):
if a[i, j] != 0.0:
keywords[
f'{name}_{i:d}_{j:d}'] = a[i, j]
f'{name}_{i:d}_{j:d}'] = a[i, j], comment

write_array('A', self.sip.a)
write_array('B', self.sip.b)
Expand Down

0 comments on commit 85e9497

Please sign in to comment.