Skip to content

Commit

Permalink
completed PAOS demo with marimo notebook/app
Browse files Browse the repository at this point in the history
  • Loading branch information
abocchieri committed Dec 25, 2024
1 parent 8af5b41 commit 4340a61
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions notebook/paos_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def _(mo):
return


@app.cell
def _(mo):
mo.md(r"""## Select .ini config file""")
return


@app.cell
def _(mo, os):
file_path = "../lens data/"
Expand All @@ -25,10 +31,16 @@ def _(mo, os):
return file_browser, file_path


@app.cell
def _(mo):
mo.md(r"""## Set field and wavelength""")
return


@app.cell
def _(mo):
field_s = mo.ui.text("0.0", label=r"Field x [$^{\circ}$]")
field_t = mo.ui.text("0.003", label=r"Field y [$^{\circ}$]")
field_t = mo.ui.text("0.0", label=r"Field y [$^{\circ}$]")

mo.hstack([field_s, field_t], justify="start")
return field_s, field_t
Expand All @@ -42,12 +54,18 @@ def _(mo):
return (wavelength,)


@app.cell
def _(mo):
mo.md(r"""## Play with PAOS""")
return


@app.cell
def _(compute_raytrace, file_browser, mo):
mo.stop(file_browser.path() is None)

mo.accordion(
{"## Paraxial raytrace": compute_raytrace()},
{"### Paraxial raytrace": mo.ui.table(compute_raytrace())},
lazy=True,
)
return
Expand All @@ -59,7 +77,7 @@ def _(get_surf_info, mo, plot, retval, surf):

mo.accordion(
{
"## POP": mo.vstack(
"### POP": mo.vstack(
[
mo.hstack(
[surf, get_surf_info(int(surf.value))],
Expand Down Expand Up @@ -129,7 +147,17 @@ def update_config():
def compute_raytrace():
pup_diameter, parameters, wavelengths, fields, opt_chains = update_config()

return raytrace(fields[0], opt_chains[0])
rt = raytrace(fields[0], opt_chains[0])

res = {}
res["Surface key"] = [item.split(" - ")[0] for item in rt]
res["Description"] = [item.split(" - ")[1].split("y:")[0] for item in rt]
res["Sagittal data [x]"] = ["x: " + item.split("x:")[1] for item in rt]
res["Tangential data [y]"] = [
"y: " + item.split("y:")[1].split("x:")[0] for item in rt
]

return res


def compute_pop():
Expand Down

0 comments on commit 4340a61

Please sign in to comment.