-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some plots, move GS to threadripper
- Loading branch information
1 parent
8befa52
commit 691e9f8
Showing
23 changed files
with
346 additions
and
57 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
from .utils import * | ||
from .linearity import * | ||
from matplotlib import pyplot as plt | ||
|
||
from .experiments.calibrate_dm import * | ||
from .experiments.lantern_reader import * | ||
from .experiments.seal import * | ||
|
||
from .simulations.lantern_optics import * | ||
from .simulations.optics import * | ||
from .simulations.pyramid_optics import * | ||
from .simulations.second_stage import * | ||
plt.rc('font', family='serif',size=12) | ||
plt.rcParams.update({ | ||
"text.usetex": False, | ||
"font.family": "serif", | ||
"font.serif" : "cmr10", | ||
"axes.formatter.use_mathtext" : True | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from datetime import datetime | ||
from astropy.io import fits | ||
|
||
# Copilot experiment to help me get over procrastinating on making a standard format for lantern outputs. | ||
def create_fits_file(commands, science_images, exposure_time=10.0, dark_frame=None, output_path='/path/to/output.fits'): | ||
# Create a new FITS file | ||
fits_file = fits.HDUList() | ||
|
||
# Add a primary header | ||
primary_header = fits.Header() | ||
primary_header['DATE-OBS'] = datetime.now().isoformat() | ||
fits_file.append(fits.PrimaryHDU(header=primary_header)) | ||
|
||
# Add camera exposure time | ||
fits_file[0].header['EXPTIME'] = exposure_time | ||
|
||
# Add dark frame image | ||
if dark_frame is not None: | ||
fits_file.append(fits.ImageHDU(data=dark_frame, name='DARK_FRAME')) | ||
|
||
# Add deformable mirror commands and science images | ||
for command, science_image in zip(commands, science_images): | ||
fits_file.append(fits.ImageHDU(data=command, name='COMMAND')) | ||
fits_file.append(fits.ImageHDU(data=science_image, name='SCIENCE_IMAGE')) | ||
|
||
# Save the FITS file | ||
fits_file.writeto(output_path, overwrite=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,64 @@ | ||
# %% | ||
from photonics.simulations.lantern_optics import LanternOptics | ||
from photonics.simulations.optics import Optics | ||
from hcipy import imshow_field | ||
from photonics.utils import nanify | ||
import numpy as np | ||
from matplotlib import pyplot as plt | ||
from tqdm import trange | ||
|
||
lo = LanternOptics(f_number=10.0) | ||
# %% | ||
lo.show_GS(3, -0.5, niter=10) | ||
optics = Optics(lantern_fnumber=6.5) | ||
lo = LanternOptics(optics) | ||
# %% | ||
lo.show_GS(optics, 3, 0.5, niter=10) | ||
# %% | ||
gs_ret = lo.GS( | ||
optics, | ||
lo.forward( | ||
optics, | ||
optics.zernike_to_pupil(3, 0.1) | ||
).intensity, | ||
niter=20 | ||
) | ||
# %% | ||
optics.zernike_basis.coefficients_for(optics.zernike_to_pupil(3, 0.1).phase)[:lo.nmodes] | ||
# %% | ||
optics.zernike_basis.coefficients_for(gs_ret.phase)[:lo.nmodes] | ||
# %% | ||
imshow_field(nanify(gs_ret.phase - np.mean(gs_ret.phase), optics.aperture), cmap="RdBu") | ||
plt.gca().set_axis_off() | ||
# %% | ||
z_applied = 2 | ||
a_applied = -0.5 | ||
zdecomps = [] | ||
EM_in, measured_in, measured_out = lo.GS_init( | ||
optics, | ||
lo.forward( | ||
optics, | ||
optics.zernike_to_pupil(z_applied, a_applied) | ||
).intensity | ||
) | ||
zdecomps.append( | ||
optics.zernike_basis.coefficients_for(EM_in.phase)[:lo.nmodes] | ||
) | ||
for i in trange(4): | ||
EM_in = lo.GS_iteration(optics, EM_in, measured_in, measured_out) | ||
zdecomps.append( | ||
optics.zernike_basis.coefficients_for(EM_in.phase)[:lo.nmodes] | ||
) | ||
|
||
zdecomps = np.array(zdecomps).T | ||
|
||
# %% | ||
plt.hlines(a_applied, 0, zdecomps.shape[1] - 1, label="Target") | ||
for (i, r) in enumerate(zdecomps): | ||
if i == z_applied: | ||
plt.plot(r, alpha=1, label="Injected mode", color="k") | ||
else: | ||
plt.plot(r, alpha=0.1, color="r") | ||
plt.xticks(np.arange(0, zdecomps.shape[1], 4)) | ||
plt.xlabel("Gerchberg-Saxton iteration") | ||
plt.ylabel("Amplitude (rad)") | ||
plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.) | ||
plt.subplots_adjust(right=0.8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
\documentclass{article} | ||
|
||
\usepackage{custom} | ||
\usepackage{tikz} | ||
\usetikzlibrary{shapes,arrows,positioning,decorations.pathmorphing} | ||
|
||
\begin{document} | ||
\tikzstyle{block} = [draw, rectangle, | ||
minimum height=3em, minimum width=6em] | ||
\tikzstyle{sum} = [draw, fill=white, circle, node distance=1cm] | ||
\tikzstyle{input} = [coordinate] | ||
\tikzstyle{output} = [coordinate] | ||
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}] | ||
\tikzstyle{gain} = [draw, fill=white, isosceles triangle, isosceles triangle apex angle = 60, shape border rotate=#1] | ||
|
||
\tikzset{snake it/.style={decorate, decoration=snake}} | ||
|
||
\begin{tikzpicture}[auto, node distance=3cm,>=latex', text width=2.2cm, align=center] | ||
\node [name=disturbance] {Atmospheric disturbance}; | ||
\node [sum, below of=disturbance, node distance=2cm, text width=0.5cm] (dm) {+}; | ||
\node [draw, rectangle, below of=dm, node distance=2cm, minimum height=2em, minimum width=2em, text width=0.1cm, color=gray] (beamsplitter) {}; | ||
\node [input, below right=1em and 1em of beamsplitter.center, anchor=center] (beamsplitterbr) {}; | ||
\node [input, above left=1em and 1em of beamsplitter.center, anchor=center] (beamsplittertl) {}; | ||
\node [input, below of=beamsplitter, node distance=2cm] (turn) {}; | ||
\node [name=beamsplittertext, left of=beamsplitter, node distance=1.0cm] {Beam\\splitter}; | ||
\node [block, minimum height=5em] (dmblock) at (dm) {}; | ||
\node [above right=1.5em and 2em of dmblock.center, anchor=center] (dmtext) {DM}; | ||
\node [block, right of=turn] (pl) {Science image}; | ||
\node [block, right of=beamsplitter] (pywfs) {Wavefront sensor}; | ||
\node [block, right of=pywfs,] (pyrecon) {Wavefront reconstructor}; | ||
\node [input, right of=pyrecon, node distance=1.5cm] (pyswitch) {}; | ||
\node [input, above of=pyswitch, node distance=0.9cm] (turn4) {}; | ||
\node [input, right of=pyrecon, text width=0.5cm, node distance=2cm] (sum2) {}; | ||
\node [input, above of=sum2, node distance=2cm] (turn3) {}; | ||
\node [gain, left of=turn3, shape border rotate=-180, text width=0.8cm, node distance=1.5cm] (gain) {Gain}; | ||
\node [block, left of=gain, node distance=3cm] (integ) {Integrator}; | ||
\node [input, left of=turn, node distance=1.05cm] (wave) {}; | ||
|
||
\path[draw,->] (disturbance) -- (dm); | ||
\path[draw,->] (dm) -- (beamsplitter.center); | ||
\path[draw,-,color=gray] (beamsplittertl) -- (beamsplitterbr); | ||
\path[draw,->] (beamsplitter.center) -- (pywfs); | ||
\path[draw,->] (pywfs) -- (pyrecon); | ||
\path[draw,-] (pyrecon) -- (sum2); | ||
\path[draw,-] (beamsplitter.center) -- (turn); | ||
\path[draw,->] (turn) -- (pl); | ||
\path[draw,-] (sum2) -- (turn3); | ||
\path[draw,->] (turn3) -- (gain); | ||
\path[draw,->] (gain) -- (integ); | ||
\path[draw,->] (integ) -- (dm) node[above, pos=0.95] {--}; | ||
\path[draw,->, snake it, color=red] (wave) -- (turn) node[left, pos=0.7] {NCPA}; | ||
\end{tikzpicture} | ||
\end{document} |
Binary file not shown.
Oops, something went wrong.