Skip to content

Commit

Permalink
use TelescopeFrame in doc notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
StFroese committed Jan 13, 2023
1 parent 2f3c6de commit 712e436
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 90 deletions.
20 changes: 14 additions & 6 deletions docs/examples/camera_display.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"outputs": [],
"source": [
"import matplotlib.pylab as plt\n",
"from ctapipe.coordinates import TelescopeFrame\n",
"from ctapipe.instrument import SubarrayDescription\n",
"from ctapipe.visualization import CameraDisplay\n",
"from ctapipe.image import toymodel\n",
Expand Down Expand Up @@ -68,14 +69,14 @@
"source": [
"# load an example camera geometry from a simulation file\n",
"subarray = SubarrayDescription.read(\"dataset://gamma_prod5.simtel.zst\")\n",
"geom = subarray.tel[100].camera.geometry\n",
"geom = subarray.tel[100].camera.geometry.transform_to(TelescopeFrame())\n",
"\n",
"# create a fake camera image to display:\n",
"model = toymodel.Gaussian(\n",
" x=0.2 * u.m,\n",
" y=0.0 * u.m,\n",
" width=0.05 * u.m,\n",
" length=0.15 * u.m,\n",
" x=-0.5 * u.deg,\n",
" y=0.0 * u.deg,\n",
" width=0.15 * u.deg,\n",
" length=0.5 * u.deg,\n",
" psi=\"35d\",\n",
")\n",
"\n",
Expand Down Expand Up @@ -120,6 +121,13 @@
" ...\n",
" mpld3.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -139,7 +147,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
25 changes: 13 additions & 12 deletions docs/examples/convert_images_to_2d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"from ctapipe.instrument import SubarrayDescription\n",
"from ctapipe.io import EventSource\n",
"from ctapipe.image.toymodel import Gaussian\n",
"from ctapipe.coordinates import TelescopeFrame\n",
"import matplotlib.pyplot as plt\n",
"import astropy.units as u"
]
Expand Down Expand Up @@ -47,15 +48,15 @@
"metadata": {},
"outputs": [],
"source": [
"geom = subarray.tel[40].camera.geometry\n",
"geom = subarray.tel[40].camera.geometry.transform_to(TelescopeFrame())\n",
"model = Gaussian(\n",
" x=0.05 * u.m,\n",
" y=0.05 * u.m,\n",
" width=0.01 * u.m,\n",
" length=0.05 * u.m,\n",
" x=1.0 * u.deg,\n",
" y=1.0 * u.deg,\n",
" width=0.2 * u.deg,\n",
" length=1.0 * u.deg,\n",
" psi=\"30d\",\n",
")\n",
"_, image, _ = model.generate_image(geom, intensity=500, nsb_level_pe=3)"
"_, image, _ = model.generate_image(geom, intensity=1000, nsb_level_pe=3)"
]
},
{
Expand Down Expand Up @@ -125,12 +126,12 @@
"metadata": {},
"outputs": [],
"source": [
"geom = subarray.tel[1].camera.geometry\n",
"geom = subarray.tel[1].camera.geometry.transform_to(TelescopeFrame())\n",
"model = Gaussian(\n",
" x=0.5 * u.m,\n",
" y=0.5 * u.m,\n",
" width=0.1 * u.m,\n",
" length=0.2 * u.m,\n",
" x=1.0 * u.deg,\n",
" y=1.0 * u.deg,\n",
" width=0.2 * u.deg,\n",
" length=0.4 * u.deg,\n",
" psi=\"30d\",\n",
")\n",
"_, image, _ = model.generate_image(geom, intensity=5000)"
Expand Down Expand Up @@ -208,7 +209,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
20 changes: 14 additions & 6 deletions docs/examples/dilate_image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@
"from ctapipe.instrument import SubarrayDescription\n",
"from ctapipe.visualization import CameraDisplay\n",
"from ctapipe.image import toymodel, tailcuts_clean, dilate\n",
"from ctapipe.coordinates import TelescopeFrame\n",
"\n",
"# Load a camera from an example file\n",
"subarray = SubarrayDescription.read(\"dataset://gamma_prod5.simtel.zst\")\n",
"geom = subarray.tel[100].camera.geometry\n",
"geom = subarray.tel[100].camera.geometry.transform_to(TelescopeFrame())\n",
"\n",
"# Create a fake camera image to display:\n",
"model = toymodel.Gaussian(\n",
" x=0.2 * u.m,\n",
" y=0.0 * u.m,\n",
" width=0.05 * u.m,\n",
" length=0.15 * u.m,\n",
" x=0.4 * u.deg,\n",
" y=0.0 * u.deg,\n",
" width=0.15 * u.deg,\n",
" length=0.50 * u.deg,\n",
" psi=\"35d\",\n",
")\n",
"\n",
Expand Down Expand Up @@ -110,6 +111,13 @@
" plt.subplot(1, 7, ii + 1)\n",
" show_dilate(cleanmask.copy(), times=ii)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -128,7 +136,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
18 changes: 10 additions & 8 deletions docs/tutorials/calibrated_data_exploration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"print(event.r1)"
Expand Down Expand Up @@ -160,10 +158,11 @@
"outputs": [],
"source": [
"from ctapipe.visualization import CameraDisplay\n",
"from ctapipe.coordinates import TelescopeFrame\n",
"\n",
"tel_id = sorted(event.r1.tel.keys())[1]\n",
"sub = source.subarray\n",
"geometry = sub.tel[tel_id].camera.geometry\n",
"geometry = sub.tel[tel_id].camera.geometry.transform_to(TelescopeFrame())\n",
"image = event.dl1.tel[tel_id].image"
]
},
Expand Down Expand Up @@ -228,8 +227,9 @@
"disp.overlay_moments(params, color=\"red\", lw=3)\n",
"disp.highlight_pixels(mask, color=\"white\", alpha=0.3, linewidth=2)\n",
"\n",
"plt.xlim(params.x.to_value(u.m) - 0.5, params.x.to_value(u.m) + 0.5)\n",
"plt.ylim(params.y.to_value(u.m) - 0.5, params.y.to_value(u.m) + 0.5)"
"\n",
"plt.xlim(params.fov_lon.to_value(u.deg) - 2, params.fov_lon.to_value(u.deg) + 2)\n",
"plt.ylim(params.fov_lat.to_value(u.deg) - 2, params.fov_lat.to_value(u.deg) + 2)"
]
},
{
Expand Down Expand Up @@ -326,7 +326,9 @@
"source": [
"plt.figure(figsize=(8, 8))\n",
"\n",
"disp = CameraDisplay(tel.camera.geometry, image=image_sum)\n",
"disp = CameraDisplay(\n",
" tel.camera.geometry.transform_to(TelescopeFrame()), image=image_sum\n",
")\n",
"disp.overlay_moments(params, with_label=False)\n",
"plt.title(\"Sum of {}x {}\".format(len(cams_in_event), tel))"
]
Expand Down Expand Up @@ -390,7 +392,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 712e436

Please sign in to comment.