In [17]:
import galsim
import numpy as np
import matplotlib.pyplot as plt
In [61]:
gal_flux = 1.234e5
gal_rpix = 24.0
gal_ns = 2.5
gal_ba = 0.8
gal_pa = 45.0
In [62]:
serModel = galsim.Sersic(gal_ns, half_light_radius=gal_rpix, flux=gal_flux)
print serModel.getFlux()
print serModel.centroid()
print serModel.hasHardEdges() #Returns True if there are any hard edges in the profile, which would require very small k spacing when working in the Fourier domain
In [63]:
serSBP = serModel.SBProfile
In [64]:
serModelAxis=serModel.shear(q=gal_ba, beta=0.0*galsim.degrees)
print serModelAxis.getFlux()
print serModelAxis.centroid()
print serModel.hasHardEdges()
In [65]:
serModelRotate=serModelAxis.rotate(gal_pa*galsim.degrees)
print serModelAxis.getFlux()
print serModelAxis.centroid()
print serModel.hasHardEdges()
In [66]:
serImg = serModel.drawImage()
serImgAxis = serModelAxis.drawImage()
serImgRotate = serModelRotate.drawImage()
In [71]:
plt.subplot(131)
plt.imshow(numpy.arcsinh(serImg.array))
plt.subplot(132)
plt.imshow(numpy.arcsinh(serImgAxis.array))
plt.subplot(133)
plt.imshow(numpy.arcsinh(serImgRotate.array))
Out[71]:
In [75]:
serModel = galsim.Sersic(gal_ns, half_light_radius=gal_rpix, flux=gal_flux)
serModel = serModel.shear(q=gal_ba, beta=0.0*galsim.degrees)
serModel = serModel.rotate(gal_pa*galsim.degrees)
serImg = serModel.drawImage()
serImg.addNoise(galsim.PoissonNoise())
plt.figure(1, figsize=(5,5))
plt.imshow(numpy.arcsinh(serImg.array))
plt.savefig('/Users/songhuang/Downloads/temp.png')
In [77]:
serModel1 = galsim.Sersic(3.0, half_light_radius=8.00, flux=1.000e5)
serModel1 = serModel1.shear(q=0.9, beta=0.0*galsim.degrees)
serModel2 = galsim.Sersic(1.0, half_light_radius=45.0, flux=1.345e5)
serModel2 = serModel2.shear(q=0.4, beta=0.0*galsim.degrees)
serModel2 = serModel2.rotate(45.0*galsim.degrees)
serDouble = serModel1 + serModel2
In [80]:
fig, axes = plt.subplots(1, 3, figsize=(15,5))
imgs = serModel1.drawImage().array, serModel2.drawImage().array, serDouble.drawImage().array
titles = "SerComp1", "SerComp2", "SerDouble"
for i in range(3):
axes[i].imshow(numpy.arcsinh(imgs[i]))
axes[i].set_title(titles[i])
In [85]:
psfGauss = galsim.Gaussian(fwhm=2.0)
psfImage = psfGauss.drawImage().array
plt.imshow(numpy.arcsinh(psfImage))
Out[85]:
In [88]:
psfIm = galsim.image.Image(psfImage)
psfObj = galsim.InterpolatedImage(psfIm, scale=1.0)
In [12]:
gal = fits.open("galaxy_test.fits")[1].data[0]
double(gal["mag"])
Out[12]:
In [1]:
from makeFakeGalaxy import *
In [2]:
testMakeFake("galaxy_test.fits")
In [0]:
In [ ]: