diff options
Diffstat (limited to 'astro/chandra')
-rwxr-xr-x | astro/chandra/blanksky_add_time.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/astro/chandra/blanksky_add_time.py b/astro/chandra/blanksky_add_time.py index a4d0cb6..8db3c2b 100755 --- a/astro/chandra/blanksky_add_time.py +++ b/astro/chandra/blanksky_add_time.py @@ -3,6 +3,17 @@ # # Aaron LI # 2015/06/16 +# +# Changelogs: +# 0.2.0, 2015/06/16, Aaron LI +# * append the new time column to the *last*, rather than inserting +# to the beginning +# * explicitly update header from the new generated table +# +# BUGS: +# * comments of columns will lost after modified by astropy.io.fits, +# which is a bug with this package +# """ Add a time column for the chandra blanksky event file. @@ -10,7 +21,7 @@ The time data are generated with a uniform distribution between TSTART and TSTOP. """ -__version__ = "0.1.0" +__version__ = "0.2.0" __date__ = "2015/06/16" import sys @@ -43,9 +54,16 @@ def add_time_column(fitsfile, blockname="EVENTS"): counts = len(table.data) time_data = np.random.uniform(tstart, tstop, counts) time_col = fits.Column(name="time", format="1D", unit="s", array=time_data) + # NOTE: append the new time column to the *last*! + # Otherwise the TLMIN??/TLMAX?? keyword pairs, which record the + # minimum/maximum values of corresponding columns, will become + # *out of order*. Therefore the output FITS file causes weird problems + # with DS9 and DM tools. newtable = fits.BinTableHDU.from_columns( - fits.ColDefs([time_col]) + table.columns) + table.columns + fits.ColDefs([time_col])) fitsfile[blockname].data = newtable.data + # update header + fitsfile[blockname].header.update(newtable.header) return fitsfile |