Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
obv_experimente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joris Nonnast
obv_experimente
Commits
57d861f9
Commit
57d861f9
authored
3 years ago
by
Joris Nonnast
Browse files
Options
Downloads
Patches
Plain Diff
add bahtinov notebook
parent
5728f872
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bahtinov.ipynb
+140
-0
140 additions, 0 deletions
bahtinov.ipynb
with
140 additions
and
0 deletions
bahtinov.ipynb
0 → 100644
+
140
−
0
View file @
57d861f9
{
"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
}
%% Cell type:code id:9c99c583 tags:
```
python
import
cv2
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
diffractio
import
um
,
nm
,
mm
,
np
,
degrees
from
diffractio.scalar_sources_XY
import
Scalar_source_XY
from
diffractio.scalar_fields_XY
import
Scalar_field_XY
from
diffractio.scalar_masks_XY
import
Scalar_mask_XY
from
ipywidgets
import
interact
,
fixed
```
%% Output
number of processors: 4
total memory : 7.6 Gb
available memory : 48 %
max frequency : 2900 GHz
%% Cell type:code id:303e2923 tags:
```
python
%
matplotlib
notebook
mask
=
cv2
.
imread
(
"
BahtinovMask.png
"
,
cv2
.
IMREAD_GRAYSCALE
)
mask
=
np
.
pad
(
mask
,
2
*
len
(
mask
))
h
,
w
=
1024
,
1024
mask
=
cv2
.
resize
(
mask
,
(
w
,
h
))
length
=
10
*
mm
x0
=
np
.
linspace
(
-
length
/
2
,
length
/
2
,
1024
)
y0
=
np
.
linspace
(
-
length
/
2
,
length
/
2
,
1024
)
wavelength
=
0.580
*
um
u0
=
Scalar_source_XY
(
x
=
x0
,
y
=
y0
,
wavelength
=
wavelength
)
t1
=
Scalar_mask_XY
(
x
=
x0
,
y
=
y0
,
wavelength
=
wavelength
)
```
%% Cell type:code id:2632f9d4 tags:
```
python
%
matplotlib
inline
def
propagate
(
z
):
u0
=
Scalar_source_XY
(
x
=
x0
,
y
=
y0
,
wavelength
=
wavelength
)
u0
.
RS
(
z
=
10
*
mm
,
new_field
=
False
)
t0
=
Scalar_mask_XY
(
x
=
x0
,
y
=
y0
,
wavelength
=
wavelength
)
t0
.
circle
((
0
,
0
),
1
*
mm
)
u0
=
u0
*
t0
u0
.
RS
(
z
=
z
,
new_field
=
False
)
#u0 = u0.RS(z=10*mm)
u0
.
draw
(
logarithm
=
True
)
interact
(
propagate
,
z
=
(
0
*
mm
,
1
*
mm
,
0.005
*
mm
))
```
%% Output
<function __main__.propagate(z)>
%% Cell type:code id:93fcb03e tags:
```
python
``
`
%%
Cell
type
:
code
id
:
03
bc9175
tags
:
```
python
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment