diff --git a/bahtinov.ipynb b/bahtinov.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..3e2fd7a6543056e9aa7410c21b2a0bcf6f79c4c3 --- /dev/null +++ b/bahtinov.ipynb @@ -0,0 +1,140 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "9c99c583", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "number of processors: 4\n", + "total memory : 7.6 Gb\n", + "available memory : 48 %\n", + "max frequency : 2900 GHz\n" + ] + } + ], + "source": [ + "import cv2\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "from diffractio import um, nm, mm, np, degrees\n", + "from diffractio.scalar_sources_XY import Scalar_source_XY\n", + "from diffractio.scalar_fields_XY import Scalar_field_XY\n", + "from diffractio.scalar_masks_XY import Scalar_mask_XY\n", + "from ipywidgets import interact, fixed" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "id": "303e2923", + "metadata": { + "scrolled": false + }, + "outputs": [], + "source": [ + "%matplotlib notebook\n", + "mask = cv2.imread(\"BahtinovMask.png\", cv2.IMREAD_GRAYSCALE)\n", + "mask = np.pad(mask, 2*len(mask))\n", + "\n", + "h, w = 1024, 1024\n", + "mask = cv2.resize(mask, (w, h))\n", + "length = 10*mm\n", + "x0 = np.linspace(-length/2, length/2, 1024)\n", + "y0 = np.linspace(-length/2, length/2, 1024)\n", + "wavelength = 0.580 * um\n", + "u0 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)\n", + "t1 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "id": "2632f9d4", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "59d03f045dc047d3a05059bc6dc3a370", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(FloatSlider(value=500.0, description='z', max=1000.0, step=5.0), Output()), _dom_classes…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "<function __main__.propagate(z)>" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%matplotlib inline\n", + "def propagate(z):\n", + " u0 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)\n", + " u0.RS(z=10*mm, new_field=False)\n", + " t0 = Scalar_mask_XY(x=x0, y=y0, wavelength=wavelength)\n", + " t0.circle((0, 0), 1*mm)\n", + " u0 = u0*t0\n", + " u0.RS(z=z, new_field=False)\n", + " \n", + " #u0 = u0.RS(z=10*mm)\n", + " u0.draw(logarithm=True)\n", + "interact(propagate, z=(0*mm, 1*mm, 0.005*mm))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "93fcb03e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "03bc9175", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}