コード例 #1
0
#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()
コード例 #2
0
                                     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")

#: residual back propagating field is close to zero
viewer2 = dtmm.field_viewer(field_data_out, mode="r", n=1.5)
fig2, ax2 = viewer2.plot()
ax2.set_title("Residual field")

viewer3 = dtmm.field_viewer(field_data_in,
                            mode="r",
                            n=1.5,
                            polarization_mode="mode",
                            polarizer="LCP",
コード例 #3
0
ax1.plot(ws, r_lcp, label="lcp mode {} ".format(mode))
ax2.plot(ws, t_rcp, label="rcp mode 0")
ax2.plot(ws, t_lcp, label="lcp mode 0")

ax1.set_title("reflection")
ax1.set_xlabel("wavelength")
ax2.set_title("transmission")
ax2.set_xlabel("wavelength")

ax1.legend()
ax2.legend()

viewer1 = dtmm.field_viewer(field_data_in,
                            mode="r",
                            n=1.5,
                            focus=0,
                            intensity=1,
                            cols=cols,
                            rows=rows,
                            analyzer="h")
viewer2 = dtmm.field_viewer(field_data_out,
                            mode="t",
                            n=1.5,
                            focus=0,
                            intensity=1,
                            cols=cols,
                            rows=rows,
                            analyzer="h")

fig, ax = viewer1.plot()
ax.set_title("Reflected field")
コード例 #4
0
                              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)
viewer2.set_parameters(sample=0,
                       intensity=2,
                       polarizer=0,
                       focus=-14,
                       analyzer=90)
コード例 #5
0
#: 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,
                       analyzer=0)

fig, ax = viewer1.plot(fmax=1000)
ax.set_title("near field")
fig.show()
コード例 #6
0
ファイル: viewer_bulk_data.py プロジェクト: xj361685640/dtmm
"""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()
コード例 #7
0
                                 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)

viewer2in = dtmm.field_viewer((fin2, w, p),
                              bulk_data=False,
                              n=1,
                              mode="r",
                              betamax=NA)
viewer2in.set_parameters(sample=0, intensity=1, polarizer=0, analyzer=0)

fig, ax = viewer2in.plot()

viewer4in = dtmm.field_viewer((fin4, w, p),
                              bulk_data=False,
                              n=1,
                              mode="r",
                              betamax=NA)
viewer4in.set_parameters(sample=0, intensity=1, polarizer=0, analyzer=0)

fig, ax = viewer4in.plot()
コード例 #8
0
#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()
コード例 #9
0

cmat = dtmm.tmm.stack_mat(kd, epsv, epsa, method = "4x4")
fout_4x4 = dtmm.tmm.transmit(ft,cmat)
fout_4x4_ref = dtmm.tmm.transfer(ft, kd, epsv, epsa, method = "4x4", reflect_out = True)
assert np.allclose(fout_4x4, fout_4x4_ref)

# inverse transpose to build field data for visualization
field_data_out_2x2 = dtmm.field.fvec2field(fout_2x2),w,p
field_data_out_2x4 = dtmm.field.fvec2field(fout_2x4),w,p
field_data_out_4x2 = dtmm.field.fvec2field(fout_4x2),w,p
field_data_out_4x4 = dtmm.field.fvec2field(fout_4x4),w,p


#: visualize output field
viewer1 = dtmm.field_viewer(field_data_out_2x2, diffraction = False)
viewer1.set_parameters(sample = 45, intensity = 2,
                polarizer = 0, analyzer = 90)

fig,ax = viewer1.plot()
ax.set_title("2x2 method (jones method, no reflections)")
fig.show()

viewer2 = dtmm.field_viewer(field_data_out_2x4, diffraction = False )
viewer2.set_parameters(sample = 45, intensity = 2,
                polarizer = 0,  analyzer = 90)

fig,ax = viewer2.plot()
ax.set_title("2x4 method (jones method, with reflections)")
fig.show()
コード例 #10
0
ファイル: hello_world.py プロジェクト: Alex-Vasile/dtmm
#: 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)
window = dtmm.aperture((96, 96))

#: 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.field_viewer(field_data_out)
viewer.set_parameters(sample=0,
                      intensity=2,
                      polarizer=0,
                      focus=-14,
                      analyzer=90)
fig, ax = viewer.plot()
コード例 #11
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()
ax2.set_title("Residual field")

viewer3 = dtmm.field_viewer(field_data_in, mode = "r", intensity = 1,n = 1.)
fig3,ax3 = viewer3.plot()
コード例 #12
0
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()
コード例 #13
0
#: 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.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, 
                                            pixelsize = PIXELSIZE) 
#: transfer input light through stack
field_data_out = dtmm.transfer_field(field_data_in, optical_data)

#: here we load illuminant A tcmf table, but you can provide your own light source.
# the illuminant argument defines the name or path to the illuminant data.
# Illuminant data format is a two column txt data file. The first column defines
# wavelength in nm, the second column the intensity  (normalization is 
# performed automatically when loading).

cmf = dtmm.load_tcmf(WAVELENGTHS, illuminant = "A")

#: visualize output field
viewer = dtmm.field_viewer(field_data_out, cmf = cmf)
viewer.set_parameters(sample = 0, intensity = 2,
                polarizer = 0, focus = -18, analyzer = 90)

fig,ax = viewer.plot()
コード例 #14
0
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()
コード例 #15
0
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,
                            analyzer=None)
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", n=1.5)
fig2, ax2 = viewer2.plot()
ax2.set_title("Residual field")

viewer3 = dtmm.field_viewer(field_data_in, mode="r", n=1.5)
fig3, ax3 = viewer3.plot()
ax3.set_title("Reflected field")