opticspy / lightpipes

LightPipes for Python, "Pure Python version"
https://opticspy.github.io/lightpipes/
BSD 3-Clause "New" or "Revised" License
227 stars 52 forks source link

Add Interpol option in Fresnel and Forvard #58

Open jmmelko opened 3 years ago

jmmelko commented 3 years ago

Hi guys,

I suggest adding newsize and Nnew as optional parameters to the Fresnel and Forvard methods. They would by used to call Interpol within the function.

This would make the three main integration methods homogeneous in terms of arguments.

I have implemented this in my own code, to be able to switch between methods, by changing the values of a Methods dictionary/list defined at the beginning of my script. Indeed, it is often the case that we have to change the method depending on the conditions (focusing or not, long or short propagation distance, etc.)

besides, this would not be shocking as other LightPipes function already integrate coordinate changes, LendForvard for instance that uses spherical coordinates.

jmmelko commented 3 years ago

here is what I did in my code:

def Forward(Fin, z, sizenew, Nnew):
    return LightPipes.Forward(Fin=Fin, z=z, sizenew=sizenew, Nnew=Nnew)

def Fresnel(Fin, z, sizenew, Nnew):
    return LightPipes.Fresnel(Fin=LightPipes.Interpol(Fin, sizenew, Nnew), z=z)

def Forvard(Fin, z, sizenew, Nnew):
    return LightPipes.Forvard(Fin=LightPipes.Interpol(Fin, sizenew, Nnew), z=z)

Maybe we can put that in light Pipes, provided that Interpol never crashes