.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_sun_in_local.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_sun_in_local.py: ======================== Sun in local coordinates ======================== Show off some coordinate transformations. .. GENERATED FROM PYTHON SOURCE LINES 8-20 .. code-block:: default # Author: Moritz Lotze # License: BSD-3 from astropy.units import deg import numpy as np import pandas as pd from km3astro.random import random_date, random_azimuth, random_zenith from km3astro.coord import local_frame, Sun, source_to_neutrino_direction .. GENERATED FROM PYTHON SOURCE LINES 21-22 generate some random events .. GENERATED FROM PYTHON SOURCE LINES 22-28 .. code-block:: default n_evts = 1e4 zen = random_zenith(n=n_evts) time = random_date(n=n_evts) azi = random_azimuth(n=n_evts) .. GENERATED FROM PYTHON SOURCE LINES 29-30 transform to horizontal coordinates .. GENERATED FROM PYTHON SOURCE LINES 30-52 .. code-block:: default orca_frame = local_frame(time=time, location="orca") sun = Sun(time) sun_orca = sun.transform_to(orca_frame) sun_azi = sun_orca.az.rad sun_zen = (90 * deg - sun_orca.alt).rad sun_phi, sun_theta = source_to_neutrino_direction(sun_azi, sun_zen) sun_df = pd.DataFrame( { "Sun Azimuth": sun_azi, "Sun Zenith": sun_zen, "Sun Cos Zenith": np.cos(sun_zen), "Sun Phi": sun_phi, "Sun Theta": sun_theta, "Sun Cos Theta": np.cos(sun_theta), } ) .. GENERATED FROM PYTHON SOURCE LINES 53-57 .. code-block:: default sun_df.plot.hexbin("Sun Zenith", "Sun Azimuth", cmap="viridis") .. image-sg:: /auto_examples/images/sphx_glr_plot_sun_in_local_001.png :alt: plot sun in local :srcset: /auto_examples/images/sphx_glr_plot_sun_in_local_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 58-61 .. code-block:: default sun_df.plot.hexbin("Sun Cos Zenith", "Sun Azimuth", cmap="magma") .. image-sg:: /auto_examples/images/sphx_glr_plot_sun_in_local_002.png :alt: plot sun in local :srcset: /auto_examples/images/sphx_glr_plot_sun_in_local_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 62-65 .. code-block:: default sun_df.plot.hexbin("Sun Theta", "Sun Phi", cmap="inferno") .. image-sg:: /auto_examples/images/sphx_glr_plot_sun_in_local_003.png :alt: plot sun in local :srcset: /auto_examples/images/sphx_glr_plot_sun_in_local_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: default sun_df.plot.hexbin("Sun Cos Theta", "Sun Phi", cmap="plasma") .. image-sg:: /auto_examples/images/sphx_glr_plot_sun_in_local_004.png :alt: plot sun in local :srcset: /auto_examples/images/sphx_glr_plot_sun_in_local_004.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 3.455 seconds) .. _sphx_glr_download_auto_examples_plot_sun_in_local.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_sun_in_local.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sun_in_local.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_