# NOT RUN {
model = list(
sersic = list(
xcen = c(180, 60),
ycen = c(90, 10),
mag = c(15, 13),
re = c(14, 5),
nser = c(3, 10),
ang = c(46, 80),
axrat = c(0.4, 0.6),
box = c(0.5,-0.5)
)
)
model.image=profitMakeModel(model=model, dim=c(200,200))$z
psf=profitMakeGaussianPSF()
#Do some benchmarking:
temp=profitBenchmarkConv(model.image, psf=psf, nbench=1)
#Check the best:
temp$best
#And we can use all three:
magimage(profitConvolvePSF(model.image, psf, options=list(method='Bruteconv')))
magimage(profitConvolvePSF(model.image, psf, options=list(method='FFTconv', fft=temp$fft)))
magimage(profitConvolvePSF(model.image, psf, options=list(method='FFTWconv', fft=temp$fft)))
#Some benchmarking for different size PSFs:
profitBenchmarkConv(imagedim=c(200,200), psfdim=c(11,11), nbench=1)
profitBenchmarkConv(imagedim=c(200,200), psfdim=c(21,21), nbench=1)
profitBenchmarkConv(imagedim=c(200,200), psfdim=c(31,31), nbench=1)
#Note they are all very similar in speed when psfdim=21. The time for FFT and FFTW
#pretty much scales with the number of pixels in the image (regardless of PSF).
#Because of how they scale, there are some rough rules-of-thumb you can use:
#Brute force is usually faster when psfdim<=21:
profitBenchmarkConv(imagedim=c(200,200), psfdim=c(15,15), nbench=1)
#FFT is usually faster when imagedim<400 & psfdim>21 & psfdim<100:
profitBenchmarkConv(imagedim=c(200,200), psfdim=c(51,51), nbench=1)
#FFTW is usually faster when imagedim>400 & psfdim>21
profitBenchmarkConv(imagedim=c(400,400), psfdim=c(25,25), nbench=1)
# }
Run the code above in your browser using DataLab