def renameFits(filenameIn,filenameOut,killInput=True,overwrite=True):
"""
Load input into a new fits HDU, write to output name, close, rm input file.
"""
goodToGo = True
if os.path.exists(filenameOut):
if overwrite:
rmFiles([filenameOut])
else:
goodToGo=False
log.critical("File already exists, either set overwrite==True, or there be more careful.")
if goodToGo:
(head,data) = loadFits(filenameIn)
hdu = pyfits.PrimaryHDU(data)
hdulist = pyfits.HDUList([hdu])
header = hdulist[0].header
for key in head:
header[key] = (head[key],head.comments[key])
hdulist.writeto(filenameOut)
hdulist.close()
log.info("output file written to:below\n"+filenameOut)
if killInput:
rmFiles([filenameIn])
评论列表
文章目录