Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andykee committed Feb 1, 2024
1 parent aec0280 commit 66f6d63
Show file tree
Hide file tree
Showing 20 changed files with 161 additions and 326 deletions.
Binary file modified docs/examples/_thumbnails/broadband_diffraction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/examples/_thumbnails/broadband_diffraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
psf += w2.intensity

fig, ax = plt.subplots()
ax.imshow(psf, norm='log')
ax.imshow(psf, norm='log', cmap='inferno')
ax.axis('off')
fig.savefig('broadband_diffraction.png', dpi=150, bbox_inches='tight')
Binary file added docs/examples/_thumbnails/dispersion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions docs/examples/_thumbnails/dispersion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import matplotlib.pyplot as plt
import numpy as np
import lentil

amp = lentil.circle(shape=(256,256), radius=120)

pupil = lentil.Pupil(amplitude=amp, opd=0, pixelscale=1/240,
focal_length=10)

trace = [1, 0]
dispersion = [3e-4, 550e-9]
dispersive_element = lentil.DispersiveTilt(trace=trace, dispersion=dispersion)


shape = (128,128)
oversample = 3
out = np.zeros((shape[0]*oversample, shape[1]*oversample))

for wave in np.linspace(475, 625, 150):
w0 = lentil.Wavefront(wavelength=wave*1e-9)
w1 = w0 * pupil
w2 = w1 * dispersive_element
w3 = lentil.propagate_dft(w2, shape=shape, prop_shape=(32, 32),
pixelscale=5.5e-6, oversample=oversample)

out = w3.insert(out)

fig, ax = plt.subplots()
ax.imshow(out, cmap='inferno')
ax.axis('off')
fig.savefig('dispersion.png', dpi=150, bbox_inches='tight')
Binary file modified docs/examples/_thumbnails/simple_diffraction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/examples/_thumbnails/simple_diffraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
w1 = w0 * pupil
w2 = lentil.propagate_dft(w1, shape=(64,64), pixelscale=5e-6, oversample=4)
fig, ax = plt.subplots()
ax.imshow(w2.intensity, norm='log', vmin=10e-5)
ax.imshow(w2.intensity, norm='log', vmin=10e-5, cmap='inferno')
ax.axis('off')
fig.savefig('simple_diffraction.png', dpi=150, bbox_inches='tight')
Binary file added docs/examples/_thumbnails/tilt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions docs/examples/_thumbnails/tilt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import matplotlib.pyplot as plt
import numpy as np
import lentil

amp = lentil.circle(shape=(256,256), radius=120)
amp -= lentil.circle(shape=(256,256), radius=40)
for angle in (0, 90, 180, 270):
amp *= lentil.spider((256,256), 2, angle)
opd = lentil.zernike_compose(amp, (0, 3.5e-6, -2e-6))
pupil = lentil.Pupil(amplitude=amp, opd=opd, pixelscale=1/240,
focal_length=10)
w0 = lentil.Wavefront(wavelength=500e-9)
w1 = w0 * pupil
w2 = lentil.propagate_dft(w1, shape=(64,64), pixelscale=5e-6, oversample=4)
fig, ax = plt.subplots()
ax.imshow(w2.intensity, norm='log', vmin=10e-5, cmap='inferno')
ax.axis('off')
fig.savefig('tilt.png', dpi=150, bbox_inches='tight')
64 changes: 64 additions & 0 deletions docs/examples/dispersion.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. _examples.dispersion:

*******************
Modeling dispersion
*******************

.. plot::
:context: reset
:include-source:
:scale: 50

import matplotlib.pyplot as plt
import numpy as np
import lentil

amp = lentil.circle(shape=(256,256), radius=120)

pupil = lentil.Pupil(amplitude=amp, opd=0, pixelscale=1/240,
focal_length=10)

trace = [1, 0] # y = x
dispersion = [3e-4, 550e-9] # center wavelength = 550 nm
dispersive_element = lentil.DispersiveTilt(trace=trace, dispersion=dispersion)

