summaryrefslogtreecommitdiff
path: root/wcsutil/wcscorr.py
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2011-05-03 17:36:16 -0400
committerhack <hack@stsci.edu>2011-05-03 17:36:16 -0400
commitc523492a23e7962087aafc9e7a16120a2e8fa069 (patch)
tree2acd4afdcf78e20f8955dd3bd56f8bf7327edf5a /wcsutil/wcscorr.py
parent2907aea16f4f8242acfd7ac0209d3975c710a2a8 (diff)
downloadstwcs_hcf-c523492a23e7962087aafc9e7a16120a2e8fa069.tar.gz
Further refinements to the WCSCORR code in STWCS to reduce the number of new rows that gets added each time, and to maintain the same header information from one update to the next.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@12715 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'wcsutil/wcscorr.py')
-rw-r--r--wcsutil/wcscorr.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/wcsutil/wcscorr.py b/wcsutil/wcscorr.py
index 054626b..c344851 100644
--- a/wcsutil/wcscorr.py
+++ b/wcsutil/wcscorr.py
@@ -263,7 +263,7 @@ def update_wcscorr(dest, source=None, extname='SCI', wcs_id=None):
wcs_keys = [wcs_key] # We're only interested in this one
# create new table for hdr and populate it with the newly updated values
- new_table = create_wcscorr(numrows=numext, padding=numext)
+ new_table = create_wcscorr(numrows=0, padding=len(wcs_keys)*numext)
old_table = dest['WCSCORR']
idx = -1
@@ -308,18 +308,22 @@ def update_wcscorr(dest, source=None, extname='SCI', wcs_id=None):
rowind = find_wcscorr_row(old_table.data, {'wcs_id':''})
old_nrows = np.where(rowind)[0][0]
new_nrows = new_table.data.shape[0]
-
+
# check to see if there is room for the new row
if (old_nrows + new_nrows) > old_table.data.shape[0]:
- pad_rows = 5 * new_nrows
+ pad_rows = 2 * new_nrows
# if not, create a new table with 'pad_rows' new empty rows
- upd_table = pyfits.new_table(old_table.columns,
- nrows=old_table.data.shape[0] + pad_rows)
+ upd_table = pyfits.new_table(old_table.columns,header=old_table.header,
+ nrows=old_table.data.shape[0]+pad_rows)
else:
upd_table = old_table
-
+ pad_rows = 0
# Now, add
for name in old_table.columns.names:
+ # reset the default values to ones specific to the row definitions
+ for i in range(pad_rows):
+ upd_table.data.field(name)[old_nrows+i] = old_table.data.field(name)[-1]
+ # Now populate with values from new table
upd_table.data.field(name)[old_nrows:old_nrows + new_nrows] = \
new_table.data.field(name)
upd_table.header.update('TROWS', old_nrows + new_nrows)