mperrin / poppy

Physical Optics Propagation in Python
BSD 3-Clause "New" or "Revised" License
176 stars 41 forks source link

Fresnel propagation detector and setting pixel pitch #242

Closed mb2448 closed 5 years ago

mb2448 commented 6 years ago

Hello, python version = 2.7.12, numpy = 1.13.3, poppy = 0.6.1

This is a two part question from a casual user of Proper and Poppy.

1) I am trying to add a detector to my FresnelOpticalSystem, but the following simple code simulating the arago spot breaks:

import numpy as np
import poppy
from poppy.poppy_core import PlaneType
import astropy.units as u
import astropy.io.fits as fits

if __name__ == "__main__":
    npix = 1024 # ~512 is minimum to accurately recover the central diffraction spike
    osys = poppy.FresnelOpticalSystem(pupil_diameter = 0.05*u.m, npix = npix, beam_ratio = 0.25)
    osys.add_optic(poppy.CircularAperture(radius=0.025) )
    osys.add_detector(pixelscale=9e-6*u.m, distance = 2*u.m)

with AttributeError: 'FresnelOpticalSystem' object has no attribute 'oversample'

2) I am confused about how to set up the following (see #191): I want a circular aperture that fresnel propagates a certain distance, then look at the beam at that distance with a detector of fixed pixel size. Is the code above the right approach? I have been avoiding using FresnelOpticalSystem thus far and simply operating on FresnelWavefront, but to downsample the beam to the detector pixel scale (9 microns) using POPPY, it seems the only way is to use the FresnelOpticalSystem and add a detector. Is there another way?

douglase commented 6 years ago

for 1. above: That's definitely a bug that should be fixed. It's a little tricky since the detector concept, with a defined platescale, doesn't translate super well to the fresnel regime; it will require resampling to define a detector pixelscale after the optical system which may give unexpected results if the wavefront is initialized with too small a pixelscale.

For 2. above, if you just want a different plate scale in your image plane using wavefront propagation without the poppy.FresnelOpticalSystem, you can vary the npix and oversampling keywords in your initial wavefront until you get the sampling you are looking for.