我适合 galsim 中的星系并收到以下错误:
File "/home/luis/Documents/SRC2014/galsim_work/noiseLibrary.py", line 50, in create_galaxy
gal = gal.shear(g1=e1, g2=e2)
File "/usr/lib/python2.7/dist-packages/galsim/base.py", line 572, in shear
shear = galsim.Shear(**kwargs)
File "/usr/lib/python2.7/dist-packages/galsim/shear.py", line 111, in __init__
raise ValueError("Requested shear exceeds 1: %f"%g)
ValueError: Requested shear exceeds 1: 1.007171
我试图通过检查 e1 和 e2 的值以及我的程序中创建星系的大小来解决这个问题:
if e1 > 1:
print "The e1 component of ellipticity is greater than 1."
e1 = 0.99
elif e1 < -1:
print "The e1 component of ellipticity is less than -1."
e1 = -0.99
if e2 > 1:
print "The e2 component of ellipticity is greater than 1."
e2 + 0.99
elif e2 < -1:
print "The e2 component of ellipticity is less than -1."
e2 = -0.99
if np.sqrt(e1**2 + e2**2) > 1:
return create_galaxy(flux, hlr, e1*0.5, e2*0.5, galtype_gal=galtype_gal, sersic_index=sersic_index,
psf_flag=psf_flag, psf_type=psf_type, beta=beta, size_psf=size_psf, flux_psf=flux_psf,
x_len=x_len, y_len=y_len, scale=scale, method=method,seed=seed)
虽然此解决方案适用于各个组件,但我怀疑递归调用会产生以下错误:
File "/usr/lib/python2.7/dist-packages/galsim/base.py", line 1196, in drawImage
image.added_flux = prof.SBProfile.draw(imview.image, gain, wmult)
MemoryError
关于如何解决这个问题的任何建议?请注意,我将 e1 和 e2 限制在 -1 和 1 之间以进行拟合参数化。我怀疑我应该限制我的椭圆度的大小(根据单位圆限制),而不是单位平方。
谢谢!