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
{{ message }}
Repository navigation
Creating a HIERARCH card in a compressed image header fails (sometimes) #5313
I've been looking a little further in this, and can actually reproduce the error with an even simpler setup which hopefully points to what needs to be fixed:
hdu = fits.open('kmts.20151202.030382.fits.fz')
key = 'trim_image'
short_name = 'trimim'
card = (key, short_name, "Shortened name for command")
hdu[3].header.append()
hdu[3].header.append(card)
This will replicate an error in which the last entry in the table is a blank. However, the primary error of this is within the function _keyword_from_index' inHeader` and can essentially be replicated even in a normal header by the following:
short_name = 'trimim'
card = (key, short_name, "Shortened name for command")
card = Card(*card)
hdu= fits.PrimaryHDU(np.ones((100,100)))
hdu.header.append()
hdu.header.append()
hdu.header.append(card)
hdu.header._keyword_from_index(-1)
Now, the main issue here is there is a list of keywords, _keyword_indices where all the keywords in that list have been normalized (essentially made upper case) before entering into that list. In a number of Header functions, prior to looking for the keyword, it will normalize the keyword like in append and contain before using it. However, it follows a different behavior in insert.
I've just submitted a pull request to address these issues and hopefully return more consistent behavior.
Activity
crawfordsm commentedon Sep 9, 2016
I've been looking a little further in this, and can actually reproduce the error with an even simpler setup which hopefully points to what needs to be fixed:
This will replicate an error in which the last entry in the table is a blank. However, the primary error of this is within the function
_keyword_from_index' inHeader` and can essentially be replicated even in a normal header by the following:Now, the main issue here is there is a list of keywords,
_keyword_indiceswhere all the keywords in that list have been normalized (essentially made upper case) before entering into that list. In a number ofHeaderfunctions, prior to looking for the keyword, it will normalize the keyword like inappendandcontainbefore using it. However, it follows a different behavior ininsert.I've just submitted a pull request to address these issues and hopefully return more consistent behavior.