echo 0
print "Demonstration of PSF simulation"

size = 256
pgbeg 0, plotdevice, 1, 1
pgask 0
pgsubp -3,2
pgsch 2
pgenv 1, size, 1, size, 1, -2
pgsitf 0
pglab "", "", "Single Dish"

pupil = circle(129, 129, 10)

pggray pupil, size, size, 1, size, 1, size, max(pupil), min(pupil), [0,1,0,0,0,1]

pgenv 1, size, 1, size, 1, -2
pglab "", "", "...and its PSF"
psf = reass(abs(fft(pupil)))
pggray psf, size, size, 1, size, 1, size, max(psf)/2, min(psf), [0,1,0,0,0,1]

pgenv 1, size, 1, size, 1, -2
pglab "", "", "Y shaped configuration"
pupil[*] = 0
for (i = 129; i < 240; i += 25) pupil += circle(129, i, 10)
for (i = 129 - 25/sqrt(2); i > 30; i -= 25/sqrt(2)) {
  pupil += circle(i, i, 10)
  pupil += circle(256-i, i, 10)
}
pggray pupil, size, size, 1, size, 1, size, max(pupil), min(pupil), [0,1,0,0,0,1]

pgenv 1, size, 1, size, 1, -2
pglab "", "", "...and its PSF"
psf = reass(abs(fft(pupil)))
pggray psf, size, size, 1, size, 1, size, max(psf)/5, min(psf), [0,1,0,0,0,1]

pgenv 1, size, 1, size, 1, -2
pglab "", "", "The LBT"
pupil = circle(110, 129, 10)
pupil += circle(139, 129, 10)
pggray pupil, size, size, 1, size, 1, size, max(pupil), min(pupil), [0,1,0,0,0,1]

pgenv 1, size, 1, size, 1, -2
pglab "", "", "...and its PSF"
psf = reass(abs(fft(pupil)))
pggray psf, size, size, 1, size, 1, size, max(psf)/2, min(psf), [0,1,0,0,0,1]

pgend
