Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an example notebook no how to convert hex geometry to square and back #767

Merged
merged 4 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ctapipe/image/geometry_converter_hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ def convert_geometry_hex1d_to_rect2d(geom, signal, key=None, add_rot=0):
signal : ndarray
1D (no timing) or 2D (with timing) array of the pmt signals
key : (default: None)
arbitrary key to store the transformed geometry in a buffer
arbitrary key (float, string) to store the transformed geometry in a buffer
The geometries (hex and rect) will be stored in a buffer.
The key is necessary to make the conversion back from rect to hex.
add_rot : int/float (default: 0)
parameter to apply an additional rotation of `add_rot` times 60°

Expand All @@ -320,6 +322,13 @@ def convert_geometry_hex1d_to_rect2d(geom, signal, key=None, add_rot=0):
rectangular grid
rot_img : ndarray 2D (no timing) or 3D (with timing)
the rectangular signal image

Example
-------
camera = event.inst.subarray.tel[tel_id].camera
image = event.r0.tel[tel_id].image[0]
key = camera.cam_id
square_geom, square_image = convert_geometry_hex1d_to_rect2d(camera, image, key=key)
"""

if key in rot_buffer:
Expand Down Expand Up @@ -455,6 +464,7 @@ def convert_geometry_rect2d_back_to_hexe1d(geom, signal, key=None,
pixel intensity stored in a 2D rectangular camera grid
key:
key to retrieve buffered geometry information
(see `convert_geometry_hex1d_to_rect2d`)
add_rot:
not used -- only here for backwards compatibility

Expand All @@ -473,6 +483,15 @@ def convert_geometry_rect2d_back_to_hexe1d(geom, signal, key=None,
instance of the original camera layout, which it tries to load by name (i.e.
the `cam_id`). The function assumes the original `cam_id` can be inferred from the
given, modified one by: `geom.cam_id.split('_')[0]`.

Example
-------
camera = event.inst.subarray.tel[tel_id].camera
image = event.r0.tel[tel_id].image[0]
key = camera.cam_id
square_geom, square_image = convert_geometry_hex1d_to_rect2d(camera, image, key=key)
hex_geom, hex_image = convert_geometry_rect2d_back_to_hexe1d(square_geom,
square_image, key = key)
"""

if key not in rot_buffer:
Expand Down
285 changes: 285 additions & 0 deletions examples/notebooks/convert_hex_to_square_example.ipynb

Large diffs are not rendered by default.