6.4.4. 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
[2]:
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, refractive_index=1.5, angle=45 * degrees)

[3]:
u1.draw_refractive_index()
../../../_images/source_tutorial_drawing_interactive_in_diffractio_4_0.png
[4]:
u1.WPM(verbose=False)
[5]:
u1.draw(kind='intensity', draw_borders=True)
../../../_images/source_tutorial_drawing_interactive_in_diffractio_6_0.png
[6]:
%matplotlib widget


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

ae0923d1882746b6be2cd6f265dd3654

[ ]: