[AstroPy] DATAMD5 calculation

Ole Streicher astropy at liska.ath.cx
Wed May 25 11:56:10 EDT 2011

Am 25.05.2011 16:14, schrieb Erik Bray:
> I took a look at the fitsmd5 utility, and as you said it's the MD5 sum 
> of all the data sections.  Where PyFITS is concerned, _datLoc is just 
> the offset within the file where that HDU's data section begins, and 
> _datSpan is the length of the data section.  Since FITS files are read 
> in 2880 byte blocks, there can be some padding at the end of the data, 
> which is why it may not be exactly the same as hdu.data.nbytes.
> But it looks like fitsmd5 includes that padding in the sum.  The padding 
> is just null bytes, so you can still add that yourself.  For example:
> md5sum.update(hdu.data)
> pad = '\0' * (FITS_BLOCK_SIZE - hdu.data.nbytes % FITS_BLOCK_SIZE)
> md5sum.update(pad)
> And do that for each HDU.  I think that would do it.

That works. Thank you very much for your help.

Best regards


More information about the AstroPy mailing list