.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_local_to_equatorial.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. 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_local_to_equatorial.py: =============================== Local to Equatorial Coordinates =============================== Where do my neutrinos come from? .. GENERATED FROM PYTHON SOURCE LINES 8-23 .. code-block:: default # sphinx_gallery_thumbnail_number = 3 __author__ = "moritz" import numpy as np import pandas as pd import matplotlib.pyplot as plt from km3astro.coord import local_event, neutrino_to_source_direction from km3astro.frame import get_location from km3astro.plot import plot_equatorial from km3astro.sources import VELA_X .. GENERATED FROM PYTHON SOURCE LINES 24-27 Detector Coordinates -------------------- Let's define some random events. .. GENERATED FROM PYTHON SOURCE LINES 27-37 .. code-block:: default theta = 10 * np.pi / 180 phi = 8 * np.pi / 180 time = pd.to_datetime( [ "2015-01-12T15:10:12", "2015-03-15T14:24:01", ] ).values[0] .. GENERATED FROM PYTHON SOURCE LINES 38-43 Note: Phi, theta: Where the neutrino is pointing to Zenith, azimuth: where the neutrino is coming from .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: default azimuth, zenith = neutrino_to_source_direction(phi, theta, radian=True) .. GENERATED FROM PYTHON SOURCE LINES 47-51 We want to observe them from the Orca location. Let's look at our geographical coordinates. In km3astro, there are the predefined locations "orca", "arca" and "antares". .. GENERATED FROM PYTHON SOURCE LINES 51-53 .. code-block:: default orca_loc = get_location("orca") .. GENERATED FROM PYTHON SOURCE LINES 54-57 Create event in local coordinates (aka AltAz or Horizontal Coordinates) This returns an ``astropy.SkyCoord`` instance. .. GENERATED FROM PYTHON SOURCE LINES 57-62 .. code-block:: default evt_local = local_event(theta, phi, time, location="orca") print(evt_local) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 63-70 Transform to equatorial -- ICRS ------------------------------- "If you’re looking for “J2000” coordinates, and aren’t sure if you want to use this or FK5, you probably want to use ICRS. It’s more well-defined as a catalog coordinate and is an inertial system, and is very close (within tens of milliarcseconds) to J2000 equatorial." .. GENERATED FROM PYTHON SOURCE LINES 70-74 .. code-block:: default evt_equat = evt_local.transform_to("icrs") print(evt_equat) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 75-76 How far removed are these events from a certain source? .. GENERATED FROM PYTHON SOURCE LINES 76-81 .. code-block:: default source_dist = evt_equat.separation(VELA_X) plt.hist(source_dist.degree, bins="auto") .. image-sg:: /auto_examples/images/sphx_glr_plot_local_to_equatorial_001.png :alt: plot local to equatorial :srcset: /auto_examples/images/sphx_glr_plot_local_to_equatorial_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none (array([1.]), array([34.62926186, 35.62926186]), ) .. GENERATED FROM PYTHON SOURCE LINES 82-83 Plot them in a square .. GENERATED FROM PYTHON SOURCE LINES 83-92 .. code-block:: default right_ascension_radian = evt_equat.ra.rad declination_radian = evt_equat.dec.rad plt.scatter(right_ascension_radian, declination_radian) plt.scatter(VELA_X.ra.rad, VELA_X.dec.rad) plt.xlabel("Right Ascension / rad") plt.ylabel("Declination / rad") .. image-sg:: /auto_examples/images/sphx_glr_plot_local_to_equatorial_002.png :alt: plot local to equatorial :srcset: /auto_examples/images/sphx_glr_plot_local_to_equatorial_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Text(13.597222222222216, 0.5, 'Declination / rad') .. GENERATED FROM PYTHON SOURCE LINES 93-97 Plot them in a skymap. We need this little wrap because astropy's convention for ra, dec differs from matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 97-101 .. code-block:: default ax = plot_equatorial(evt_equat, markersize=12, label="Event") plot_equatorial(VELA_X, markersize=12, ax=ax, label="Vela X") plt.legend(loc="best") .. image-sg:: /auto_examples/images/sphx_glr_plot_local_to_equatorial_003.png :alt: plot local to equatorial :srcset: /auto_examples/images/sphx_glr_plot_local_to_equatorial_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.641 seconds) .. _sphx_glr_download_auto_examples_plot_local_to_equatorial.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_local_to_equatorial.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_local_to_equatorial.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_