4.3. Interactive internal to diffractioΒΆ

To include the figures into the jupyter notebook: - %matplotlib inline

To draw the figures in external windows: - %matplotlib qt - %matplotlib notebook - %matplotlib widgets

To install widgets: - pip3 install ipympl - pip3 install nodejs - jupyter labextension install @jupyter-widgets/jupyterlab-manager - jupyter labextension install jupyter-matplotlib

Windows: If you use windows: pip3 -> pip

[1]:
from diffractio import degrees, mm, plt, sp, um, np
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.scalar_masks_XZ import Scalar_mask_XZ
from diffractio.scalar_sources_X import Scalar_source_X
number of processors: 8
[9]:
%matplotlib inline

from matplotlib import rcParams
rcParams['figure.figsize']=(5,5)
rcParams['figure.dpi']=200
[10]:
x0 = np.linspace(-110 * um, 110 * um, 2048)
z0 = np.linspace(-110 * um, 110 * um, 2048)
wavelength = 1 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1, x0=0 * um, z0=80 * um, w0=40 * um, theta=0 * degrees)

u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.layer(r0=(50, 0), depth=100 * um, refraction_index=1.5, angle=45 * degrees);
[11]:
u1.draw_refraction_index()
[11]:
<matplotlib.image.AxesImage at 0x7f6a630f6880>
../../../_images/source_tutorial_drawing_interactive_in_diffractio_5_1.png
[12]:
u1.WPM(verbose=False)
[15]:
u1.draw(kind='intensity', draw_borders=True)
[15]:
<matplotlib.image.AxesImage at 0x7f6a63099640>
[14]:
%matplotlib widget
%matplotlib widget

u1.draw_profiles_interactive(
    kind='intensity', logarithm=True, normalize=False);
[ ]: