.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_polar_horns.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_examples_plot_polar_horns.py: Polar horns =========== .. GENERATED FROM PYTHON SOURCE LINES 7-8 First, some imports. .. GENERATED FROM PYTHON SOURCE LINES 8-19 .. code-block:: Python from astroplan import Observer from astropy.coordinates import ITRS from astropy.time import Time from astropy import units as u from astropy_healpix import HEALPix from dorado.scheduling.constraints import TrappedParticleFluxConstraint from ligo.skymap import plot # noqa: F401 from matplotlib import pyplot as plt import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 20-21 Create trapped particle constraint. .. GENERATED FROM PYTHON SOURCE LINES 21-28 .. code-block:: Python constraint = TrappedParticleFluxConstraint( flux=100 * u.cm**-2 * u.s**-1, energy=1 * u.MeV, particle='e', solar='max') .. GENERATED FROM PYTHON SOURCE LINES 29-30 Evaluate the constraint on a HEALPix grid in ITRS coordinates. .. GENERATED FROM PYTHON SOURCE LINES 30-45 .. code-block:: Python obstime = Time('2021-01-01') frame = ITRS(obstime=obstime) healpix = HEALPix(64, frame=frame) locations = healpix.healpix_to_skycoord(np.arange(healpix.npix)) locations = ITRS(lon=locations.spherical.lon, lat=locations.spherical.lat, distance=1 * u.Rearth + 600 * u.km, representation_type='spherical') locations = locations.earth_location constraint_values = np.asarray([ constraint.compute_constraint(obstime, Observer(location)) for location in locations]) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/dorado-scheduling/envs/latest/lib/python3.11/site-packages/numpy/lib/function_base.py:2455: RuntimeWarning: invalid value encountered in aep8 (vectorized) outputs = ufunc(*inputs) .. GENERATED FROM PYTHON SOURCE LINES 46-47 Plot a map of the true/false value of the constraint. .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: Python ax = plt.axes(projection='geo mollweide') ax.imshow_hpx(constraint_values, order='nearest-neighbor', cmap='binary_r') ax.grid() .. image-sg:: /examples/images/sphx_glr_plot_polar_horns_001.png :alt: plot polar horns :srcset: /examples/images/sphx_glr_plot_polar_horns_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (4 minutes 4.699 seconds) .. _sphx_glr_download_examples_plot_polar_horns.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_polar_horns.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_polar_horns.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_