field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, jones=jones, beta=beta, pixelsize=PIXELSIZE, n=1.5, focus=focus, window=window) #: transfer input light through stackt field_data_out = dtmm.transfer_field(field_data_in, optical_data, beta=beta, phi=0, diffraction=1, method="4x4", smooth=0.1, reflection=2, nin=1.5, nout=1.5, npass=5, norm=2) #: visualize output field viewer1 = dtmm.field_viewer(field_data_out, mode="t", n=1.5, intensity=0.5, focus=-20) fig1, ax1 = viewer1.plot() ax1.set_title("Transmitted field")
units of coefficient b are microns**2 """ epsc = EpsilonCauchy(shape=(NLAYERS, HEIGHT, WIDTH), n=2) epsc.coefficients[..., 0] = (epsv)**0.5 # a term, just set to refractive index epsc.coefficients[..., 0:2, 1] = 0.005 * (epsv[..., 0:2])**0.5 # b term ordinary epsc.coefficients[..., 2, 1] = 0.005 * (epsv[..., 2])**0.5 # b term extraordinary #redefien optical data, setting epsc as optical_data = [(d, epsc, epsa)] #: create non-polarized input light field_data_in = dtmm.field.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize=PIXELSIZE) #: transfer input light through stack. We must split wavelength and compute for each wavelength. #: the algorithm computes epsv values from the cauchy coefficient for each of the wavelengths. field_data_out = dtmm.transfer_field(field_data_in, optical_data, split_wavelengths=True) #: visualize output field viewer = dtmm.pom_viewer(field_data_out) viewer.set_parameters(polarizer="h", analyzer="v", focus=-18) fig, ax = viewer.plot() plt.show()
optical_data = [ dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius=30, profile="r", no=1.5, ne=1.6, nhost=1.5) ] #: create non-polarized input light field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize=PIXELSIZE) #: transfer input light through stack field_data_out = dtmm.transfer_field(field_data_in, optical_data, diffraction=0, betamax=1) #: visualize output field # no diffraction to simulate output of standard jones method viewer1 = dtmm.field_viewer(field_data_out, diffraction=False) viewer1.set_parameters(sample=0, intensity=2, polarizer=0, analyzer=90) fig, ax = viewer1.plot() ax.set_title("diffraction = 0") field_data_out = dtmm.transfer_field(field_data_in, optical_data, diffraction=1, betamax=1) viewer2 = dtmm.field_viewer(field_data_out)
#optical_data[1][0,...]=1 #optical_data[1][-1,...]=1 window = dtmm.aperture((96, 96), 0.95, 0.) window = None #: create non-polarized input light field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, beta=0., pixelsize=PIXELSIZE, window=window) f, w, p = dtmm.transfer_field(field_data_in, optical_data, beta=0., phi=0., betamax=0.8, method="4x4", ret_bulk=True, npass=4, reflection=2, smooth=0.1) #must be even for 4x4 method viewer_bulk = dtmm.field_viewer((f, w, p), bulk_data=True) viewer_bulk.set_parameters(sample=0, intensity=1, polarizer=0, focus=0, analyzer=0) fig, ax = viewer_bulk.plot()
"""Hello nematic droplet example.""" import dtmm import numpy as np import matplotlib.pyplot as plt dtmm.conf.set_verbose(2) #: pixel size in nm PIXELSIZE = 200 #: compute box dimensions NLAYERS, HEIGHT, WIDTH = 60, 96, 96 #: illumination wavelengths in nm WAVELENGTHS = np.linspace(380,780,9) #: create some experimental data (stack) optical_data = dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius = 30, profile = "r", no = 1.5, ne = 1.6, nhost = 1.5) #: create non-polarized input light field_data_in = dtmm.field.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize = PIXELSIZE) #: transfer input light through stack field_data_out = dtmm.transfer_field(field_data_in, optical_data) #: visualize output field viewer = dtmm.pom_viewer(field_data_out) viewer.set_parameters(polarizer = "h", analyzer = "v", focus = -18) fig,ax = viewer.plot() plt.show()
"""Nematic droplet example using bulk data calculation and bulk viewer""" import dtmm import numpy as np #: pixel size in nm PIXELSIZE = 200 #: compute box dimensions NLAYERS, HEIGHT, WIDTH = 60, 96, 96 #: illumination wavelengths in nm WAVELENGTHS = [550] #: create some experimental data (stack) optical_data = dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius = 30, profile = "r", no = 1.5, ne = 1.6, nhost = 1.5) #: create non-polarized input light field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize = PIXELSIZE) #: transfer input light through stack and compute bulk EM field field_data_out = dtmm.transfer_field(field_data_in, optical_data, ret_bulk = True) #: visualize output field viewer = dtmm.field_viewer(field_data_out, bulk_data = True) viewer.set_parameters(sample = 0, intensity = 2, polarizer = 0, focus = 20, analyzer = 90) fig,ax = viewer.plot()
#NA 0.25, diaphragm with diameter 4 pixels, around 2*2*pi rays beta, phi, intensity = dtmm.illumination_rays(0.25, 4) window = dtmm.aperture((HEIGHT, WIDTH), 1, 0.1) field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, PIXELSIZE, beta, phi, intensity, window=window, n=1.5, focus=30) field_data_out = dtmm.transfer_field(field_data_in, optical_data, multiray=True, nin=1.5, nout=1.5) viewer = dtmm.field_viewer(field_data_out, sample=0, intensity=2, n=1.5, polarizer=0, focus=-30, analyzer=90, polarization="mode") fig, ax = viewer.plot() fig.show()
1 * np.sin(np.linspace(0, np.pi / 2048 * PIXELSIZE * WIDTH, WIDTH))**2) mod = eps_periodic() e[..., 2] = mod[None, None, :] window = dtmm.aperture((HEIGHT, WIDTH), 0.1, 1) #: create non-polarized input light field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, jones=(1, 0), pixelsize=PIXELSIZE, window=window) #: transfer input light through stack f, w, p = dtmm.transfer_field(field_data_in, (d, e, a), betamax=np.inf, diffraction=1) ff = np.fft.fftshift(dtmm.fft.fft2(f), axes=(-2, -1)) i = dtmm.field2specter(ff) cmf = dtmm.load_tcmf(w) c = dtmm.specter2color(i, cmf, norm=True) plt.imshow(c) plt.title("far field - fft of the near field") #: visualize output field viewer1 = dtmm.field_viewer((f, w, p), betamax=1) viewer1.set_parameters(sample=0, intensity=2, polarizer=None, focus=0,
] #using annular aperture, approximate ratio of aperture dimaters is inner/outer = 6/7 #: max NA is set to 0.7., this means input rays from NA of 0.6 to 0.7 beta, phi, intensity = dtmm.illumination_rays(0.7, (6, 7)) #: care must be taken when using high NA light source, we must usee a high betamax parameter field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, PIXELSIZE, beta, phi, intensity, focus=30, betamax=1) #: also in the calculation, we must perform it at high betamax field_data_out = dtmm.transfer_field(field_data_in, optical_data, multiray=True, betamax=1) # we must set the numarical aperture of the objective lower than the minimum NA of the illumination. viewer = dtmm.pom_viewer(field_data_out, intensity=10, NA=0.5, focus=-20, beta=beta) fig, ax = viewer.plot() fig.show()
window = dtmm.aperture((96, 96), 0.95, 0.) window = None #: create non-polarized input light (fin2, w, p) = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, beta=0., pixelsize=PIXELSIZE, window=window) (fin4, w, p) = (fin2.copy(), w, p) (f2, w, p) = dtmm.transfer_field((fin2, w, p), optical_data, beta=0., phi=0., betamax=betamax, method="2x2", ret_bulk=False, npass=9, reflection=2) (f4, w, p) = dtmm.transfer_field((fin4, w, p), optical_data, beta=0., phi=0., betamax=betamax, method="4x4", ret_bulk=False, npass=9, reflection=2)
#: some experimental data BETA = 0.4 epsv = dtmm.refind2eps([4,4,4]) #high reflective index medium, to increase reflections. epsa = (0.,0.,0.) optical_data = [(THICKNESS, epsv, epsa)] window = dtmm.aperture((HEIGHT, WIDTH),0.2,1) #illumination data is focused at the top (exit) surface (actual focus = focus * ref_ind = 25*4=100) field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, window = window, beta = BETA, pixelsize = PIXELSIZE,focus = 25.,n=1) #illumination filed is defined in vacuum, so we make input and output medium with n = 1. field_data_out = dtmm.transfer_field(field_data_in, optical_data, beta = BETA, phi = 0., reflection = 2, diffraction =1, npass = 3, method = "2x2",nin = 1, nout = 1) #we are viewing computed data in vacuum, so set n = 1. viewer4 = dtmm.field_viewer(field_data_in, mode = "t", intensity = 1,n = 1.) fig4,ax4 = viewer4.plot() ax4.set_title("Input field") #: visualize output field viewer1 = dtmm.field_viewer(field_data_out, mode = "t",intensity = 1,n = 1.) fig1,ax1 = viewer1.plot() ax1.set_title("Transmitted field") #: residual back propagating field is close to zero viewer2 = dtmm.field_viewer(field_data_out, mode = "r",intensity = 1,n = 1.) fig2,ax2 = viewer2.plot()
temp_director = dtmm.nematic_droplet_director(shape, radius, "r") # Export the data to a text file temp_director.tofile("director.txt", sep=",") # --- Read in director and convert optical data # Read director from text file director = dtmm.read_director("director.txt", (n_layers, height, width, 3), sep=",") # Create the mask for a spherical mask = dtmm.sphere_mask(shape, radius) # Covert director, mask, and physical parameters into optical data optical_data = dtmm.director2data(director, mask, no, ne, nhost) # ---- # Generate wavelengths wavelengths = np.linspace(380, 780, 9) # Size of each pixel in nm pixel_size = 200 # Generate input light field input_light_field = dtmm.field.illumination_data((height, width), wavelengths, pixel_size) # Generate output light field using 4x4 method output_light_field = dtmm.transfer_field(input_light_field, optical_data, method="4x4") #: visualize output field viewer = dtmm.field_viewer(output_light_field) viewer.set_parameters(focus=-14, intensity=2, sample=0, analyzer=90, polarizer=0) fig, _ = viewer.plot() # Show figure fig.show()
None, :]) optical_data = (d, eps_values[:, None, None, :], eps_angles[:, None, None, :]) #: create non-polarized input light field_data_in = dtmm.field.illumination_data((1, 1), wavelengths, beta=beta, phi=phi, diffraction=False, pixelsize=step) #: transfer input light through stack field_data_out = dtmm.transfer_field(field_data_in, optical_data, beta=beta, phi=phi, method="2x2", reflection=2, diffraction=False) f, w, p = field_data_out Txx2 = field2poynting(dotmf( x_polarizer, f[0]))[..., 0, 0] * 2 #times two, because field_data_in[0][0] has intensity of 0.5 Tyx2 = field2poynting(dotmf(y_polarizer, f[0]))[..., 0, 0] * 2 Txy2 = field2poynting(dotmf( x_polarizer, f[1]))[..., 0, 0] * 2 #times two, because field_data_in[0][1] has intensity of 0.5 Tyy2 = field2poynting(dotmf(y_polarizer, f[1]))[..., 0, 0] * 2
"""Hello nematic droplet example.""" import dtmm import numpy as np import matplotlib.pyplot as plt dtmm.conf.set_verbose(2) #: pixel size in nm PIXELSIZE = 200 #: compute box dimensions NLAYERS, HEIGHT, WIDTH = 60, 96, 96 #: illumination wavelengths in nm WAVELENGTHS = np.linspace(380,780,9) #: create some experimental data (stack) optical_block = dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius = 30, profile = "r", no = 1.5, ne = 1.6, nhost = 1.5) #: create non-polarized input light field_data_in = dtmm.field.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize = PIXELSIZE) #: transfer input light through stack field_data_out = dtmm.transfer_field(field_data_in, [optical_block]) #: visualize output field viewer = dtmm.pom_viewer(field_data_out) viewer.set_parameters(polarizer = "h", analyzer = "v", focus = -18) fig,ax = viewer.plot() plt.show()
window = dtmm.aperture((HEIGHT, WIDTH), 1, 0.1) field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, PIXELSIZE, beta, phi, intensity, window=window, n=1.3, focus=30) field_data_out = dtmm.transfer_field(field_data_in, optical_data, multiray=True, split_rays=False, nin=1.3, nout=1.3, betamax=1., diffraction=1, reflection=1) #: visualize output field viewer = dtmm.field_viewer(field_data_out, betamax=1., n=1.3) viewer.set_parameters(sample=0, intensity=1, polarizer=None, focus=-14, analyzer=None) fig, ax = viewer.plot()