In [1]:
import galsim
import time
import numpy as np
import matplotlib.pyplot as plt
In [37]:
flux = 1.00e6
nser = 4.0
reff = 10.0
ba = 0.6
pa = 45.0
In [38]:
trunc = int(10.0 * reff)
method = 'auto'
In [39]:
size = min([30.0 * reff, 600.0])
imgTemp = galsim.image.Image(size, size)
In [40]:
psfObj = galsim.Moffat(2.0, fwhm=2.0)
plt.figure(1, figsize=(5,5))
plt.imshow(numpy.arcsinh(psfObj.drawImage().array))
Out[40]:
In [21]:
start_time = time.time()
serUntr = galsim.Sersic(nser, half_light_radius=reff)
serUntr = serUntr.withFlux(flux)
print "\n## Normal round Sersic model with Sersic %5.1f, and Re %6.2f pixels" % (nser, reff)
print "The Flux is : ", serUntr.getFlux()
serUntrImg0 = serUntr.drawImage(method=method).array
print "Shape of the output array : ", serUntrImg0.shape
print "Total Flux in the array : ", np.sum(serUntrImg0)
# Apply the axis ratio
serUntr = serUntr.shear(q=ba, beta=0.0*galsim.degrees)
print "\n## With axis ratio = %5.2f" % ba
print "The Flux is : ", serUntr.getFlux()
serUntrImg1 = serUntr.drawImage().array
print "Shape of the output array : ", serUntrImg1.shape
print "Total Flux in the array : ", np.sum(serUntrImg1)
# Apply the position angle
serUntr = serUntr.rotate(pa*galsim.degrees)
print "\n## With position angle = %6.2f" % pa
print "The Flux is : ", serUntr.getFlux()
serUntrImg2 = serUntr.drawImage(method=method).array
print "Shape of the output array : ", serUntrImg2.shape
print "Total Flux in the array : ", np.sum(serUntrImg2)
# Apply the PSF convolution
serConvUntr = galsim.Convolve([serUntr, psfObj])
print "\n## Convolve with a Moffat PSF model"
print "The Flux is : ", serConvUntr.getFlux()
serUntrImg3 = serConvUntr.drawImage(method=method).array
print "Shape of the output array : ", serUntrImg3.shape
print "Total Flux in the array : ", np.sum(serUntrImg3)
print "\n------- Time Spent: %s seconds -------" % (time.time() - start_time)
In [23]:
fig, axes = plt.subplots(1, 4, figsize=(16.0, 4.0))
imgs = serUntrImg0, serUntrImg1, serUntrImg2, serUntrImg3
titles = "SerOrigin", "SerAxisRatio", "SerPosAngle", "SerConv"
for i in range(4):
axes[i].imshow(numpy.arcsinh(imgs[i]))
axes[i].set_title(titles[i])
In [24]:
start_time = time.time()
serTrun = galsim.Sersic(nser, half_light_radius=reff, trunc=trunc)
serTrun = serTrun.withFlux(flux)
print "\n## Truncated round Sersic model with Sersic %5.1f, and Re %6.2f pixels" % (nser, reff)
print "The Flux is : ", serTrun.getFlux()
serTrunImg0 = serTrun.drawImage(method=method).array
print "Shape of the output array : ", serTrunImg0.shape
print "Total Flux in the array : ", np.sum(serTrunImg0)
# Apply the axis ratio
serTrun = serTrun.shear(q=ba, beta=0.0*galsim.degrees)
print "\n## With axis ratio = %5.2f" % ba
print "The Flux is : ", serTrun.getFlux()
serTrunImg1 = serTrun.drawImage().array
print "Shape of the output array : ", serTrunImg1.shape
print "Total Flux in the array : ", np.sum(serTrunImg1)
# Apply the position angle
serTrun = serTrun.rotate(pa*galsim.degrees)
print "\n## With position angle = %6.2f" % pa
print "The Flux is : ", serTrun.getFlux()
serTrunImg2 = serTrun.drawImage(method=method).array
print "Shape of the output array : ", serTrunImg2.shape
print "Total Flux in the array : ", np.sum(serTrunImg2)
# Apply the PSF convolution
serConvTrun = galsim.Convolve([serTrun, psfObj])
print "\n## Convolve with a Moffat PSF model"
print "The Flux is : ", serConvTrun.getFlux()
serTrunImg3 = serConvTrun.drawImage(method=method).array
print "Shape of the output array : ", serTrunImg3.shape
print "Total Flux in the array : ", np.sum(serTrunImg3)
print "\n------- Time Spent: %s seconds -------" % (time.time() - start_time)
In [25]:
fig, axes = plt.subplots(1, 4, figsize=(16.0, 4.0))
imgs = serTrunImg0, serTrunImg1, serTrunImg2, serTrunImg3
titles = "SerOrigin", "SerAxisRatio", "SerPosAngle", "SerConv"
for i in range(4):
axes[i].imshow(numpy.arcsinh(imgs[i]))
axes[i].set_title(titles[i])
In [31]:
start_time = time.time()
serUntr = galsim.Sersic(nser, half_light_radius=reff)
serUntr = serUntr.withFlux(flux)
print "\n## Normal round Sersic model with Sersic %5.1f, and Re %6.2f pixels" % (nser, reff)
print "The Flux is : ", serUntr.getFlux()
# Apply the axis ratio
print "\n## With axis ratio = %5.2f" % ba
serUntr = serUntr.shear(q=ba, beta=0.0*galsim.degrees)
# Apply the position angle
print "\n## With position angle = %6.2f" % pa
serUntr = serUntr.rotate(pa*galsim.degrees)
# Apply the PSF convolution
serConvUntr = galsim.Convolve([serUntr, psfObj])
print "\n## Convolve with a Moffat PSF model"
print "The Flux is : ", serConvUntr.getFlux()
serUntrImg = serConvUntr.drawImage(method=method).array
print "Shape of the output array : ", serUntrImg.shape
print "Total Flux in the array : ", np.sum(serUntrImg)
print "\n------- Time Spent: %s seconds -------" % (time.time() - start_time)
plt.figure(1, figsize=(5,5))
plt.imshow(numpy.arcsinh(serUntrImg))
Out[31]:
In [32]:
start_time = time.time()
serTrun = galsim.Sersic(nser, half_light_radius=reff, trunc=trunc)
serTrun = serTrun.withFlux(flux)
print "\n## Truncated round Sersic model with Sersic %5.1f, and Re %6.2f pixels" % (nser, reff)
print "The Flux is : ", serTrun.getFlux()
# Apply the axis ratio
print "\n## With axis ratio = %5.2f" % ba
serTrun = serTrun.shear(q=ba, beta=0.0*galsim.degrees)
# Apply the position angle
print "\n## With position angle = %6.2f" % pa
serTrun = serTrun.rotate(pa*galsim.degrees)
# Apply the PSF convolution
serConvTrun = galsim.Convolve([serTrun, psfObj])
print "\n## Convolve with a Moffat PSF model"
print "The Flux is : ", serConvTrun.getFlux()
serTrunImg = serConvTrun.drawImage(method=method).array
print "Shape of the output array : ", serTrunImg.shape
print "Total Flux in the array : ", np.sum(serTrunImg)
print "\n------- Time Spent: %s seconds -------" % (time.time() - start_time)
plt.figure(1, figsize=(5,5))
plt.imshow(numpy.arcsinh(serTrunImg))
Out[32]:
In [42]:
start_time = time.time()
serUntr = galsim.Sersic(nser, half_light_radius=reff)
serUntr = serUntr.withFlux(flux)
print "\n## Normal round Sersic model with Sersic %5.1f, and Re %6.2f pixels" % (nser, reff)
print "The Flux is : ", serUntr.getFlux()
# Apply the axis ratio
print "\n## With axis ratio = %5.2f" % ba
serUntr = serUntr.shear(q=ba, beta=0.0*galsim.degrees)
# Apply the position angle
print "\n## With position angle = %6.2f" % pa
serUntr = serUntr.rotate(pa*galsim.degrees)
# Apply the PSF convolution
serConvUntr = galsim.Convolve([serUntr, psfObj])
print "\n## Convolve with a Moffat PSF model"
print "The Flux is : ", serConvUntr.getFlux()
# Draw on an ImgObj with size=size
print "\n## Draw on an ImageObj with size=%5d pixels" % size
serUntrImg = serConvUntr.drawImage(imgTemp, method=method).array
print "Shape of the output array : ", serUntrImg.shape
print "Total Flux in the array : ", np.sum(serUntrImg)
print "\n------- Time Spent: %s seconds -------" % (time.time() - start_time)
plt.figure(1, figsize=(5,5))
plt.imshow(numpy.arcsinh(serUntrImg))
Out[42]:
In [ ]: