Sterncat / opticspy

python optics module
MIT License
448 stars 126 forks source link

Does "psfcaculator" really related with z, which is Distance from exit pupil to image plane? #26

Open goldengrape opened 6 years ago

goldengrape commented 6 years ago

For zernike.py:

def __psfcaculator__(self,r=1,lambda_1=632*10**(-9),z=0.1):
        """
        pupil: Exit pupil diameter
        z: Distance from exit pupil to image plane
        r: pupil radius, in unit of lambda
        """
        pupil = l1 = 200 # exit pupil sample points
        x = __np__.linspace(-r, r, l1)
        [X,Y] = __np__.meshgrid(x,x)
        Z = __interferometer__.__zernikecartesian__(self.__coefficients__,X,Y)
        for i in range(len(Z)):
            for j in range(len(Z)):
                if x[i]**2+x[j]**2>r**2:
                    Z[i][j] = 0
        d = 400 # background
        A = __np__.zeros([d,d])
        A[d//2-l1//2+1:d//2+l1//2+1,d//2-l1//2+1:d//2+l1//2+1] = Z
        axis_1 = d//pupil*r
        fig = __plt__.figure()
        # ax = fig.gca()
        # __plt__.imshow(A,extent=[-axis_1,axis_1,-axis_1,axis_1],cmap=__cm__.RdYlGn)
        # ax.set_xlabel('mm',fontsize=14)
        # __plt__.colorbar()
        # __plt__.show()

I don't see any code effected by z=0.1

Sterncat commented 6 years ago

Actually, I think I need to recheck that since I develop this long time ago when I am in school. If you want to provide some code, feel free to do that.

Golden Grape notifications@github.com 于2018年8月25日周六 上午8:18写道:

For zernike.py:

def psfcaculator(self,r=1,lambda_1=63210(-9),z=0.1): """ pupil: Exit pupil diameter z: Distance from exit pupil to image plane r: pupil radius, in unit of lambda """ pupil = l1 = 200 # exit pupil sample points x = np.linspace(-r, r, l1) [X,Y] = np.meshgrid(x,x) Z = interferometer.zernikecartesian(self.coefficients,X,Y) for i in range(len(Z)): for j in range(len(Z)): if x[i]2+x[j]2>r2: Z[i][j] = 0 d = 400 # background A = np.zeros([d,d]) A[d//2-l1//2+1:d//2+l1//2+1,d//2-l1//2+1:d//2+l1//2+1] = Z axis_1 = d//pupilr fig = plt.figure()

ax = fig.gca()

  # __plt__.imshow(A,extent=[-axis_1,axis_1,-axis_1,axis_1],cmap=__cm__.RdYlGn)
  # ax.set_xlabel('mm',fontsize=14)
  # __plt__.colorbar()
  # __plt__.show()

I don't see any code effected by z=0.1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Sterncat/opticspy/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiIhd5pLzc7kuDlyOopXbkghaxtsfPWks5uUWrAgaJpZM4WMbD1 .

akurz-wue commented 6 years ago

noticed the same! A PSF would be incredibly awesome, there is some really big stuff upcoming in single molecule localisation microscopy, concerning beamshaping using deformable mirrors. If my python skills would just be better..

brandondube commented 5 years ago

Hey @akurz-wue ,

I've been writing an optics library in Python for some time now, which has robust PSF tools. It's at https://github.com/brandondube/prysm and may be of some value to you.

FYI, most optics libraries (including paid softwares, like Code V or Zemax!) use a Fresnel transform to compute a PSF. For large NA systems, this method isn't very accurate and you would need to do e.g. an angular spectrum calculation. PROPER ( https://sourceforge.net/projects/proper-library/ ) can do that sort of thing, but you may find it unwieldy to use.