4.1. Development of video using Matplotlib

from diffractio import degrees, mm, plt, sp, um, np
from diffractio.scalar_sources_X import Scalar_source_X
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.scalar_masks_XZ import Scalar_mask_XZ
from numpy.fft import fft, ifft
from scipy.signal import convolve2d
number of processors: 8
# size of figures
%matplotlib inline

import matplotlib

4.1.1. Generates a XZ field and show plots for each z

# Initial parameters
x0 = np.linspace(-250 * um, 250 * um, 1024*1)
z0 = np.linspace(-0.125*um, 750 * um, 1024*2)
wavelength = 0.6238 * um*10

# Definition of source
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
# insert sphere
u1.sphere(r0=(0,250*um), radius=(200*um,200*um),refraction_index=1.5, angle=0)
u1.draw_refraction_index(scale='scaled', colorbar_kind='horizontal');
# propagation
u1.draw(logarithm=True, scale='scaled', draw_borders=True);
u1.video(kind='intensity',logarithm=True,normalize=False, time_video=10 * seconds, frames_reduction=5,
         filename='creating_video.mp4', dpi=300)

<div align="middle">
<video width="50%" controls>
      <source src="creating_video.mp4" type="video/mp4">

Windows: Perphaps, video generation is not valid for Windows. In this case, you can create the .png figures and use an external program.