{ "cells": [ { "metadata": {}, "cell_type": "markdown", "source": [ "# Point-Spread Function\n", "\n", "This report computes the point-spread function of the ESIS optical system." ], "id": "61b45a415e261529" }, { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true }, "source": [ "import matplotlib.pyplot as plt\n", "import astropy.visualization\n", "import astropy.units as u\n", "import named_arrays as na\n", "import esis" ], "outputs": [], "execution_count": null }, { "metadata": {}, "cell_type": "markdown", "source": [ "\n", "Start by loading the proposed optical design" ], "id": "e7f891a08e1a9e7b" }, { "metadata": {}, "cell_type": "code", "source": [ "instrument = esis.flights.f1.optics.design_single(num_distribution=0)\n", "instrument.field.num = 5\n", "# spectrograph.pupil.num = 21" ], "id": "47b0cba17ce43fae", "outputs": [], "execution_count": null }, { "metadata": {}, "cell_type": "markdown", "source": "Plot a schematic of the spectrograph design", "id": "990857ae03119ae4" }, { "metadata": {}, "cell_type": "code", "source": [ "with astropy.visualization.quantity_support():\n", " fig, ax = plt.subplots(\n", " figsize=(8, 4),\n", " constrained_layout=True,\n", " )\n", " instrument.system.plot(\n", " ax=ax,\n", " # plot_rays=False,\n", " components=(\"z\", \"x\"),\n", " color=\"black\",\n", " # plot_rays_vignetted=True,\n", " kwargs_rays=dict(\n", " color=\"tab:blue\",\n", " zorder=0,\n", " ),\n", " )\n", " ax.set_xlabel(f\"$z$ ({ax.get_xlabel()})\")\n", " ax.set_ylabel(f\"$x$ ({ax.get_ylabel()})\")\n", " # ax.set_aspect(\"equal\")" ], "id": "51ceb190ea5103fb", "outputs": [], "execution_count": null }, { "metadata": {}, "cell_type": "markdown", "source": "Plot a spot diagram for the nominal wavelength", "id": "7410b39b99ac2967" }, { "metadata": {}, "cell_type": "code", "source": [ "field = instrument.field\n", "\n", "rays = instrument.system.rayfunction_default.outputs\n", "position = rays.position.to(u.um)\n", "position_relative = position - position.mean(instrument.pupil.axes)\n", "\n", "with astropy.visualization.quantity_support():\n", " fig, ax = na.plt.subplots(\n", " axis_rows=field.axis.y,\n", " axis_cols=field.axis.x,\n", " nrows=field.num,\n", " ncols=field.num,\n", " sharex=True,\n", " sharey=True,\n", " figsize=(7, 6),\n", " constrained_layout=True,\n", " )\n", " na.plt.scatter(\n", " position_relative.x,\n", " position_relative.y,\n", " ax=ax,\n", " s=5,\n", " where=rays.unvignetted,\n", " )\n", "\n", " ax_lower = ax[{field.axis.y: +0}]\n", " ax_upper = ax[{field.axis.y: ~0}]\n", " ax_left = ax[{field.axis.x: +0}]\n", " ax_right = ax[{field.axis.x: ~0}]\n", "\n", " na.plt.set_xlabel(f\"$x$ ({position.x.unit:latex_inline})\", ax=ax_lower)\n", " na.plt.set_ylabel(f\"$y$ ({position.y.unit:latex_inline})\", ax=ax_left)\n", "\n", " angle = instrument.system.rayfunction_default.inputs.field.to(u.arcsec)\n", " angle_x = angle.x.mean(set(angle.axes) - {field.axis.x,})\n", " angle_y = angle.y.mean(set(angle.axes) - {field.axis.y,})\n", " na.plt.text(\n", " x=0.5,\n", " y=1,\n", " s=angle_x.nominal.to_string_array(),\n", " ax=ax_upper,\n", " transform=na.plt.transAxes(ax_upper),\n", " ha=\"center\",\n", " va=\"bottom\",\n", " )\n", " na.plt.text(\n", " x=1.05,\n", " y=0.5,\n", " s=angle_y.nominal.to_string_array(),\n", " ax=ax_right,\n", " transform=na.plt.transAxes(ax_right),\n", " ha=\"left\",\n", " va=\"center\",\n", " )" ], "id": "b9f0285d545a6cff", "outputs": [], "execution_count": null } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }