.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_pmt_directions.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_pmt_directions.py: ================== PMT Directions ================== Plot the PMT directions for a given DOM. .. GENERATED FROM PYTHON SOURCE LINES 11-30 .. code-block:: Python # Author: Tamas Gal # License: BSD-3 from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt from km3net_testdata import data_path import km3pipe as kp import km3pipe.style km3pipe.style.use("km3pipe") km3pipe.style.use("talk") detx = data_path( "detx/orca_115strings_av23min20mhorizontal_18OMs_alt9mvertical_v1.detx" ) det = kp.hardware.Detector(detx) .. rst-class:: sphx-glr-script-out .. code-block:: none Detector: Parsing the DETX header Detector: Reading PMT information... Detector: Done. .. GENERATED FROM PYTHON SOURCE LINES 31-32 Alternatively, you can use the `det_id` to retrieve the geometry from the DB. .. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: Python # det = kp.hardware.Detector(det_id=29) .. GENERATED FROM PYTHON SOURCE LINES 36-37 Let's take the first DOM ID .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python dom_id = det.dom_ids[0] .. GENERATED FROM PYTHON SOURCE LINES 40-41 ...and get the table of the PMTs in the chosen DOM: .. GENERATED FROM PYTHON SOURCE LINES 41-44 .. code-block:: Python pmts = det.pmts[det.pmts.dom_id == dom_id] .. GENERATED FROM PYTHON SOURCE LINES 45-47 The `quiver` function can directly plot the PMT data, since those are stored as numpy arrays. .. GENERATED FROM PYTHON SOURCE LINES 47-59 .. code-block:: Python fig = plt.figure() ax = plt.axes(projection="3d") ax.quiver( pmts.pos_x, pmts.pos_y, pmts.pos_z, pmts.dir_x, pmts.dir_y, pmts.dir_z, length=0.1 ) ax.set_xlabel("x [m]") ax.set_ylabel("y [m]") ax.set_zlabel("z [m]") ax.set_title("PMT directions on DOM {}".format(dom_id)) .. image-sg:: /auto_examples/images/sphx_glr_plot_pmt_directions_001.png :alt: PMT directions on DOM 1 :srcset: /auto_examples/images/sphx_glr_plot_pmt_directions_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(0.5, 1.0, 'PMT directions on DOM 1') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.681 seconds) .. _sphx_glr_download_auto_examples_plot_pmt_directions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_pmt_directions.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_pmt_directions.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_