I am fitting to galaxies in galsim and receive the following errors:
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
I've attempted to remedy this by checking for values of e1 and e2 and the magnitude in my program that creates galaxies by the following:
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)
while this solution works for the individual components, I suspect the recursive call is creating the following error:
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
Any recommendations on how to go about this? Note that I am bounding e1 and e2 to be between -1 and 1 for my fitting parametrization. I suspect that I should be bounding the magnitude of my ellipticity (to bound according to the unit circle), not the unit square.
Thanks!