

.. _sphx_glr_auto_examples_astro_orca.py:


================
Orca Astro Test.
================

This example needs Astropy: ``pip install astropy``.

You'll also want to check out the ``km3astro`` project, which wraps a nicer
API around this: git.km3net.de/moritz/km3astro

Take some events in the detector and transform them
to galactic coordinates.



.. code-block:: python


    from astropy.coordinates import (Angle, Latitude, Longitude, Galactic, # noqa
                                     EarthLocation, AltAz, SkyCoord)  # noqa
    from astropy.units import degree, minute, meter     # noqa
    from astropy.time import Time
    import matplotlib.pyplot as plt
    import numpy as np

    from km3pipe.constants import orca_longitude, orca_latitude, orca_height
    import km3pipe.style
    km3pipe.style.use("km3pipe")


    # load orca coordinates
    orca_loc = EarthLocation.from_geodetic(
        Longitude(orca_longitude * degree),
        Latitude(orca_latitude * degree),
        height=orca_height
    )
    orca_frame = AltAz(obstime=Time.now(), location=orca_loc)

    # prepare canvases
    fig = plt.figure(figsize=(10, 4))
    ax = fig.add_subplot(111, projection='aitoff')

    # generate some zenith + azimuth pairs
    az = np.random.rand(100)*360.0 * degree
    alt = (np.random.rand(100)*180.0-90.0) * degree

    orca_event = SkyCoord(alt=alt, az=az, frame=orca_frame)
    orca_event_origin = orca_event.galactic
    ax.plot(orca_event_origin.l, orca_event_origin.b, 'o',
            markersize=10, alpha=0.3, color='k')
    plt.show()

**Total running time of the script:** ( 0 minutes  0.000 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: astro_orca.py <astro_orca.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: astro_orca.ipynb <astro_orca.ipynb>`

.. rst-class:: sphx-glr-signature

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
