使用numpy正态分布的更多帮助

时间:2013-11-04 08:17:10

标签: python random numpy noise

我正在尝试添加正常分布的噪音量,但它的行为很奇怪。当我输入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: - (

0 个答案:

没有答案