<jupyter_start><jupyter_text>Example on how to convert hexagonal cameras into square grid and back to hex<jupyter_code>from ctapipe.utils import get_dataset
from ctapipe.image.geometry_converter import convert_geometry_hex1d_to_rect2d, convert_geometry_rect2d_back_to_hexe1d
from ctapipe.visualization import CameraDisplay
from ctapipe.io import event_source
import copy
import matplotlib.pyplot as plt
filename = get_dataset('gamma_test.simtel.gz')
source = event_source(filename)
source.allowed_tels = {1}
events = [copy.deepcopy(event) for event in source]
event = events[0]
camera = event.inst.subarray.tel[1].camera
image = event.r0.tel[1].image[0]
CameraDisplay(camera, image)<jupyter_output><empty_output><jupyter_text>Conversion into square geometry **A key must be speficied to be able to convert back to hexagonal afterwards**   The conversion geometry is stored in `ctapipe.image.geometry_convert.rot_buffer`<jupyter_code>key = 0
square_geom, square_image = convert_geometry_hex1d_to_rect2d(camera, image, key=key)
plt.imshow(square_image)<jupyter_output><empty_output><jupyter_text>Conversion back to hexagonal geometry<jupyter_code>hex_geom, hex_image = convert_geometry_rect2d_back_to_hexe1d(square_geom, square_image, key=key)
CameraDisplay(hex_geom, hex_image)<jupyter_output><empty_output><jupyter_text>Let's check that the images are exactly the same:<jupyter_code>assert (hex_image == image).all()
assert hex_geom == camera<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08355978260869565, 'fraction_numerical': 0.010190217391304348, 'mean_word_length': 9.08904109589041, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '31949', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 508, 'n_tokens_neox': 495, 'n_words': 110, 'path': 'examples/notebooks/convert_hex_to_square_example.ipynb', 'repo_name': 'Mike7477/ctapipe', 'size': '1472'}