From e5fde186e26213fbe78189f3e9e403d9534c50d8 Mon Sep 17 00:00:00 2001 From: stephanieyflu <84485762+stephanieyflu@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:33:08 -0500 Subject: [PATCH 1/6] Resolve tradebook inconsistencies --- .../grism_efficency_vs_fringe_frequency.ipynb | 38 +++++++++++++------ .../ground_target_error_tradebook.ipynb | 7 ++-- tradebooks/sensor_wavelength_mapping.ipynb | 5 +-- tradebooks/snr.ipynb | 34 +++++++++-------- ...lution_&_swath_vs_focal_length_trade.ipynb | 27 +++++++------ ...on_&_efficiency_vs_grism_resolvance_.ipynb | 3 +- 6 files changed, 69 insertions(+), 45 deletions(-) diff --git a/tradebooks/grism_efficency_vs_fringe_frequency.ipynb b/tradebooks/grism_efficency_vs_fringe_frequency.ipynb index 2f282a7..9b1500b 100644 --- a/tradebooks/grism_efficency_vs_fringe_frequency.ipynb +++ b/tradebooks/grism_efficency_vs_fringe_frequency.ipynb @@ -11,7 +11,19 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ImportError", + "evalue": "cannot import name 'components' from 'architect' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\__init__.py)", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\tradebooks\\grism_efficency_vs_fringe_frequency.ipynb Cell 2\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mplot\u001b[39;00m\n\u001b[0;32m 7\u001b[0m \u001b[39m# project\u001b[39;00m\n\u001b[1;32m----> 8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39marchitect\u001b[39;00m \u001b[39mimport\u001b[39;00m components\n", + "\u001b[1;31mImportError\u001b[0m: cannot import name 'components' from 'architect' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\__init__.py)" + ] + } + ], "source": [ "# external\n", "import astropy.units as unit\n", @@ -40,18 +52,18 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# region constant\n", - "\n", + "# region constants\n", "d = 2.5 * unit.mm\n", "n_2 = 1.52 * unit.dimensionless_unscaled\n", "n_g = 0.1 * unit.dimensionless_unscaled\n", "incident_angle = 60 * unit.rad\n", "# endregion\n", "\n", + "# region variables\n", "fringe_frequency = np.arange(start=10, stop=1200, step=10) * 1 / unit.mm\n", "# endregion" ] @@ -65,7 +77,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -75,7 +87,8 @@ " index_dcg=n_2,\n", " dcg_thickness=d,\n", " fringe_frequency=fringe_frequency,\n", - ")" + ")\n", + "# endregion" ] }, { @@ -88,7 +101,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -108,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -298,7 +311,7 @@ 0.18283076476340177, 0.0849684972102143, 0.02225904188522381, - 1.3835855601248883e-05, + 0.000013835855601248883, 0.020117028987762953, 0.08086589807006146, 0.17711506600808222, @@ -341,7 +354,7 @@ 0.18571502331415382, 0.08705430775830264, 0.023369738066646835, - 5.5342656681394646e-05, + 0.000055342656681394646, 0.019085830818050105, 0.07884933652987386, 0.17428394212980192, @@ -1341,12 +1354,14 @@ "source": [ "fringe_frequency_label = f\"Fringe Frequency\"\n", "grism_efficiency_label = f\"Grism Efficiency\"\n", + "\n", "data = {\n", " fringe_frequency_label: fringe_frequency[:],\n", " grism_efficiency_label: efficiency[:],\n", "}\n", "\n", "df = pd.DataFrame.from_dict(data=data)\n", + "\n", "graph = plot.line(\n", " df=df,\n", " x=fringe_frequency_label,\n", @@ -1354,6 +1369,7 @@ " title=\"Grism Efficiency versus Fringe Density\",\n", " dark=False,\n", ")\n", + "\n", "graph.show()\n", "display(df)" ] @@ -1375,7 +1391,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.2" }, "orig_nbformat": 4, "vscode": { diff --git a/tradebooks/ground_target_error_tradebook.ipynb b/tradebooks/ground_target_error_tradebook.ipynb index f92ad43..83e6297 100644 --- a/tradebooks/ground_target_error_tradebook.ipynb +++ b/tradebooks/ground_target_error_tradebook.ipynb @@ -33,7 +33,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Setup" + "## Setup\n", + "Run this section onwards when a parameter is updated." ] }, { @@ -92,7 +93,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Plot" + "## Plots" ] }, { @@ -153,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.10.2" }, "orig_nbformat": 4, "vscode": { diff --git a/tradebooks/sensor_wavelength_mapping.ipynb b/tradebooks/sensor_wavelength_mapping.ipynb index 4cce407..9d4ef51 100644 --- a/tradebooks/sensor_wavelength_mapping.ipynb +++ b/tradebooks/sensor_wavelength_mapping.ipynb @@ -21,8 +21,7 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect import components, systems\n", - "from architect.libs import utillib" + "from architect import components, systems" ] }, { @@ -2749,7 +2748,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.2" }, "orig_nbformat": 4, "vscode": { diff --git a/tradebooks/snr.ipynb b/tradebooks/snr.ipynb index e7206fa..091f279 100644 --- a/tradebooks/snr.ipynb +++ b/tradebooks/snr.ipynb @@ -7,13 +7,6 @@ "# SNR vs Wavelengths (900 - 1700 nm)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Setup" - ] - }, { "cell_type": "code", "execution_count": 1, @@ -33,10 +26,17 @@ "\n", "# project\n", "from architect import luts\n", - "from architect.libs import utillib\n", "from architect.systems.optical import foreoptics, masks, sensors, spectrometers" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup\n", + "Run this section onwards when a parameter is updated." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -50,10 +50,9 @@ "metadata": {}, "outputs": [], "source": [ - "# constants\n", - "\n", - "# variables\n", - "wavelength = np.arange(start=900, stop=1700, step=25) * unit.nm" + "# region variables\n", + "wavelength = np.arange(start=900, stop=1700, step=25) * unit.nm\n", + "# endregion" ] }, { @@ -69,17 +68,19 @@ "metadata": {}, "outputs": [], "source": [ - "# components\n", + "# region components\n", "sensor = sensors.TauSWIR()\n", "foreoptic = foreoptics.Foreoptic(\n", " focal_length=100 * unit.mm, diameter=35 * unit.mm, image_diameter=10 * unit.mm\n", ")\n", "slit = masks.RectSlit(size=(1 * unit.mm, 20 * unit.mm))\n", + "# endregion\n", "\n", - "# systems\n", + "# region systems\n", "payload = spectrometers.HyperspectralImager(\n", " sensor=sensor, foreoptic=foreoptic, slit=slit\n", - ")" + ")\n", + "# endregion" ] }, { @@ -1308,12 +1309,14 @@ "source": [ "wavelength_label = f\"Wavelengths\"\n", "snr_label = f\"SNR\"\n", + "\n", "data = {\n", " wavelength_label: wavelength[:],\n", " snr_label: snr[:],\n", "}\n", "\n", "df = pd.DataFrame.from_dict(data=data)\n", + "\n", "fig = plot.line(\n", " df=df,\n", " x=wavelength_label,\n", @@ -1321,6 +1324,7 @@ " title=\"SNR versus Wavelengths\",\n", " dark=False,\n", ")\n", + "\n", "fig.show()\n", "display(df)" ] diff --git a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb index fc956d4..c5adaa1 100644 --- a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb +++ b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb @@ -33,7 +33,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Setup" + "## Setup\n", + "Run this section onwards when a parameter is updated." ] }, { @@ -59,21 +60,24 @@ "metadata": {}, "outputs": [], "source": [ - "# constants\n", + "# region constants\n", "orbital_altitude = 550 * unit.km\n", "foreoptic_diameter = 44 * unit.mm\n", "skew_angle = np.array([0, 0]) * unit.deg\n", "slit_size = np.array([3, 1]) * unit.mm\n", "target_wavelength = 1300 * unit.nm\n", + "# endregion\n", "\n", - "# variables\n", + "# region variables\n", "focal_length = np.arange(start=10, stop=300, step=10) * unit.mm\n", + "# endregion\n", "\n", - "# vectorization\n", + "# region vectorization\n", "parameter_space_shape = (focal_length.size, slit_size.size)\n", "focal_length = utillib.orient_and_broadcast(\n", " a=focal_length, dim=0, shape=parameter_space_shape\n", - ")" + ")\n", + "# endregion" ] }, { @@ -89,19 +93,19 @@ "metadata": {}, "outputs": [], "source": [ - "# components\n", + "# region components\n", "sensor = components.sensors.TauSWIR()\n", - "\n", "foreoptic = components.foreoptics.Foreoptic(\n", " diameter=foreoptic_diameter, focal_length=focal_length\n", ")\n", - "\n", "slit = components.masks.RectSlit(size=slit_size)\n", + "# endregion\n", "\n", - "# systems\n", + "# region systems\n", "payload = systems.spectrometers.HyperspectralImager(\n", " sensor=sensor, foreoptic=foreoptic, slit=slit\n", - ")" + ")\n", + "# endregion" ] }, { @@ -1646,6 +1650,7 @@ "}\n", "\n", "df = pd.DataFrame.from_dict(data=data)\n", + "\n", "fig = plot.line(\n", " df=df,\n", " x=focal_length_label,\n", @@ -1657,12 +1662,12 @@ " title=None,\n", " dark=True,\n", ")\n", + "\n", "df.to_csv(output_dir / \"data.csv\", index=False)\n", "plot.save(\n", " fig=fig, name=\"spatial_resolution_&_swath_vs_focal_length_trade\", path=output_dir\n", ")\n", "\n", - "\n", "fig.show()\n", "display(df)\n", "display(payload)" diff --git a/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb b/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb index 33669ed..26307ea 100644 --- a/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb +++ b/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb @@ -21,8 +21,7 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect import components, systems\n", - "from architect.libs import utillib" + "from architect import components, systems" ] }, { From c191c4a80ad03e832207825cef73fdd26593ff78 Mon Sep 17 00:00:00 2001 From: stephanieyflu <84485762+stephanieyflu@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:30:51 -0500 Subject: [PATCH 2/6] Resolve tradebook inconsistencies except spatial --- .../grism_efficency_vs_fringe_frequency.ipynb | 222 ++- .../ground_target_error_tradebook.ipynb | 1222 ++++++++++++++++- tradebooks/sensor_wavelength_mapping.ipynb | 189 +-- tradebooks/snr.ipynb | 254 ++-- ...lution_&_swath_vs_focal_length_trade.ipynb | 70 +- ...on_&_efficiency_vs_grism_resolvance_.ipynb | 167 +-- 6 files changed, 1668 insertions(+), 456 deletions(-) diff --git a/tradebooks/grism_efficency_vs_fringe_frequency.ipynb b/tradebooks/grism_efficency_vs_fringe_frequency.ipynb index 9b1500b..6b3b7dd 100644 --- a/tradebooks/grism_efficency_vs_fringe_frequency.ipynb +++ b/tradebooks/grism_efficency_vs_fringe_frequency.ipynb @@ -9,21 +9,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 12, "metadata": {}, - "outputs": [ - { - "ename": "ImportError", - "evalue": "cannot import name 'components' from 'architect' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\__init__.py)", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\tradebooks\\grism_efficency_vs_fringe_frequency.ipynb Cell 2\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mplot\u001b[39;00m\n\u001b[0;32m 7\u001b[0m \u001b[39m# project\u001b[39;00m\n\u001b[1;32m----> 8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39marchitect\u001b[39;00m \u001b[39mimport\u001b[39;00m components\n", - "\u001b[1;31mImportError\u001b[0m: cannot import name 'components' from 'architect' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\__init__.py)" - ] - } - ], + "outputs": [], "source": [ "# external\n", "import astropy.units as unit\n", @@ -32,7 +20,7 @@ "import plot\n", "\n", "# project\n", - "from architect import components" + "from architect.systems.optical import diffractors" ] }, { @@ -52,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -77,12 +65,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# region components\n", - "diffractor = components.diffractors.VPHGrism(\n", + "diffractor = diffractors.VPHGrism(\n", " index_dcg_amplitude=n_g,\n", " index_dcg=n_2,\n", " dcg_thickness=d,\n", @@ -101,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -121,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -132,8 +120,8 @@ }, "data": [ { - "hovertemplate": "variable=Grism Efficiency
Fringe Frequency=%{x}
value=%{y}", - "legendgroup": "Grism Efficiency", + "hovertemplate": "Fringe Frequency [1 / mm]=%{x}
Grism Efficiency []=%{y}", + "legendgroup": "", "line": { "color": "#636efa", "dash": "solid" @@ -142,9 +130,9 @@ "symbol": "circle" }, "mode": "lines", - "name": "Grism Efficiency", + "name": "", "orientation": "v", - "showlegend": true, + "showlegend": false, "type": "scatter", "x": [ 10, @@ -394,9 +382,6 @@ ], "layout": { "legend": { - "title": { - "text": "variable" - }, "tracegroupgap": 0 }, "template": { @@ -404,14 +389,14 @@ "bar": [ { "error_x": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "error_y": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -427,7 +412,7 @@ { "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -442,18 +427,18 @@ "carpet": [ { "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "type": "carpet" } @@ -771,10 +756,10 @@ ], "scatter": [ { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 + "marker": { + "line": { + "color": "#283442" + } }, "type": "scatter" } @@ -821,9 +806,8 @@ "scattergl": [ { "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" + "line": { + "color": "#283442" } }, "type": "scattergl" @@ -928,18 +912,18 @@ { "cells": { "fill": { - "color": "#EBF0F8" + "color": "#506784" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "header": { "fill": { - "color": "#C8D4E3" + "color": "#2a3f5f" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "type": "table" @@ -948,7 +932,7 @@ }, "layout": { "annotationdefaults": { - "arrowcolor": "#2a3f5f", + "arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1 }, @@ -1104,119 +1088,129 @@ "#FECB52" ], "font": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", "showlakes": true, "showland": true, - "subunitcolor": "white" + "subunitcolor": "#506784" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { - "style": "light" + "style": "dark" }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", "polar": { "angularaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "radialaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "scene": { "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" } }, "shapedefaults": { "line": { - "color": "#2a3f5f" + "color": "#f2f5fa" } }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, "ternary": { "aaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, "baxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "caxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "title": { "x": 0.05 }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, "xaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 }, "yaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 } } }, "title": { - "text": "Grism Efficiency versus Fringe Density" + "text": "Grism Efficiency vs. Fringe Density" }, "xaxis": { "anchor": "y", @@ -1225,7 +1219,7 @@ 1 ], "title": { - "text": "Fringe Frequency" + "text": "Fringe Frequency [1 / mm]" } }, "yaxis": { @@ -1235,7 +1229,7 @@ 1 ], "title": { - "text": "value" + "text": "Grism Efficiency []" } } } @@ -1265,8 +1259,8 @@ " \n", " \n", " \n", - " Fringe Frequency\n", - " Grism Efficiency\n", + " Fringe Frequency [1 / mm]\n", + " Grism Efficiency []\n", " \n", " \n", " \n", @@ -1331,18 +1325,18 @@ "" ], "text/plain": [ - " Fringe Frequency Grism Efficiency\n", - "0 10.0 0.021175\n", - "1 20.0 0.082906\n", - "2 30.0 0.179964\n", - "3 40.0 0.304129\n", - "4 50.0 0.444884\n", - ".. ... ...\n", - "114 1150.0 0.782782\n", - "115 1160.0 0.889536\n", - "116 1170.0 0.963297\n", - "117 1180.0 0.997817\n", - "118 1190.0 0.990173\n", + " Fringe Frequency [1 / mm] Grism Efficiency []\n", + "0 10.0 0.021175\n", + "1 20.0 0.082906\n", + "2 30.0 0.179964\n", + "3 40.0 0.304129\n", + "4 50.0 0.444884\n", + ".. ... ...\n", + "114 1150.0 0.782782\n", + "115 1160.0 0.889536\n", + "116 1170.0 0.963297\n", + "117 1180.0 0.997817\n", + "118 1190.0 0.990173\n", "\n", "[119 rows x 2 columns]" ] @@ -1352,8 +1346,8 @@ } ], "source": [ - "fringe_frequency_label = f\"Fringe Frequency\"\n", - "grism_efficiency_label = f\"Grism Efficiency\"\n", + "fringe_frequency_label = f\"Fringe Frequency [{fringe_frequency.unit}]\"\n", + "grism_efficiency_label = f\"Grism Efficiency [{efficiency.unit}]\"\n", "\n", "data = {\n", " fringe_frequency_label: fringe_frequency[:],\n", @@ -1365,9 +1359,9 @@ "graph = plot.line(\n", " df=df,\n", " x=fringe_frequency_label,\n", - " y=[grism_efficiency_label],\n", - " title=\"Grism Efficiency versus Fringe Density\",\n", - " dark=False,\n", + " y=grism_efficiency_label,\n", + " title=\"Grism Efficiency vs. Fringe Density\",\n", + " dark=True,\n", ")\n", "\n", "graph.show()\n", diff --git a/tradebooks/ground_target_error_tradebook.ipynb b/tradebooks/ground_target_error_tradebook.ipynb index 83e6297..c593063 100644 --- a/tradebooks/ground_target_error_tradebook.ipynb +++ b/tradebooks/ground_target_error_tradebook.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -26,7 +26,7 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect.systems.optical.spectrometers import HyperspectralImager" + "from architect.systems.optical import spectrometers" ] }, { @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -62,11 +62,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "system = HyperspectralImager()" + "system = spectrometers.HyperspectralImager()" ] }, { @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -98,28 +98,1224 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hovertemplate": "Pointing Accuracy [deg]=%{x}
Ground Target Error [m]=%{y}", + "legendgroup": "", + "line": { + "color": "#636efa", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines", + "name": "", + "orientation": "v", + "showlegend": false, + "type": "scatter", + "x": [ + 0.0001, + 0.0011, + 0.0021, + 0.0031, + 0.0041, + 0.0051, + 0.0061, + 0.0071, + 0.0081, + 0.0091, + 0.0101, + 0.011099999999999999, + 0.0121, + 0.0131, + 0.0141, + 0.015099999999999999, + 0.0161, + 0.0171, + 0.0181, + 0.0191, + 0.0201, + 0.0211, + 0.022099999999999998, + 0.0231, + 0.0241, + 0.0251, + 0.0261, + 0.0271, + 0.0281, + 0.0291, + 0.0301, + 0.0311, + 0.032100000000000004, + 0.033100000000000004, + 0.034100000000000005, + 0.035100000000000006, + 0.03610000000000001, + 0.0371, + 0.0381, + 0.0391, + 0.040100000000000004, + 0.041100000000000005, + 0.042100000000000005, + 0.043100000000000006, + 0.0441, + 0.0451, + 0.0461, + 0.0471, + 0.048100000000000004, + 0.049100000000000005, + 0.050100000000000006, + 0.051100000000000007, + 0.05210000000000001, + 0.0531, + 0.0541, + 0.0551, + 0.056100000000000004, + 0.057100000000000005, + 0.058100000000000006, + 0.05910000000000001, + 0.0601, + 0.0611, + 0.0621, + 0.0631, + 0.0641, + 0.0651, + 0.0661, + 0.0671, + 0.06810000000000001, + 0.06910000000000001, + 0.07010000000000001, + 0.07110000000000001, + 0.07210000000000001, + 0.0731, + 0.0741, + 0.0751, + 0.0761, + 0.0771, + 0.0781, + 0.0791, + 0.0801, + 0.0811, + 0.0821, + 0.08310000000000001, + 0.08410000000000001, + 0.08510000000000001, + 0.08610000000000001, + 0.08710000000000001, + 0.0881, + 0.0891, + 0.0901, + 0.0911, + 0.0921, + 0.0931, + 0.0941, + 0.0951, + 0.0961, + 0.0971, + 0.0981, + 0.09910000000000001 + ], + "xaxis": "x", + "y": [ + 0.872664625998051, + 9.599310887148205, + 18.325957154146597, + 27.052603432309798, + 35.77924972695439, + 44.50589604339695, + 53.232542386954044, + 61.95918876294227, + 70.68583517667817, + 79.41248163347838, + 88.13912813865942, + 96.86577469753786, + 105.59242131543036, + 114.31906799765342, + 123.04571474952363, + 131.77236157635758, + 140.49900848347187, + 149.22565547618308, + 157.95230255980775, + 166.67894973966244, + 175.4055970210638, + 184.13224440932834, + 192.8588919097727, + 201.58553952771345, + 210.3121872684671, + 219.03883513735033, + 227.7654831396797, + 236.4921312807717, + 245.218779565943, + 253.94542800051016, + 262.67207658978975, + 271.3987253390984, + 280.12537425375274, + 288.85202333906915, + 297.57867260036437, + 306.30532204295497, + 315.0319716721574, + 323.75862149328844, + 332.48527151166456, + 341.21192173260243, + 349.9385721614186, + 358.6652228034297, + 367.3918736639521, + 376.1185247483027, + 384.84517606179776, + 393.57182760975417, + 402.2984793974884, + 411.02513143031706, + 419.7517837135566, + 428.4784362525239, + 437.2050890525353, + 445.9317421189075, + 454.65839545695695, + 463.38504907200047, + 472.11170296935455, + 480.83835715433577, + 489.5650116322608, + 498.2916664084461, + 507.01832148820836, + 515.7449768768641, + 524.4716325797301, + 533.1982886021227, + 541.9249449493589, + 550.6516016267548, + 559.3782586396273, + 568.1049159932929, + 576.8315736930683, + 585.5582317442701, + 594.2848901522149, + 603.0115489222193, + 611.7382080595999, + 620.4648675696731, + 629.1915274577559, + 637.9181877291644, + 646.6448483892157, + 655.3715094432262, + 664.0981708965126, + 672.8248327543914, + 681.5514950221793, + 690.2781577051929, + 699.004820808749, + 707.7314843381636, + 716.4581482987539, + 725.1848126958365, + 733.911477534728, + 742.6381428207447, + 751.3648085592034, + 760.0914747554208, + 768.8181414147134, + 777.5448085423978, + 786.271476143791, + 794.9981442242093, + 803.7248127889693, + 812.451481843388, + 821.1781513927814, + 829.9048214424666, + 838.6314919977603, + 847.3581630639787, + 856.0848346464389, + 864.8115067504572 + ], + "yaxis": "y" + } + ], + "layout": { + "legend": { + "tracegroupgap": 0 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "showlakes": true, + "showland": true, + "subunitcolor": "#506784" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "dark" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "gridwidth": 2, + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3" + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, + "ternary": { + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "bgcolor": "rgb(17,17,17)", + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Ground Target Error vs. Relative Pointing Accuracy" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Pointing Accuracy [deg]" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Ground Target Error [m]" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Pointing Accuracy [deg]Ground Target Error [m]
00.00010.872665
10.00119.599311
20.002118.325957
30.003127.052603
40.004135.779250
.........
950.0951829.904821
960.0961838.631492
970.0971847.358163
980.0981856.084835
990.0991864.811507
\n", + "

100 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " Pointing Accuracy [deg] Ground Target Error [m]\n", + "0 0.0001 0.872665\n", + "1 0.0011 9.599311\n", + "2 0.0021 18.325957\n", + "3 0.0031 27.052603\n", + "4 0.0041 35.779250\n", + ".. ... ...\n", + "95 0.0951 829.904821\n", + "96 0.0961 838.631492\n", + "97 0.0971 847.358163\n", + "98 0.0981 856.084835\n", + "99 0.0991 864.811507\n", + "\n", + "[100 rows x 2 columns]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "pointing_accuracy_label = f\"Pointing Accuracy [{pointing_accuracy.unit}]\"\n", "ground_target_error_label = f\"Ground Target Error [{ground_target_error.unit}]\"\n", "\n", "data = {\n", - " pointing_accuracy_label: pointing_accuracy,\n", - " ground_target_error_label: ground_target_error,\n", + " pointing_accuracy_label: pointing_accuracy[:],\n", + " ground_target_error_label: ground_target_error[:],\n", "}\n", "\n", "df = pd.DataFrame.from_dict(data=data)\n", - "fig = plot.line(\n", + "\n", + "graph = plot.line(\n", " df=df,\n", " x=pointing_accuracy_label,\n", " y=ground_target_error_label,\n", - " title=\"Ground Target Error vs Relative Pointing Accuracy\",\n", + " title=\"Ground Target Error vs. Relative Pointing Accuracy\",\n", " dark=True,\n", ")\n", "\n", - "fig.show()\n", + "graph.show()\n", "display(df)" ] }, diff --git a/tradebooks/sensor_wavelength_mapping.ipynb b/tradebooks/sensor_wavelength_mapping.ipynb index 9d4ef51..0cc4d7a 100644 --- a/tradebooks/sensor_wavelength_mapping.ipynb +++ b/tradebooks/sensor_wavelength_mapping.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,13 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect import components, systems" + "from architect.systems.optical import (\n", + " diffractors,\n", + " foreoptics,\n", + " lenses,\n", + " masks,\n", + " spectrometers,\n", + ")" ] }, { @@ -41,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -63,25 +69,25 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# region components\n", - "foreoptic = components.foreoptics.Chromar()\n", - "slit = components.masks.RectSlit()\n", - "collimator = components.lenses.Lens()\n", - "grism = components.diffractors.VPHGrism(\n", + "foreoptic = foreoptics.Foreoptic()\n", + "slit = masks.RectSlit()\n", + "collimator = lenses.Lens()\n", + "grism = diffractors.VPHGrism(\n", " fringe_frequency=fringe_frequency,\n", " apex_angle=45 * unit.deg,\n", " index_prism=1,\n", " index_seal=1,\n", ")\n", - "focuser = components.lenses.Lens(focal_length=0.5 * unit.mm)\n", + "focuser = lenses.Lens(focal_length=0.5 * unit.mm)\n", "# endregion\n", "\n", "# region systems\n", - "payload = systems.spectrometers.FINCHEye(\n", + "payload = spectrometers.FINCHEye(\n", " foreoptic=foreoptic,\n", " slit=slit,\n", " collimator=collimator,\n", @@ -101,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -130,7 +136,7 @@ }, "data": [ { - "hovertemplate": "Wavelength (nm)=%{x}
Sensor Height (mm)=%{y}", + "hovertemplate": "Wavelength [nm]=%{x}
Sensor Height [mm]=%{y}", "legendgroup": "", "line": { "color": "#636efa", @@ -1761,14 +1767,14 @@ "bar": [ { "error_x": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "error_y": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -1784,7 +1790,7 @@ { "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -1799,18 +1805,18 @@ "carpet": [ { "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "type": "carpet" } @@ -2128,10 +2134,10 @@ ], "scatter": [ { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 + "marker": { + "line": { + "color": "#283442" + } }, "type": "scatter" } @@ -2178,9 +2184,8 @@ "scattergl": [ { "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" + "line": { + "color": "#283442" } }, "type": "scattergl" @@ -2285,18 +2290,18 @@ { "cells": { "fill": { - "color": "#EBF0F8" + "color": "#506784" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "header": { "fill": { - "color": "#C8D4E3" + "color": "#2a3f5f" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "type": "table" @@ -2305,7 +2310,7 @@ }, "layout": { "annotationdefaults": { - "arrowcolor": "#2a3f5f", + "arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1 }, @@ -2461,119 +2466,129 @@ "#FECB52" ], "font": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", "showlakes": true, "showland": true, - "subunitcolor": "white" + "subunitcolor": "#506784" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { - "style": "light" + "style": "dark" }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", "polar": { "angularaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "radialaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "scene": { "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" } }, "shapedefaults": { "line": { - "color": "#2a3f5f" + "color": "#f2f5fa" } }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, "ternary": { "aaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, "baxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "caxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "title": { "x": 0.05 }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, "xaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 }, "yaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 } } }, "title": { - "text": "Sensor Height v/s Wavelength" + "text": "Sensor Height vs. Wavelength" }, "xaxis": { "anchor": "y", @@ -2582,7 +2597,7 @@ 1 ], "title": { - "text": "Wavelength (nm)" + "text": "Wavelength [nm]" } }, "yaxis": { @@ -2592,7 +2607,7 @@ 1 ], "title": { - "text": "Sensor Height (mm)" + "text": "Sensor Height [mm]" } } } @@ -2622,8 +2637,8 @@ " \n", " \n", " \n", - " Wavelength (nm)\n", - " Sensor Height (mm)\n", + " Wavelength [nm]\n", + " Sensor Height [mm]\n", " \n", " \n", " \n", @@ -2688,7 +2703,7 @@ "" ], "text/plain": [ - " Wavelength (nm) Sensor Height (mm)\n", + " Wavelength [nm] Sensor Height [mm]\n", "0 900.0 -0.311110\n", "1 901.0 -0.311589\n", "2 902.0 -0.312070\n", @@ -2709,8 +2724,8 @@ } ], "source": [ - "wavelength_label = f\"Wavelength (nm)\"\n", - "sensor_height_label = f\"Sensor Height (mm)\"\n", + "wavelength_label = f\"Wavelength [{wavelength.unit}]\"\n", + "sensor_height_label = f\"Sensor Height [{sensor_height.unit}]\"\n", "\n", "data = {\n", " wavelength_label: wavelength[:],\n", @@ -2723,8 +2738,8 @@ " df=df,\n", " x=wavelength_label,\n", " y=sensor_height_label,\n", - " title=\"Sensor Height v/s Wavelength\",\n", - " dark=False,\n", + " title=\"Sensor Height vs. Wavelength\",\n", + " dark=True,\n", ")\n", "\n", "graph.show()\n", diff --git a/tradebooks/snr.ipynb b/tradebooks/snr.ipynb index 091f279..4b03561 100644 --- a/tradebooks/snr.ipynb +++ b/tradebooks/snr.ipynb @@ -141,7 +141,7 @@ }, "data": [ { - "hovertemplate": "Wavelengths=%{x}
SNR=%{y}", + "hovertemplate": "Wavelengths [nm]=%{x}
SNR []=%{y}", "legendgroup": "", "line": { "color": "#636efa", @@ -236,14 +236,14 @@ "bar": [ { "error_x": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "error_y": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -259,7 +259,7 @@ { "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -274,18 +274,18 @@ "carpet": [ { "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "type": "carpet" } @@ -603,10 +603,10 @@ ], "scatter": [ { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 + "marker": { + "line": { + "color": "#283442" + } }, "type": "scatter" } @@ -653,9 +653,8 @@ "scattergl": [ { "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" + "line": { + "color": "#283442" } }, "type": "scattergl" @@ -760,18 +759,18 @@ { "cells": { "fill": { - "color": "#EBF0F8" + "color": "#506784" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "header": { "fill": { - "color": "#C8D4E3" + "color": "#2a3f5f" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "type": "table" @@ -780,7 +779,7 @@ }, "layout": { "annotationdefaults": { - "arrowcolor": "#2a3f5f", + "arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1 }, @@ -936,119 +935,129 @@ "#FECB52" ], "font": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", "showlakes": true, "showland": true, - "subunitcolor": "white" + "subunitcolor": "#506784" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { - "style": "light" + "style": "dark" }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", "polar": { "angularaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "radialaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "scene": { "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" } }, "shapedefaults": { "line": { - "color": "#2a3f5f" + "color": "#f2f5fa" } }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, "ternary": { "aaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, "baxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "caxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "title": { "x": 0.05 }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, "xaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 }, "yaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 } } }, "title": { - "text": "SNR versus Wavelengths" + "text": "SNR vs. Wavelengths" }, "xaxis": { "anchor": "y", @@ -1057,7 +1066,7 @@ 1 ], "title": { - "text": "Wavelengths" + "text": "Wavelengths [nm]" } }, "yaxis": { @@ -1067,7 +1076,7 @@ 1 ], "title": { - "text": "SNR" + "text": "SNR []" } } } @@ -1097,8 +1106,8 @@ " \n", " \n", " \n", - " Wavelengths\n", - " SNR\n", + " Wavelengths [nm]\n", + " SNR []\n", " \n", " \n", " \n", @@ -1267,39 +1276,39 @@ "" ], "text/plain": [ - " Wavelengths SNR\n", - "0 900.0 188.531710\n", - "1 925.0 234.440639\n", - "2 950.0 152.394612\n", - "3 975.0 259.417087\n", - "4 1000.0 352.754914\n", - "5 1025.0 330.737355\n", - "6 1050.0 305.680311\n", - "7 1075.0 271.573063\n", - "8 1100.0 209.625120\n", - "9 1125.0 76.595719\n", - "10 1150.0 90.342279\n", - "11 1175.0 159.867381\n", - "12 1200.0 156.744057\n", - "13 1225.0 168.617259\n", - "14 1250.0 163.347480\n", - "15 1275.0 140.412845\n", - "16 1300.0 130.627403\n", - "17 1325.0 96.983911\n", - "18 1350.0 26.571521\n", - "19 1375.0 13.750956\n", - "20 1400.0 11.952794\n", - "21 1425.0 21.395375\n", - "22 1450.0 26.481642\n", - "23 1475.0 42.954339\n", - "24 1500.0 64.154504\n", - "25 1525.0 74.058795\n", - "26 1550.0 75.042837\n", - "27 1575.0 64.684128\n", - "28 1600.0 61.530669\n", - "29 1625.0 57.798496\n", - "30 1650.0 49.053235\n", - "31 1675.0 42.764089" + " Wavelengths [nm] SNR []\n", + "0 900.0 188.531710\n", + "1 925.0 234.440639\n", + "2 950.0 152.394612\n", + "3 975.0 259.417087\n", + "4 1000.0 352.754914\n", + "5 1025.0 330.737355\n", + "6 1050.0 305.680311\n", + "7 1075.0 271.573063\n", + "8 1100.0 209.625120\n", + "9 1125.0 76.595719\n", + "10 1150.0 90.342279\n", + "11 1175.0 159.867381\n", + "12 1200.0 156.744057\n", + "13 1225.0 168.617259\n", + "14 1250.0 163.347480\n", + "15 1275.0 140.412845\n", + "16 1300.0 130.627403\n", + "17 1325.0 96.983911\n", + "18 1350.0 26.571521\n", + "19 1375.0 13.750956\n", + "20 1400.0 11.952794\n", + "21 1425.0 21.395375\n", + "22 1450.0 26.481642\n", + "23 1475.0 42.954339\n", + "24 1500.0 64.154504\n", + "25 1525.0 74.058795\n", + "26 1550.0 75.042837\n", + "27 1575.0 64.684128\n", + "28 1600.0 61.530669\n", + "29 1625.0 57.798496\n", + "30 1650.0 49.053235\n", + "31 1675.0 42.764089" ] }, "metadata": {}, @@ -1307,8 +1316,8 @@ } ], "source": [ - "wavelength_label = f\"Wavelengths\"\n", - "snr_label = f\"SNR\"\n", + "wavelength_label = f\"Wavelengths [{wavelength.unit}]\"\n", + "snr_label = f\"SNR [{snr.unit}]\"\n", "\n", "data = {\n", " wavelength_label: wavelength[:],\n", @@ -1317,15 +1326,15 @@ "\n", "df = pd.DataFrame.from_dict(data=data)\n", "\n", - "fig = plot.line(\n", + "graph = plot.line(\n", " df=df,\n", " x=wavelength_label,\n", " y=snr_label,\n", - " title=\"SNR versus Wavelengths\",\n", - " dark=False,\n", + " title=\"SNR vs. Wavelengths\",\n", + " dark=True,\n", ")\n", "\n", - "fig.show()\n", + "graph.show()\n", "display(df)" ] }, @@ -1335,19 +1344,14 @@ "metadata": {}, "outputs": [ { - "ename": "ValueError", - "evalue": "\nImage export using the \"kaleido\" engine requires the kaleido package,\nwhich can be installed using pip:\n $ pip install -U kaleido\n", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\David\\Workbench\\payload-designer\\tradebooks\\snr.ipynb Cell 12\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m output_path\u001b[39m.\u001b[39mmkdir(parents\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m, exist_ok\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m)\n\u001b[0;32m 5\u001b[0m df\u001b[39m.\u001b[39mto_csv(output_path \u001b[39m/\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mdata.csv\u001b[39m\u001b[39m\"\u001b[39m, index\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m)\n\u001b[1;32m----> 6\u001b[0m plot\u001b[39m.\u001b[39;49msave(fig\u001b[39m=\u001b[39;49mfig, name\u001b[39m=\u001b[39;49mfile_name, path\u001b[39m=\u001b[39;49moutput_path)\n", - "File \u001b[1;32mc:\\Users\\David\\Workbench\\payload-designer\\.venv\\lib\\site-packages\\plot\\functions.py:291\u001b[0m, in \u001b[0;36msave\u001b[1;34m(fig, name, path)\u001b[0m\n\u001b[0;32m 287\u001b[0m timestamp \u001b[39m=\u001b[39m datetime\u001b[39m.\u001b[39mnow()\u001b[39m.\u001b[39mstrftime(\u001b[39m\"\u001b[39m\u001b[39m%\u001b[39m\u001b[39mY-\u001b[39m\u001b[39m%\u001b[39m\u001b[39mm-\u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m_\u001b[39m\u001b[39m%\u001b[39m\u001b[39mH:\u001b[39m\u001b[39m%\u001b[39m\u001b[39mM:\u001b[39m\u001b[39m%\u001b[39m\u001b[39mS.\u001b[39m\u001b[39m%f\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 289\u001b[0m filepath \u001b[39m=\u001b[39m path \u001b[39m/\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mname\u001b[39m}\u001b[39;00m\u001b[39m_\u001b[39m\u001b[39m{\u001b[39;00mtimestamp\u001b[39m}\u001b[39;00m\u001b[39m.png\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m--> 291\u001b[0m fig\u001b[39m.\u001b[39;49mwrite_image(filepath)\n\u001b[0;32m 293\u001b[0m LOG\u001b[39m.\u001b[39minfo(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mSaved figure to \u001b[39m\u001b[39m{\u001b[39;00mfilepath\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n", - "File \u001b[1;32mc:\\Users\\David\\Workbench\\payload-designer\\.venv\\lib\\site-packages\\plotly\\basedatatypes.py:3829\u001b[0m, in \u001b[0;36mBaseFigure.write_image\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 3769\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 3770\u001b[0m \u001b[39mConvert a figure to a static image and write it to a file or writeable\u001b[39;00m\n\u001b[0;32m 3771\u001b[0m \u001b[39mobject\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 3825\u001b[0m \u001b[39mNone\u001b[39;00m\n\u001b[0;32m 3826\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 3827\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mplotly\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mio\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mpio\u001b[39;00m\n\u001b[1;32m-> 3829\u001b[0m \u001b[39mreturn\u001b[39;00m pio\u001b[39m.\u001b[39mwrite_image(\u001b[39mself\u001b[39m, \u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n", - "File \u001b[1;32mc:\\Users\\David\\Workbench\\payload-designer\\.venv\\lib\\site-packages\\plotly\\io\\_kaleido.py:267\u001b[0m, in \u001b[0;36mwrite_image\u001b[1;34m(fig, file, format, scale, width, height, validate, engine)\u001b[0m\n\u001b[0;32m 251\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[0;32m 252\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 253\u001b[0m \u001b[39mCannot infer image type from output path '{file}'.\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 261\u001b[0m )\n\u001b[0;32m 262\u001b[0m )\n\u001b[0;32m 264\u001b[0m \u001b[39m# Request image\u001b[39;00m\n\u001b[0;32m 265\u001b[0m \u001b[39m# -------------\u001b[39;00m\n\u001b[0;32m 266\u001b[0m \u001b[39m# Do this first so we don't create a file if image conversion fails\u001b[39;00m\n\u001b[1;32m--> 267\u001b[0m img_data \u001b[39m=\u001b[39m to_image(\n\u001b[0;32m 268\u001b[0m fig,\n\u001b[0;32m 269\u001b[0m \u001b[39mformat\u001b[39;49m\u001b[39m=\u001b[39;49m\u001b[39mformat\u001b[39;49m,\n\u001b[0;32m 270\u001b[0m scale\u001b[39m=\u001b[39;49mscale,\n\u001b[0;32m 271\u001b[0m width\u001b[39m=\u001b[39;49mwidth,\n\u001b[0;32m 272\u001b[0m height\u001b[39m=\u001b[39;49mheight,\n\u001b[0;32m 273\u001b[0m validate\u001b[39m=\u001b[39;49mvalidate,\n\u001b[0;32m 274\u001b[0m engine\u001b[39m=\u001b[39;49mengine,\n\u001b[0;32m 275\u001b[0m )\n\u001b[0;32m 277\u001b[0m \u001b[39m# Open file\u001b[39;00m\n\u001b[0;32m 278\u001b[0m \u001b[39m# ---------\u001b[39;00m\n\u001b[0;32m 279\u001b[0m \u001b[39mif\u001b[39;00m path \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m 280\u001b[0m \u001b[39m# We previously failed to make sense of `file` as a pathlib object.\u001b[39;00m\n\u001b[0;32m 281\u001b[0m \u001b[39m# Attempt to write to `file` as an open file descriptor.\u001b[39;00m\n", - "File \u001b[1;32mc:\\Users\\David\\Workbench\\payload-designer\\.venv\\lib\\site-packages\\plotly\\io\\_kaleido.py:133\u001b[0m, in \u001b[0;36mto_image\u001b[1;34m(fig, format, width, height, scale, validate, engine)\u001b[0m\n\u001b[0;32m 131\u001b[0m \u001b[39m# Raise informative error message if Kaleido is not installed\u001b[39;00m\n\u001b[0;32m 132\u001b[0m \u001b[39mif\u001b[39;00m scope \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m--> 133\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[0;32m 134\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 135\u001b[0m \u001b[39mImage export using the \"kaleido\" engine requires the kaleido package,\u001b[39;00m\n\u001b[0;32m 136\u001b[0m \u001b[39mwhich can be installed using pip:\u001b[39;00m\n\u001b[0;32m 137\u001b[0m \u001b[39m $ pip install -U kaleido\u001b[39;00m\n\u001b[0;32m 138\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 139\u001b[0m )\n\u001b[0;32m 141\u001b[0m \u001b[39m# Validate figure\u001b[39;00m\n\u001b[0;32m 142\u001b[0m \u001b[39m# ---------------\u001b[39;00m\n\u001b[0;32m 143\u001b[0m fig_dict \u001b[39m=\u001b[39m validate_coerce_fig_to_dict(fig, validate)\n", - "\u001b[1;31mValueError\u001b[0m: \nImage export using the \"kaleido\" engine requires the kaleido package,\nwhich can be installed using pip:\n $ pip install -U kaleido\n" - ] + "data": { + "text/plain": [ + "WindowsPath('output/snr_tradebook/snr_tradebook_2023-11-30_15-28-39-332675.html')" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -1356,7 +1360,7 @@ "output_path.mkdir(parents=True, exist_ok=True)\n", "\n", "df.to_csv(output_path / \"data.csv\", index=False)\n", - "plot.save(fig=fig, name=file_name, path=output_path)" + "plot.save(fig=graph, name=file_name, path=output_path)" ] } ], @@ -1376,7 +1380,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.10.2" }, "orig_nbformat": 4, "vscode": { diff --git a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb index c5adaa1..8012d7b 100644 --- a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb +++ b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb @@ -25,8 +25,8 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect import components, systems\n", - "from architect.libs import utillib" + "from architect.libs import utillib\n", + "from architect.systems.optical import foreoptics, masks, sensors, spectrometers" ] }, { @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -89,20 +89,18 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# region components\n", - "sensor = components.sensors.TauSWIR()\n", - "foreoptic = components.foreoptics.Foreoptic(\n", - " diameter=foreoptic_diameter, focal_length=focal_length\n", - ")\n", - "slit = components.masks.RectSlit(size=slit_size)\n", + "sensor = sensors.TauSWIR()\n", + "foreoptic = foreoptics.Foreoptic(diameter=foreoptic_diameter, focal_length=focal_length)\n", + "slit = masks.RectSlit(size=slit_size)\n", "# endregion\n", "\n", "# region systems\n", - "payload = systems.spectrometers.HyperspectralImager(\n", + "payload = spectrometers.HyperspectralImager(\n", " sensor=sensor, foreoptic=foreoptic, slit=slit\n", ")\n", "# endregion" @@ -117,33 +115,31 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "'Sensor-limited spatial resolution test shape: (29, 2)'" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING: AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. [astropy.units.quantity]\n" + "ename": "UnitConversionError", + "evalue": "Can only apply 'maximum' function to quantities with compatible dimensions", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mUnitConversionError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\helpers.py:68\u001b[0m, in \u001b[0;36mget_converters_and_unit\u001b[1;34m(f, unit1, unit2)\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m---> 68\u001b[0m converters[changeable] \u001b[39m=\u001b[39m get_converter(unit2, unit1)\n\u001b[0;32m 69\u001b[0m \u001b[39mexcept\u001b[39;00m UnitsError:\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\helpers.py:32\u001b[0m, in \u001b[0;36mget_converter\u001b[1;34m(from_unit, to_unit)\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[39m\"\"\"Like Unit._get_converter, except returns None if no scaling is needed,\u001b[39;00m\n\u001b[0;32m 31\u001b[0m \u001b[39mi.e., if the inferred scale is unity.\"\"\"\u001b[39;00m\n\u001b[1;32m---> 32\u001b[0m converter \u001b[39m=\u001b[39m from_unit\u001b[39m.\u001b[39;49m_get_converter(to_unit)\n\u001b[0;32m 33\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mif\u001b[39;00m converter \u001b[39mis\u001b[39;00m unit_scale_converter \u001b[39melse\u001b[39;00m converter\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\core.py:1061\u001b[0m, in \u001b[0;36mUnitBase._get_converter\u001b[1;34m(self, other, equivalencies)\u001b[0m\n\u001b[0;32m 1059\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m-> 1061\u001b[0m \u001b[39mraise\u001b[39;00m exc\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\core.py:1046\u001b[0m, in \u001b[0;36mUnitBase._get_converter\u001b[1;34m(self, other, equivalencies)\u001b[0m\n\u001b[0;32m 1045\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m-> 1046\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_apply_equivalencies(\n\u001b[0;32m 1047\u001b[0m \u001b[39mself\u001b[39;49m, other, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_normalize_equivalencies(equivalencies))\n\u001b[0;32m 1048\u001b[0m \u001b[39mexcept\u001b[39;00m UnitsError \u001b[39mas\u001b[39;00m exc:\n\u001b[0;32m 1049\u001b[0m \u001b[39m# Last hope: maybe other knows how to do it?\u001b[39;00m\n\u001b[0;32m 1050\u001b[0m \u001b[39m# We assume the equivalencies have the unit itself as first item.\u001b[39;00m\n\u001b[0;32m 1051\u001b[0m \u001b[39m# TODO: maybe better for other to have a `_back_converter` method?\u001b[39;00m\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\core.py:1022\u001b[0m, in \u001b[0;36mUnitBase._apply_equivalencies\u001b[1;34m(self, unit, other, equivalencies)\u001b[0m\n\u001b[0;32m 1020\u001b[0m other_str \u001b[39m=\u001b[39m get_err_str(other)\n\u001b[1;32m-> 1022\u001b[0m \u001b[39mraise\u001b[39;00m UnitConversionError(\n\u001b[0;32m 1023\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00munit_str\u001b[39m}\u001b[39;00m\u001b[39m and \u001b[39m\u001b[39m{\u001b[39;00mother_str\u001b[39m}\u001b[39;00m\u001b[39m are not convertible\u001b[39m\u001b[39m\"\u001b[39m)\n", + "\u001b[1;31mUnitConversionError\u001b[0m: 'km nm / mm' (length) and 'km um' (area) are not convertible", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mUnitConversionError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\tradebooks\\spatial_resolution_&_swath_vs_focal_length_trade.ipynb Cell 10\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m sensor_spatial_resolution \u001b[39m=\u001b[39m payload\u001b[39m.\u001b[39;49mget_spatial_resolution(\n\u001b[0;32m 2\u001b[0m wavelength\u001b[39m=\u001b[39;49mtarget_wavelength,\n\u001b[0;32m 3\u001b[0m target_distance\u001b[39m=\u001b[39;49morbital_altitude,\n\u001b[0;32m 4\u001b[0m skew_angle\u001b[39m=\u001b[39;49mskew_angle[\u001b[39m0\u001b[39;49m],\n\u001b[0;32m 5\u001b[0m )\u001b[39m.\u001b[39mto(unit\u001b[39m.\u001b[39mm)\n\u001b[0;32m 7\u001b[0m display(\n\u001b[0;32m 8\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mSensor-limited spatial resolution test shape: \u001b[39m\u001b[39m{\u001b[39;00msensor_spatial_resolution\u001b[39m.\u001b[39mshape\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\n\u001b[0;32m 9\u001b[0m )\n\u001b[0;32m 11\u001b[0m swath \u001b[39m=\u001b[39m payload\u001b[39m.\u001b[39mget_swath(altitude\u001b[39m=\u001b[39morbital_altitude, skew_angle\u001b[39m=\u001b[39mskew_angle)\n", + "File \u001b[1;32m~\\Documents\\GitHub\\architect\\architect\\systems\\optical\\spectrometers.py:280\u001b[0m, in \u001b[0;36mHyperspectralImager.get_spatial_resolution\u001b[1;34m(self, wavelength, target_distance, skew_angle)\u001b[0m\n\u001b[0;32m 270\u001b[0m sensor_spatial_resolution \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_sensor_spatial_resolution(\n\u001b[0;32m 271\u001b[0m target_distance\u001b[39m=\u001b[39mtarget_distance\n\u001b[0;32m 272\u001b[0m )\n\u001b[0;32m 274\u001b[0m optical_spatial_resolution \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_optical_spatial_resolution(\n\u001b[0;32m 275\u001b[0m wavelength\u001b[39m=\u001b[39mwavelength,\n\u001b[0;32m 276\u001b[0m target_distance\u001b[39m=\u001b[39mtarget_distance,\n\u001b[0;32m 277\u001b[0m skew_angle\u001b[39m=\u001b[39mskew_angle,\n\u001b[0;32m 278\u001b[0m )\n\u001b[1;32m--> 280\u001b[0m spatial_resolution \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39;49mmaximum(\n\u001b[0;32m 281\u001b[0m sensor_spatial_resolution, optical_spatial_resolution\n\u001b[0;32m 282\u001b[0m )\n\u001b[0;32m 284\u001b[0m \u001b[39mreturn\u001b[39;00m spatial_resolution\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity.py:591\u001b[0m, in \u001b[0;36mQuantity.__array_ufunc__\u001b[1;34m(self, function, method, *inputs, **kwargs)\u001b[0m\n\u001b[0;32m 569\u001b[0m \u001b[39m\"\"\"Wrap numpy ufuncs, taking care of units.\u001b[39;00m\n\u001b[0;32m 570\u001b[0m \n\u001b[0;32m 571\u001b[0m \u001b[39mParameters\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 585\u001b[0m \u001b[39m Results of the ufunc, with the unit set properly.\u001b[39;00m\n\u001b[0;32m 586\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 587\u001b[0m \u001b[39m# Determine required conversion functions -- to bring the unit of the\u001b[39;00m\n\u001b[0;32m 588\u001b[0m \u001b[39m# input to that expected (e.g., radian for np.sin), or to get\u001b[39;00m\n\u001b[0;32m 589\u001b[0m \u001b[39m# consistent units between two inputs (e.g., in np.add) --\u001b[39;00m\n\u001b[0;32m 590\u001b[0m \u001b[39m# and the unit of the result (or tuple of units for nout > 1).\u001b[39;00m\n\u001b[1;32m--> 591\u001b[0m converters, unit \u001b[39m=\u001b[39m converters_and_unit(function, method, \u001b[39m*\u001b[39;49minputs)\n\u001b[0;32m 593\u001b[0m out \u001b[39m=\u001b[39m kwargs\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mout\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mNone\u001b[39;00m)\n\u001b[0;32m 594\u001b[0m \u001b[39m# Avoid loop back by turning any Quantity output into array views.\u001b[39;00m\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\converters.py:174\u001b[0m, in \u001b[0;36mconverters_and_unit\u001b[1;34m(function, method, *args)\u001b[0m\n\u001b[0;32m 171\u001b[0m units \u001b[39m=\u001b[39m [\u001b[39mgetattr\u001b[39m(arg, \u001b[39m'\u001b[39m\u001b[39munit\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mNone\u001b[39;00m) \u001b[39mfor\u001b[39;00m arg \u001b[39min\u001b[39;00m args]\n\u001b[0;32m 173\u001b[0m \u001b[39m# Determine possible conversion functions, and the result unit.\u001b[39;00m\n\u001b[1;32m--> 174\u001b[0m converters, result_unit \u001b[39m=\u001b[39m ufunc_helper(function, \u001b[39m*\u001b[39;49munits)\n\u001b[0;32m 176\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39many\u001b[39m(converter \u001b[39mis\u001b[39;00m \u001b[39mFalse\u001b[39;00m \u001b[39mfor\u001b[39;00m converter \u001b[39min\u001b[39;00m converters):\n\u001b[0;32m 177\u001b[0m \u001b[39m# for multi-argument ufuncs with a quantity and a non-quantity,\u001b[39;00m\n\u001b[0;32m 178\u001b[0m \u001b[39m# the quantity normally needs to be dimensionless, *except*\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 181\u001b[0m \u001b[39m# can just have the unit of the quantity\u001b[39;00m\n\u001b[0;32m 182\u001b[0m \u001b[39m# (this allows, e.g., `q > 0.` independent of unit)\u001b[39;00m\n\u001b[0;32m 183\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m 184\u001b[0m \u001b[39m# Don't fold this loop in the test above: this rare case\u001b[39;00m\n\u001b[0;32m 185\u001b[0m \u001b[39m# should not make the common case slower.\u001b[39;00m\n", + "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\helpers.py:70\u001b[0m, in \u001b[0;36mget_converters_and_unit\u001b[1;34m(f, unit1, unit2)\u001b[0m\n\u001b[0;32m 68\u001b[0m converters[changeable] \u001b[39m=\u001b[39m get_converter(unit2, unit1)\n\u001b[0;32m 69\u001b[0m \u001b[39mexcept\u001b[39;00m UnitsError:\n\u001b[1;32m---> 70\u001b[0m \u001b[39mraise\u001b[39;00m UnitConversionError(\n\u001b[0;32m 71\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mCan only apply \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m function to quantities \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 72\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mwith compatible dimensions\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 73\u001b[0m \u001b[39m.\u001b[39mformat(f\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m))\n\u001b[0;32m 75\u001b[0m \u001b[39mreturn\u001b[39;00m converters, unit1\n", + "\u001b[1;31mUnitConversionError\u001b[0m: Can only apply 'maximum' function to quantities with compatible dimensions" ] - }, - { - "data": { - "text/plain": [ - "'Swath shape: (29, 2)'" - ] - }, - "metadata": {}, - "output_type": "display_data" } ], "source": [ @@ -1651,7 +1647,7 @@ "\n", "df = pd.DataFrame.from_dict(data=data)\n", "\n", - "fig = plot.line(\n", + "graph = plot.line(\n", " df=df,\n", " x=focal_length_label,\n", " y=[\n", @@ -1665,10 +1661,10 @@ "\n", "df.to_csv(output_dir / \"data.csv\", index=False)\n", "plot.save(\n", - " fig=fig, name=\"spatial_resolution_&_swath_vs_focal_length_trade\", path=output_dir\n", + " fig=graph, name=\"spatial_resolution_&_swath_vs_focal_length_trade\", path=output_dir\n", ")\n", "\n", - "fig.show()\n", + "graph.show()\n", "display(df)\n", "display(payload)" ] @@ -1690,7 +1686,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.2" }, "orig_nbformat": 4, "vscode": { diff --git a/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb b/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb index 26307ea..37da53a 100644 --- a/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb +++ b/tradebooks/spectral_resolution_&_efficiency_vs_grism_resolvance_.ipynb @@ -21,7 +21,7 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect import components, systems" + "from architect.systems.optical import diffractors, sensors, spectrometers" ] }, { @@ -67,19 +67,17 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# region components\n", - "sensor = components.sensors.TauSWIR()\n", - "diffractor = components.diffractors.VPHGrism(fringe_frequency=fringe_frequency)\n", + "sensor = sensors.TauSWIR()\n", + "diffractor = diffractors.VPHGrism(fringe_frequency=fringe_frequency)\n", "# endregion\n", "\n", "# region systems\n", - "payload = systems.spectrometers.HyperspectralImager(\n", - " sensor=sensor, diffractor=diffractor\n", - ")\n", + "payload = spectrometers.HyperspectralImager(sensor=sensor, diffractor=diffractor)\n", "# endregion" ] }, @@ -92,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -123,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -398,22 +396,19 @@ "legend": { "tracegroupgap": 0 }, - "margin": { - "t": 60 - }, "template": { "data": { "bar": [ { "error_x": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "error_y": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -429,7 +424,7 @@ { "marker": { "line": { - "color": "#E5ECF6", + "color": "rgb(17,17,17)", "width": 0.5 }, "pattern": { @@ -444,18 +439,18 @@ "carpet": [ { "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" }, "type": "carpet" } @@ -773,10 +768,10 @@ ], "scatter": [ { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 + "marker": { + "line": { + "color": "#283442" + } }, "type": "scatter" } @@ -823,9 +818,8 @@ "scattergl": [ { "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" + "line": { + "color": "#283442" } }, "type": "scattergl" @@ -930,18 +924,18 @@ { "cells": { "fill": { - "color": "#EBF0F8" + "color": "#506784" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "header": { "fill": { - "color": "#C8D4E3" + "color": "#2a3f5f" }, "line": { - "color": "white" + "color": "rgb(17,17,17)" } }, "type": "table" @@ -950,7 +944,7 @@ }, "layout": { "annotationdefaults": { - "arrowcolor": "#2a3f5f", + "arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1 }, @@ -1106,117 +1100,130 @@ "#FECB52" ], "font": { - "color": "#2a3f5f" + "color": "#f2f5fa" }, "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", + "lakecolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", "showlakes": true, "showland": true, - "subunitcolor": "white" + "subunitcolor": "#506784" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { - "style": "light" + "style": "dark" }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", "polar": { "angularaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "radialaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "scene": { "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" }, "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", "gridwidth": 2, - "linecolor": "white", + "linecolor": "#506784", "showbackground": true, "ticks": "", - "zerolinecolor": "white" + "zerolinecolor": "#C8D4E3" } }, "shapedefaults": { "line": { - "color": "#2a3f5f" + "color": "#f2f5fa" } }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "bordercolor": "rgb(17,17,17)", + "borderwidth": 1, + "tickwidth": 0 + }, "ternary": { "aaxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, "baxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" }, - "bgcolor": "#E5ECF6", + "bgcolor": "rgb(17,17,17)", "caxis": { - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#506784", + "linecolor": "#506784", "ticks": "" } }, "title": { "x": 0.05 }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, "xaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 }, "yaxis": { "automargin": true, - "gridcolor": "white", - "linecolor": "white", + "gridcolor": "#283442", + "linecolor": "#506784", "ticks": "", "title": { "standoff": 15 }, - "zerolinecolor": "white", + "zerolinecolor": "#283442", "zerolinewidth": 2 } } }, + "title": { + "text": "Spatial Resolution and Efficiency vs. Grism Resolvance" + }, "xaxis": { "anchor": "y", "domain": [ @@ -1365,8 +1372,8 @@ " df=df,\n", " x=fringe_frequency_label,\n", " y=spectral_reolution_label,\n", - " title=None,\n", - " dark=False,\n", + " title=\"Spatial Resolution and Efficiency vs. Grism Resolvance\",\n", + " dark=True,\n", ")\n", "\n", "graph.show()\n", @@ -1390,7 +1397,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.2" }, "orig_nbformat": 4, "vscode": { From 362b3a5aaaeeebe4b940caa361ba789b34944e0c Mon Sep 17 00:00:00 2001 From: stephanieyflu <84485762+stephanieyflu@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:33:46 -0500 Subject: [PATCH 3/6] Add orient_tensor and orient_and_broadcast --- architect/libs/utillib.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/architect/libs/utillib.py b/architect/libs/utillib.py index 348e5c2..9fa1583 100644 --- a/architect/libs/utillib.py +++ b/architect/libs/utillib.py @@ -31,3 +31,43 @@ def hypercast(*arrays) -> list[np.ndarray]: hyperarrays.append(array_broadcasted) return hyperarrays + + +def orient_tensor(a, dim: int, dims: int) -> np.ndarray: + """Orient a tensor in a given dimensionality. + + Args: + a: array tensor. + dim: index of the dimension axis on which to orient the tensor. + dims: dimensionality of the tensor space. + + Returns: + The oriented tensor. + + """ + shape = [1] * dims + shape[dim] = -1 + + return np.reshape(a=a, newshape=shape) + + +def orient_and_broadcast(a, dim: int, shape) -> np.ndarray: + """Orient and broadcast a tensor into a given dimensionality. + + Args: + a: array tensor. + dim: index of the dimension axis on which to orient the tensor. + shape: dimensionality and size of broadcasted tensor. + + Returns: + The broadcasted tensor. + + """ + + a_oriented = orient_tensor(a=a, dim=dim, dims=len(shape)) + a_broadcasted = np.broadcast_to(array=a_oriented, shape=shape) + + if isinstance(a, Quantity): + a_broadcasted *= a.unit + + return a_broadcasted From c0c6fdeed15c3738309ab70114f2e0ebc2b5061a Mon Sep 17 00:00:00 2001 From: stephanieyflu <84485762+stephanieyflu@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:48:21 -0500 Subject: [PATCH 4/6] Resolve spatial rest + swath vs focal trade --- ...lution_&_swath_vs_focal_length_trade.ipynb | 116 ++++++++++++------ 1 file changed, 78 insertions(+), 38 deletions(-) diff --git a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb index 8012d7b..cf92ec6 100644 --- a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb +++ b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb @@ -10,9 +10,21 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 40, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ImportError", + "evalue": "cannot import name 'orient_and_broadcast' from 'architect.libs.utillib' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\libs\\utillib.py)", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\tradebooks\\spatial_resolution_&_swath_vs_focal_length_trade.ipynb Cell 2\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mIPython\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdisplay\u001b[39;00m \u001b[39mimport\u001b[39;00m display\n\u001b[0;32m 11\u001b[0m \u001b[39m# project\u001b[39;00m\n\u001b[1;32m---> 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39marchitect\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlibs\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mutillib\u001b[39;00m \u001b[39mimport\u001b[39;00m orient_and_broadcast\n\u001b[0;32m 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39marchitect\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msystems\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39moptical\u001b[39;00m \u001b[39mimport\u001b[39;00m foreoptics, masks, sensors, spectrometers\n", + "\u001b[1;31mImportError\u001b[0m: cannot import name 'orient_and_broadcast' from 'architect.libs.utillib' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\libs\\utillib.py)" + ] + } + ], "source": [ "# stdlib\n", "from pathlib import Path\n", @@ -25,7 +37,7 @@ "from IPython.display import display\n", "\n", "# project\n", - "from architect.libs import utillib\n", + "from architect.libs.utillib import orient_and_broadcast\n", "from architect.systems.optical import foreoptics, masks, sensors, spectrometers" ] }, @@ -39,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -56,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -74,9 +86,7 @@ "\n", "# region vectorization\n", "parameter_space_shape = (focal_length.size, slit_size.size)\n", - "focal_length = utillib.orient_and_broadcast(\n", - " a=focal_length, dim=0, shape=parameter_space_shape\n", - ")\n", + "focal_length = orient_and_broadcast(a=focal_length, dim=0, shape=parameter_space_shape)\n", "# endregion" ] }, @@ -89,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -115,31 +125,26 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 38, "metadata": {}, "outputs": [ { - "ename": "UnitConversionError", - "evalue": "Can only apply 'maximum' function to quantities with compatible dimensions", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mUnitConversionError\u001b[0m Traceback (most recent call last)", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\helpers.py:68\u001b[0m, in \u001b[0;36mget_converters_and_unit\u001b[1;34m(f, unit1, unit2)\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m---> 68\u001b[0m converters[changeable] \u001b[39m=\u001b[39m get_converter(unit2, unit1)\n\u001b[0;32m 69\u001b[0m \u001b[39mexcept\u001b[39;00m UnitsError:\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\helpers.py:32\u001b[0m, in \u001b[0;36mget_converter\u001b[1;34m(from_unit, to_unit)\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[39m\"\"\"Like Unit._get_converter, except returns None if no scaling is needed,\u001b[39;00m\n\u001b[0;32m 31\u001b[0m \u001b[39mi.e., if the inferred scale is unity.\"\"\"\u001b[39;00m\n\u001b[1;32m---> 32\u001b[0m converter \u001b[39m=\u001b[39m from_unit\u001b[39m.\u001b[39;49m_get_converter(to_unit)\n\u001b[0;32m 33\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mif\u001b[39;00m converter \u001b[39mis\u001b[39;00m unit_scale_converter \u001b[39melse\u001b[39;00m converter\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\core.py:1061\u001b[0m, in \u001b[0;36mUnitBase._get_converter\u001b[1;34m(self, other, equivalencies)\u001b[0m\n\u001b[0;32m 1059\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m-> 1061\u001b[0m \u001b[39mraise\u001b[39;00m exc\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\core.py:1046\u001b[0m, in \u001b[0;36mUnitBase._get_converter\u001b[1;34m(self, other, equivalencies)\u001b[0m\n\u001b[0;32m 1045\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m-> 1046\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_apply_equivalencies(\n\u001b[0;32m 1047\u001b[0m \u001b[39mself\u001b[39;49m, other, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_normalize_equivalencies(equivalencies))\n\u001b[0;32m 1048\u001b[0m \u001b[39mexcept\u001b[39;00m UnitsError \u001b[39mas\u001b[39;00m exc:\n\u001b[0;32m 1049\u001b[0m \u001b[39m# Last hope: maybe other knows how to do it?\u001b[39;00m\n\u001b[0;32m 1050\u001b[0m \u001b[39m# We assume the equivalencies have the unit itself as first item.\u001b[39;00m\n\u001b[0;32m 1051\u001b[0m \u001b[39m# TODO: maybe better for other to have a `_back_converter` method?\u001b[39;00m\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\core.py:1022\u001b[0m, in \u001b[0;36mUnitBase._apply_equivalencies\u001b[1;34m(self, unit, other, equivalencies)\u001b[0m\n\u001b[0;32m 1020\u001b[0m other_str \u001b[39m=\u001b[39m get_err_str(other)\n\u001b[1;32m-> 1022\u001b[0m \u001b[39mraise\u001b[39;00m UnitConversionError(\n\u001b[0;32m 1023\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00munit_str\u001b[39m}\u001b[39;00m\u001b[39m and \u001b[39m\u001b[39m{\u001b[39;00mother_str\u001b[39m}\u001b[39;00m\u001b[39m are not convertible\u001b[39m\u001b[39m\"\u001b[39m)\n", - "\u001b[1;31mUnitConversionError\u001b[0m: 'km nm / mm' (length) and 'km um' (area) are not convertible", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[1;31mUnitConversionError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\tradebooks\\spatial_resolution_&_swath_vs_focal_length_trade.ipynb Cell 10\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m sensor_spatial_resolution \u001b[39m=\u001b[39m payload\u001b[39m.\u001b[39;49mget_spatial_resolution(\n\u001b[0;32m 2\u001b[0m wavelength\u001b[39m=\u001b[39;49mtarget_wavelength,\n\u001b[0;32m 3\u001b[0m target_distance\u001b[39m=\u001b[39;49morbital_altitude,\n\u001b[0;32m 4\u001b[0m skew_angle\u001b[39m=\u001b[39;49mskew_angle[\u001b[39m0\u001b[39;49m],\n\u001b[0;32m 5\u001b[0m )\u001b[39m.\u001b[39mto(unit\u001b[39m.\u001b[39mm)\n\u001b[0;32m 7\u001b[0m display(\n\u001b[0;32m 8\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mSensor-limited spatial resolution test shape: \u001b[39m\u001b[39m{\u001b[39;00msensor_spatial_resolution\u001b[39m.\u001b[39mshape\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\n\u001b[0;32m 9\u001b[0m )\n\u001b[0;32m 11\u001b[0m swath \u001b[39m=\u001b[39m payload\u001b[39m.\u001b[39mget_swath(altitude\u001b[39m=\u001b[39morbital_altitude, skew_angle\u001b[39m=\u001b[39mskew_angle)\n", - "File \u001b[1;32m~\\Documents\\GitHub\\architect\\architect\\systems\\optical\\spectrometers.py:280\u001b[0m, in \u001b[0;36mHyperspectralImager.get_spatial_resolution\u001b[1;34m(self, wavelength, target_distance, skew_angle)\u001b[0m\n\u001b[0;32m 270\u001b[0m sensor_spatial_resolution \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_sensor_spatial_resolution(\n\u001b[0;32m 271\u001b[0m target_distance\u001b[39m=\u001b[39mtarget_distance\n\u001b[0;32m 272\u001b[0m )\n\u001b[0;32m 274\u001b[0m optical_spatial_resolution \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_optical_spatial_resolution(\n\u001b[0;32m 275\u001b[0m wavelength\u001b[39m=\u001b[39mwavelength,\n\u001b[0;32m 276\u001b[0m target_distance\u001b[39m=\u001b[39mtarget_distance,\n\u001b[0;32m 277\u001b[0m skew_angle\u001b[39m=\u001b[39mskew_angle,\n\u001b[0;32m 278\u001b[0m )\n\u001b[1;32m--> 280\u001b[0m spatial_resolution \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39;49mmaximum(\n\u001b[0;32m 281\u001b[0m sensor_spatial_resolution, optical_spatial_resolution\n\u001b[0;32m 282\u001b[0m )\n\u001b[0;32m 284\u001b[0m \u001b[39mreturn\u001b[39;00m spatial_resolution\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity.py:591\u001b[0m, in \u001b[0;36mQuantity.__array_ufunc__\u001b[1;34m(self, function, method, *inputs, **kwargs)\u001b[0m\n\u001b[0;32m 569\u001b[0m \u001b[39m\"\"\"Wrap numpy ufuncs, taking care of units.\u001b[39;00m\n\u001b[0;32m 570\u001b[0m \n\u001b[0;32m 571\u001b[0m \u001b[39mParameters\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 585\u001b[0m \u001b[39m Results of the ufunc, with the unit set properly.\u001b[39;00m\n\u001b[0;32m 586\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 587\u001b[0m \u001b[39m# Determine required conversion functions -- to bring the unit of the\u001b[39;00m\n\u001b[0;32m 588\u001b[0m \u001b[39m# input to that expected (e.g., radian for np.sin), or to get\u001b[39;00m\n\u001b[0;32m 589\u001b[0m \u001b[39m# consistent units between two inputs (e.g., in np.add) --\u001b[39;00m\n\u001b[0;32m 590\u001b[0m \u001b[39m# and the unit of the result (or tuple of units for nout > 1).\u001b[39;00m\n\u001b[1;32m--> 591\u001b[0m converters, unit \u001b[39m=\u001b[39m converters_and_unit(function, method, \u001b[39m*\u001b[39;49minputs)\n\u001b[0;32m 593\u001b[0m out \u001b[39m=\u001b[39m kwargs\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mout\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mNone\u001b[39;00m)\n\u001b[0;32m 594\u001b[0m \u001b[39m# Avoid loop back by turning any Quantity output into array views.\u001b[39;00m\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\converters.py:174\u001b[0m, in \u001b[0;36mconverters_and_unit\u001b[1;34m(function, method, *args)\u001b[0m\n\u001b[0;32m 171\u001b[0m units \u001b[39m=\u001b[39m [\u001b[39mgetattr\u001b[39m(arg, \u001b[39m'\u001b[39m\u001b[39munit\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mNone\u001b[39;00m) \u001b[39mfor\u001b[39;00m arg \u001b[39min\u001b[39;00m args]\n\u001b[0;32m 173\u001b[0m \u001b[39m# Determine possible conversion functions, and the result unit.\u001b[39;00m\n\u001b[1;32m--> 174\u001b[0m converters, result_unit \u001b[39m=\u001b[39m ufunc_helper(function, \u001b[39m*\u001b[39;49munits)\n\u001b[0;32m 176\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39many\u001b[39m(converter \u001b[39mis\u001b[39;00m \u001b[39mFalse\u001b[39;00m \u001b[39mfor\u001b[39;00m converter \u001b[39min\u001b[39;00m converters):\n\u001b[0;32m 177\u001b[0m \u001b[39m# for multi-argument ufuncs with a quantity and a non-quantity,\u001b[39;00m\n\u001b[0;32m 178\u001b[0m \u001b[39m# the quantity normally needs to be dimensionless, *except*\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 181\u001b[0m \u001b[39m# can just have the unit of the quantity\u001b[39;00m\n\u001b[0;32m 182\u001b[0m \u001b[39m# (this allows, e.g., `q > 0.` independent of unit)\u001b[39;00m\n\u001b[0;32m 183\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m 184\u001b[0m \u001b[39m# Don't fold this loop in the test above: this rare case\u001b[39;00m\n\u001b[0;32m 185\u001b[0m \u001b[39m# should not make the common case slower.\u001b[39;00m\n", - "File \u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\.venv\\lib\\site-packages\\astropy\\units\\quantity_helper\\helpers.py:70\u001b[0m, in \u001b[0;36mget_converters_and_unit\u001b[1;34m(f, unit1, unit2)\u001b[0m\n\u001b[0;32m 68\u001b[0m converters[changeable] \u001b[39m=\u001b[39m get_converter(unit2, unit1)\n\u001b[0;32m 69\u001b[0m \u001b[39mexcept\u001b[39;00m UnitsError:\n\u001b[1;32m---> 70\u001b[0m \u001b[39mraise\u001b[39;00m UnitConversionError(\n\u001b[0;32m 71\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mCan only apply \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m function to quantities \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 72\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mwith compatible dimensions\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 73\u001b[0m \u001b[39m.\u001b[39mformat(f\u001b[39m.\u001b[39m\u001b[39m__name__\u001b[39m))\n\u001b[0;32m 75\u001b[0m \u001b[39mreturn\u001b[39;00m converters, unit1\n", - "\u001b[1;31mUnitConversionError\u001b[0m: Can only apply 'maximum' function to quantities with compatible dimensions" - ] + "data": { + "text/plain": [ + "'Sensor-limited spatial resolution test shape: (29, 2)'" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "'Swath shape: (29, 2)'" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -166,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -424,9 +429,6 @@ }, "tracegroupgap": 0 }, - "margin": { - "t": 60 - }, "template": { "data": { "bar": [ @@ -1252,6 +1254,9 @@ } } }, + "title": { + "text": "Spatial Resolution and Swath vs. Focal Length" + }, "xaxis": { "anchor": "y", "domain": [ @@ -1614,15 +1619,50 @@ " None\n", " \n", " \n", - " components\n", + " systems\n", " list [4]\n", " None\n", " \n", + " \n", + " dimensions\n", + " None\n", + " None\n", + " \n", + " \n", + " mass\n", + " None\n", + " None\n", + " \n", + " \n", + " volume\n", + " None\n", + " None\n", + " \n", + " \n", + " density\n", + " None\n", + " None\n", + " \n", + " \n", + " index\n", + " None\n", + " None\n", + " \n", + " \n", + " transmittance\n", + " None\n", + " None\n", + " \n", + " \n", + " spatial_resolution\n", + " None\n", + " None\n", + " \n", " \n", "" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -1655,7 +1695,7 @@ " swath_label_x,\n", " swath_label_y,\n", " ],\n", - " title=None,\n", + " title=\"Spatial Resolution and Swath vs. Focal Length\",\n", " dark=True,\n", ")\n", "\n", From b1039a6babe37887974628aa54b420e019a25800 Mon Sep 17 00:00:00 2001 From: stephanieyflu <84485762+stephanieyflu@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:48:58 -0500 Subject: [PATCH 5/6] Update spatial res + swath vs focal trade --- ...lution_&_swath_vs_focal_length_trade.ipynb | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb index cf92ec6..5e2a9d2 100644 --- a/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb +++ b/tradebooks/spatial_resolution_&_swath_vs_focal_length_trade.ipynb @@ -10,21 +10,9 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 1, "metadata": {}, - "outputs": [ - { - "ename": "ImportError", - "evalue": "cannot import name 'orient_and_broadcast' from 'architect.libs.utillib' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\libs\\utillib.py)", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\Users\\Optics\\Documents\\GitHub\\architect\\tradebooks\\spatial_resolution_&_swath_vs_focal_length_trade.ipynb Cell 2\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mIPython\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdisplay\u001b[39;00m \u001b[39mimport\u001b[39;00m display\n\u001b[0;32m 11\u001b[0m \u001b[39m# project\u001b[39;00m\n\u001b[1;32m---> 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39marchitect\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlibs\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mutillib\u001b[39;00m \u001b[39mimport\u001b[39;00m orient_and_broadcast\n\u001b[0;32m 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39marchitect\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msystems\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39moptical\u001b[39;00m \u001b[39mimport\u001b[39;00m foreoptics, masks, sensors, spectrometers\n", - "\u001b[1;31mImportError\u001b[0m: cannot import name 'orient_and_broadcast' from 'architect.libs.utillib' (C:\\Users\\Optics\\Documents\\GitHub\\architect\\architect\\libs\\utillib.py)" - ] - } - ], + "outputs": [], "source": [ "# stdlib\n", "from pathlib import Path\n", @@ -51,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -68,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -99,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -125,7 +113,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -171,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -1662,7 +1650,7 @@ "" ], "text/plain": [ - "" + "" ] }, "metadata": {}, From 7cd66085d53cb6b65faaaf53c7be9f4a63352d19 Mon Sep 17 00:00:00 2001 From: Stephanie Lu <84485762+stephanieyflu@users.noreply.github.com> Date: Sat, 27 Jan 2024 17:38:41 +0000 Subject: [PATCH 6/6] Bump isort to 5.12.0 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c90246b..226fa1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort