Simulate a camera PSF? Say I have a $3D$ object stored as a $3D$ $\texttt{NumPy}$ array in python. I want to view this $3D$ object as a camera would give: a particular aperture, focal length, etc. My understanding is I can blur each layer of this object by a certain amount by convoluting it with the camera's PSF. After blurring, all the slices can be summed together, resulting in a final image. The issue I am having is how to create this PSF, so it's $3D$ $(x,y,z)$. I see a lot of literature for deriving PSF for microscopes, but to my understanding, the PSF on a camera isn't symmetric across the focal plane; objects closer to the camera blur out faster.  I wondered if anyone has come across a $3D$ PSF for a conventional camera or how about I could derive it myself?
 A: If you wanted to do it in purely ray optics, it's easiest to proceed with ray tracing. The rays cast from camera sensor would go through the objective lenses and finally find their intersections with the nearest points of the object (unless absorbed inside the objective). Don't forget that the ray may partially reflect from the lenses, and the lenses have coatings that change reflectivity depending on wavelength and incidence angle from the simple Fresnel model. This process will let you reproduce depth of field effect, bokeh and most aberrations of the lens, as well as lens flare.
But this is not sufficient if your aperture is small enough. In this case you also need to take diffraction into account. In case of a point light source at infinity, focused at the sensor, you can calculate the pattern as Fraunhofer diffraction by the aperture. For a polygonal aperture the integral can be calculated analytically, see e.g. [1] for triangle, and use superposition for arbitrary polygon.
Now, if the source point isn't at infinity, it might be a good approximation to treat the rays from the object as if originating at infinity in the same direction. This will neglect their sphericity, but might not affect the result too much. This I cannot guarantee because I didn't check how much of an error this approximation introduces.
Of course, this isn't exact solution of wave propagation through the whole system. But it should get most of the details right.
References
1: R.M. Sillitto & Winifred Sillitto (1975) "A Simple Fourier Approach to Fraunhofer Diffraction by Triangular Apertures", Optica Acta: International Journal of Optics, 22:12, 999-1010,
DOI: 10.1080/713819012