shape = (128,128)
oversample = 3
out = np.zeros((shape[0]*oversample, shape[1]*oversample))

fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(6,3))

# dispersed PSF @ 475 nm
w0 = lentil.Wavefront(475e-9)
w1 = w0 * pupil
w2 = w1 * dispersive_element
w3 = lentil.propagate_dft(w2, shape=shape, prop_shape=(32, 32),
pixelscale=5.5e-6, oversample=oversample)
ax[0].imshow(w3.intensity, cmap='inferno')
ax[0].set_title('$\lambda$ = 475 nm')
ax[0].axis('off')

# dispersed PSF @ 625 nm
w0 = lentil.Wavefront(625e-9)
w1 = w0 * pupil
w2 = w1 * dispersive_element
w3 = lentil.propagate_dft(w2, shape=shape, prop_shape=(32, 32),
pixelscale=5.5e-6, oversample=oversample)
ax[1].imshow(w3.intensity, cmap='inferno')
ax[1].set_title('$\lambda$ = 625 nm')
ax[1].axis('off')

# broadband dispersion
for wave in np.linspace(475, 625, 150):
w0 = lentil.Wavefront(wavelength=wave*1e-9)
w1 = w0 * pupil
w2 = w1 * dispersive_element
w3 = lentil.propagate_dft(w2, shape=shape, prop_shape=(32, 32),
pixelscale=5.5e-6, oversample=oversample)

out = w3.insert(out)


ax[2].imshow(out, cmap='inferno')
ax[2].set_title('$\lambda$ = [475 625] nm')
ax[2].axis('off')
78 changes: 41 additions & 37 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This page contains examples and useful model design patterns.

.. _examples.end_to_end:

End-to-end simulations
======================
Numerical diffraction propagation
=================================

.. grid:: 3

Expand Down Expand Up @@ -51,62 +51,49 @@ End-to-end simulations
:link-type: doc
:margin: 2 2 0 0

Diffraction simulation with large tilt

.. grid-item-card::
:margin: 2 2 0 0
.. image:: /examples/_thumbnails/tilt.png
:width: 175px
:align: center

Radiometrically correct propagation
Diffraction simulation with large tilt

.. grid-item-card::
:link: dispersion
:link-type: doc
:margin: 2 2 0 0

Including a detector model

.. grid-item-card::
:margin: 2 2 0 0
.. image:: /examples/_thumbnails/dispersion.png
:width: 175px
:align: center

Image simulation
Modeling dispersion


.. toctree::
:caption: End-to-end simulations
:caption: Numerical diffraction propagation
:hidden:

simple
broadband
segmented
tilt
dispersion


Focal plane modeling
====================

.. _examples.useful_patterns:

Useful patterns
===============

.. toctree::
:caption: Useful patterns
:hidden:

planes/filter_wheel
planes/rb_element
planes/translation_stage

.. grid:: 3

.. _examples.radiometry:
.. grid-item-card::
:margin: 2 2 0 0

Radiometry
==========
Including a detector model

.. toctree::
:caption: Radiometry
:hidden:
.. grid-item-card::
:margin: 2 2 0 0

radiometry/propagation
radiometry/source_coupling
radiometry/self_emission
radiometry/complex_sources
radiometry/source_defocus
Modeling a Bayer detector


.. _examples.advanced:
Expand All @@ -116,6 +103,22 @@ Advanced usage

.. grid:: 3

.. grid-item-card::
:margin: 2 2 0 0

Image simulation

.. grid-item-card::
:link: radiometry
:link-type: doc
:margin: 2 2 0 0

.. image:: /examples/_thumbnails/matlab.png
:width: 175px
:align: center

Radiometrically correct propagations

.. grid-item-card::
:link: matlab_interface
:link-type: doc
Expand All @@ -132,6 +135,7 @@ Advanced usage
:caption: Advanced usage
:hidden:

radiometry
matlab_interface


Expand Down
128 changes: 0 additions & 128 deletions docs/examples/planes/filter_wheel.rst

This file was deleted.

Loading

0 comments on commit 66f6d63

Please sign in to comment.