In [2]:
%pylab inline
from astropy.io import fits

test = fits.open("subaru_IB427_042_sci_10.fits")
            
test[0].data[np.where(np.isnan(test[0].data))[0],np.where(np.isnan(test[0].data))[1]] = 65535.

test.writeto("IB_pixreplace_42.fits")


Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['test']
`%matplotlib` prevents importing * from pylab and numpy