.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` 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. .. code-block:: python from __future__ import absolute_import, print_function, division # Author: Tamas Gal # License: BSD-3 from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import km3pipe as kp import km3pipe.style km3pipe.style.use('km3pipe') km3pipe.style.use('talk') DETX = 'data/orca_115strings_av23min20mhorizontal_18OMs_alt9mvertical_v1.detx' det = kp.hardware.Detector(DETX) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Loading style definitions from '/home/docs/checkouts/readthedocs.org/user_builds/km3pipe/conda/stable/lib/python3.5/site-packages/km3pipe/kp-data/stylelib/km3pipe.mplstyle' Loading style definitions from '/home/docs/checkouts/readthedocs.org/user_builds/km3pipe/conda/stable/lib/python3.5/site-packages/km3pipe/kp-data/stylelib/km3pipe-talk.mplstyle' Detector: Parsing the DETX header Detector: Reading PMT information... Detector: Done. Alternatively, you can use the `det_id` to retrieve the geometry from the DB. .. code-block:: python # det = kp.hardware.Detector(det_id=29) Let's take the first DOM ID .. code-block:: python dom_id = det.dom_ids[0] ...and get the table of the PMTs in the chosen DOM: .. code-block:: python pmts = det.pmts[det.pmts.dom_id == dom_id] The `quiver` function can directly plot the PMT data, since those are stored as numpy arrays. .. code-block:: python fig = plt.figure() ax = fig.gca(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:: /auto_examples/images/sphx_glr_plot_pmt_directions_001.png :class: sphx-glr-single-img **Total running time of the script:** ( 0 minutes 1.384 seconds) .. _sphx_glr_download_auto_examples_plot_pmt_directions.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_pmt_directions.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_pmt_directions.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_