def mode_jonesmat2x2(shape, k, jmat, epsv=(1., 1., 1.), epsa=(0., 0., 0.), mode=+1, betamax=BETAMAX): """Returns a mode polarizer for fft of the field data in the laboratory frame. This is the most general set of jones matrices for E-field data. It is meant to be used in FFT space. Parameters ---------- shape : (int,int) Shape of the 2D crossection of the field data. k : float or array of floats Wavenumber at which to compute the mode matrices. jmat : (2,2) array A 2x2 jones matrix that needs to be converted to 4x4 mode matrices. epsv : array Medium epsilon eigenvalues epsa : array Medium epsilon euler angles mode : int PRopagatin mode, either +1 or -1 betamax : float The betamax parameter Returns ------- pmat : (:,:,2,2) array Output matrix. Shape of the matirx is shape + (2,2) or len(ks) + shape + (2,2) if k is an array. See Also -------- ray_jonesmat2x2 : for applying the jones matrix in the real space. """ ks = np.asarray(k, FDTYPE) ks = abs(ks) epsv = np.asarray(epsv, CDTYPE) epsa = np.asarray(epsa, FDTYPE) beta, phi = betaphi(shape, ks) alpha, f = diffraction_alphaf(shape, ks, epsv=epsv, epsa=epsa, betamax=betamax) beta, phi = betaphi(shape, ks) #matrix viewed in the eigenframe jmat = rotated_matrix(jmat, phi) pmat = jonesmat4x4(jmat, f) return as2x2(pmat, f, mode)
def ray_jonesmat4x4( jmat, beta=0, phi=0, epsv=(1., 1., 1.), epsa=(0., 0., 0.), ): """Returns a ray polarizer for field data in the laboratory frame. Numpy broadcasting rules apply. Parameters ---------- jmat : (...,2,2) array A 2x2 jones matrix that needs to be converted to 4x4 mode matrices. beta : float The beta parameter of the beam. phi : float The phi parameter of the beam. epsv : (...,3) array Medium epsilon eigenvalues epsa : (...,3) array Medium epsilon euler angles betamax : float The betamax parameter Returns ------- pmat : (...,4,4) array Output matrix. See Also -------- mode_jonesmat4x4 : for applying the jones matrix in the fft space. jonesmat4x4 : for applying the jones matrix in the eigenframe. """ epsv = np.asarray(epsv, CDTYPE) epsa = np.asarray(epsa, FDTYPE) beta = np.asarray(beta, FDTYPE) phi = np.asarray(phi, FDTYPE) alpha, f = alphaf(beta, phi, epsv, epsa) jmat = rotated_matrix(jmat, phi) pmat = jonesmat4x4(jmat, f) return pmat