<div dir="ltr">Hi all,<div><br></div><div>I recently upgraded to astropy version '0.3.dev5121'. I tried to run one of my old codes and it failed because was using hdr.has_key('CDELT1'). And now seems that the header does not have that attribute anymore: AttributeError: 'CompImageHeader' object has no attribute 'has_key'</div>
<div><br></div><div>If I use the old pyfits I don't get any error. </div><div>Trying to understand what happened, I open the same file using astropy.io.fits and pyfits 2.3.2 and found that the hdu objects were different, they had different number of Cards and different formats.</div>
<div><br></div><div>I solved my original problem replacing </div><div>if hdr.has_key('CDELT1'): by if 'CDELT1' in hdr.keys():<br></div><div><br></div><div>However I am still puzzled by the other changes I see in the HDUs, and I wonder if they have some other implications.</div>
<div><br></div><div>Here is a code showing that the HDUs are different using astropy.fits and pyfits (I think the problem should be independent of the image used so I am not attaching it)</div><div><br></div><div>================<br clear="all">
<div><div>from <a href="http://astropy.io">astropy.io</a> import fits</div><div>import pyfits</div><div><br></div><div>imgname = 'image.fits'</div><div><br></div><div>hdu1 = pyfits.open(imgname)</div><div>hdu2 = fits.open(imgname)</div>
<div><br></div><div>hdr1 = hdu1[1].header</div><div>hdr2 = hdu2[1].header</div><div><br></div><div>print "hdu1 == hdu2? ", hdu1 == hdu2</div><div>print <a href="http://hdu1.info">hdu1.info</a>()</div><div>print <a href="http://hdu2.info">hdu2.info</a>()<br>
</div></div><div>================</div><div><br></div><div>The output is:</div><div><br></div><div><div>hdu1 == hdu2?  False</div><div>Filename: image.fits</div><div>No.    Name         Type      Cards   Dimensions   Format</div>
<div>0    PRIMARY     PrimaryHDU       6  ()            int16</div><div>1                CompImageHDU   172  (1200, 1200)  float32</div><div>None</div><div>Filename: image.fits</div><div>No.    Name         Type      Cards   Dimensions   Format</div>
<div>0    PRIMARY     PrimaryHDU       6   ()           int16   </div><div>1                CompImageHDU    174   (1200, 1200)   int16   </div><div>None</div></div><div><br></div><div><br></div><div>The Cards number changes from 172 to 174 and the Format from float32 to int16. And the attributes of the headers are different</div>
<div><br></div><div>Cheers,</div><div><br></div>-- <br><div dir="ltr">Eduardo Bañados <br><br></div>
</div></div>