-
-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathhexagonal_grating.py
More file actions
21 lines (16 loc) · 661 Bytes
/
hexagonal_grating.py
File metadata and controls
21 lines (16 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import diffractsim
diffractsim.set_backend("CPU") #Change the string to "CUDA" to use GPU acceleration
from diffractsim import PolychromaticField, ApertureFromImage, Lens, cf, mm, cm
F = PolychromaticField(
spectrum=2.0 * cf.illuminant_d65,
extent_x=20.0 * mm,
extent_y=20.0 * mm,
Nx=1000,
Ny=1000,
spectrum_size = 200, spectrum_divisions = 50 # increase these values to improve color resolution
)
F.add(ApertureFromImage("./apertures/hexagon_grating.jpg", image_size=(15 * mm, 15 * mm), simulation = F))
F.add(Lens(f = 100*cm))
F.propagate(z= 100*cm)
rgb =F.get_colors()
F.plot_colors(rgb, xlim=[-9*mm, 9*mm], ylim=[-9*mm, 9*mm])