我正在尝试将增量泊松噪声添加到 .fits 文件中。我知道如何为常规文件类型执行此操作,但我似乎无法阅读合适的内容,然后添加泊松噪声。有人知道该怎么做吗?
这是代码。其中大部分都不是特别相关。
s=str(raw_input("filter name: "))
t=str(raw_input("sci or wht: "))
poisson = str(raw_input("Poisson noise amount: "))
for i in range(0,len(ra_new)):
ra_new2=cat['ra'][z2&lmass2&ra2&dec2][i]
dec_new2=cat['dec'][z2&lmass2&ra2&dec2][i]
id_new=cat['id'][z2&lmass2&ra2&dec2][i]
target_pixel_x = ((ra_new2-ra_ref)/(pixel_size_x))+reference_pixel_x
target_pixel_y = ((dec_new2-dec_ref)/(pixel_size_y))+reference_pixel_y
fig = plt.figure(figsize=(5.,5.))
timage=img[target_pixel_y-65:target_pixel_y+65,target_pixel_x-65:target_pixel_x+65]
plt.imshow(img[target_pixel_y-65:target_pixel_y+65,target_pixel_x-65:target_pixel_x+65], vmin=-0.01, vmax=0.1, cmap='Greys')
galimage = pf.writeto(t+'PHOTO'+s+str(i)+'.fits',timage,clobber=True,header=hdr)
imagea = (scipy.misc.imread(galimage)).astype(float)
poissonNoise = numpy.random.poisson(poisson,imagea.shape).astype(float)
noisyImage = imagea + poissonNoise
pf.writeto(t+'POISSONPHOTO'+s+str(i)+poisson+'.fits',timage,clobber=True,header=hdr)
lmass3=cat['lmass'][z2&lmass2&ra2&dec2][i]
print id_new, ra_new2,dec_new2