You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the documentation for the method ImageFileCollection.ccds(), it seems that if return_fname=True, then it should return "the tuple (header, file_name)" instead of just header. I cannot figure out how to do that in practice.
Iterating like this: for ccd, fname in image_collection.ccds(return_fname=True) :
does return the CCDData object in question, and its filename, but not the header. I can't figure out how to get the header. Instead I had to do a clunky workaround, that puts the data in a np array and then converts it to a CCDData object, since there doesn't seem to be a way to do hdu.ccd :
forhdu, fnameinimage_collection.hdus(return_fname=True) :
header=hdu.headerdata=hdu.datadata_ccd=CCDData(hdu.data, unit='MJy/sr', header=header) # clunky. Needed to iterate all of header, data, filenamesubtracted=data_ccd.subtract(combined_image, handle_meta='first_found') # This saves the header from data_ccdnewname=sub('_cbcd.fits', '_bcbcd.fits', fname)
subtracted.write(outdir+newname, overwrite=True)
The text was updated successfully, but these errors were encountered:
@janerigby The header is an attribute of the CCDData object, (e.g., ccd.header) and directly accessible. For the example you included, it would not seem you need to separately handle the header information at all:
for ccd, fname in image_collection.ccds(return_fname=True) :
subtracted = ccd.subtract(combined_image, handle_meta='first_found')
#Add a HISTORY to the header:
subtracted.header['HISTORY'] = 'Subtracted combined_image'
newname=sub('_cbcd.fits', '_bcbcd.fits', fname)
subtracted.write(outdir + newname, overwrite=True)
where we explicitly add a header field HISTORY to the new CCDData object.
Please correct me if I have misunderstood your application.
From the documentation for the method ImageFileCollection.ccds(), it seems that if return_fname=True, then it should return "the tuple (header, file_name)" instead of just header. I cannot figure out how to do that in practice.
Iterating like this:
for ccd, fname in image_collection.ccds(return_fname=True) :
does return the CCDData object in question, and its filename, but not the header. I can't figure out how to get the header. Instead I had to do a clunky workaround, that puts the data in a np array and then converts it to a CCDData object, since there doesn't seem to be a way to do hdu.ccd :
The text was updated successfully, but these errors were encountered: