我正在尝试添加正态分布的噪音,但它的行为很奇怪。当我输入 1 个标准偏差时,它反而给了我大量的额外噪音。也许你知道解决办法?
#irrelevant code precedes this
poisson = float((raw_input("Noise standard deviation: ")))
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')
pf.writeto(t+'PHOTO'+s+str(i)+'.fits',timage,clobber=True,header=hdr)
lmass3=cat['lmass'][z2&lmass2&ra2&dec2][i]
print id_new, ra_new2,dec_new2
name = t+'PHOTO'+s+str(i)+'.fits'
im = pf.open(name)
im0 = im[0]
poissonNoise = np.random.normal(0,poisson, im0.data.shape).astype(float)
test = im0.data + poissonNoise
im0.data = test
stringee = 'NOISE'
pf.writeto(stringee+str(poisson)+name, data=test, clobber=True, header=im0.header)
print poisson
我得到的鼻子超过1个标准偏差:-(