Skip to content

Commit

Permalink
Merge pull request #120 from AstarVienna/hb/makenotebooksrun
Browse files Browse the repository at this point in the history
Add optional cell to notebooks to reduce spectral resolution
  • Loading branch information
hugobuddel authored Jul 21, 2023
2 parents 9debf3b + e48b21a commit 98dc81b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ jobs:
- name: Run MICADO Notebooks
run: |
sed -i "s/USE_FULL_DETECTOR = True/USE_FULL_DETECTOR = False/g" MICADO/docs/example_notebooks/*.ipynb
sed -i 's/# cmd\[\\"!SIM.spectral.spectral_bin_width/cmd\[\\"!SIM.spectral.spectral_bin_width/g' MICADO/docs/example_notebooks/*.ipynb
for fn in MICADO/docs/example_notebooks/*.ipynb; do echo "${fn}"; /usr/bin/time -v jupytext --execute --update "${fn}"; done
20 changes: 19 additions & 1 deletion MICADO/docs/example_notebooks/4_scopesim_SPEC_pipe_galaxy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@
"cmd[\"!INST.aperture.height\"] = 0.05 "
]
},
{
"cell_type": "markdown",
"id": "19103513",
"metadata": {},
"source": [
"This notebook runs for about 10 minutes and requires about 20 GB of RAM. It is possible to speed up the computation and reduce the memory consumption (at the cost of lower accuracy) by specifying the spectral bin width. Uncomment the following line if you prefer a faster but less accurate simulation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "28dc2278",
"metadata": {},
"outputs": [],
"source": [
"# cmd[\"!SIM.spectral.spectral_bin_width\"] = 5e-4"
]
},
{
"cell_type": "markdown",
"id": "destroyed-outline",
Expand Down Expand Up @@ -1365,7 +1383,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
33 changes: 30 additions & 3 deletions MICADO/docs/example_notebooks/6_basic_spectroscopy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,41 @@
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "570c5068",
"metadata": {},
"outputs": [],
"source": [
"cmd = sim.UserCommands(use_instrument=\"MICADO\", set_modes=[\"SCAO\", \"SPEC_15000x50\"])"
]
},
{
"cell_type": "markdown",
"id": "a8910613",
"metadata": {},
"source": [
"This notebook runs for a long time and requires more than 30 GB of RAM. It is possible to speed up the computation and reduce the memory consumption (at the cost of lower accuracy) by specifying the spectral bin width. Uncomment the following line if you prefer a faster but less accurate simulation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9212f0dd",
"metadata": {},
"outputs": [],
"source": [
"# cmd[\"!SIM.spectral.spectral_bin_width\"] = 5e-4"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "conditional-secretariat",
"metadata": {},
"outputs": [],
"source": [
"cmd = sim.UserCommands(use_instrument=\"MICADO\", set_modes=[\"SCAO\", \"SPEC_15000x50\"])\n",
"micado = sim.OpticalTrain(cmd)"
]
},
Expand Down Expand Up @@ -559,7 +586,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -573,7 +600,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@
"metadata": {},
"outputs": [],
"source": [
"cmds = sim.UserCommands(use_instrument=\"MICADO\", set_modes=[\"SCAO\", \"SPEC_3000x50\"])\n",
"cmds[\"!OBS.dit\"] = 3600\n",
"cmds[\"!OBS.filter_name_fw1\"] = \"Spec_HK\" # Spec_IJ, Spec_HK\n",
"cmds[\"!OBS.filter_name_fw2\"] = \"open\"\n",
"cmd = sim.UserCommands(use_instrument=\"MICADO\", set_modes=[\"SCAO\", \"SPEC_3000x50\"])\n",
"cmd[\"!OBS.dit\"] = 3600\n",
"cmd[\"!OBS.filter_name_fw1\"] = \"Spec_HK\" # Spec_IJ, Spec_HK\n",
"cmd[\"!OBS.filter_name_fw2\"] = \"open\"\n",
"\n",
"micado = sim.OpticalTrain(cmd)\n",
"\n",
"micado = sim.OpticalTrain(cmds)\n",
"# The relay_psf and micado_ncpas_psf effects can be switched off,\n",
"# as these should have no effect on a slit-filling source. This\n",
"# reduces the memory footprint of the simulation.\n",
"micado[\"relay_psf\"].include = False\n",
"micado[\"micado_ncpas_psf\"].include = False\n",
"\n",
"# Set to False to test if everything is working, then flip to True\n",
"USE_FULL_DETECTOR = False\n",
Expand Down Expand Up @@ -358,7 +363,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 98dc81b

Please sign in to comment.