.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_filling_factor.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_filling_factor.py: Filling factor of various sky grids for the Dorado mission ========================================================== .. GENERATED FROM PYTHON SOURCE LINES 7-8 First, some imports. .. GENERATED FROM PYTHON SOURCE LINES 8-18 .. code-block:: Python from functools import partial from astropy_healpix import HEALPix from astropy.coordinates import ICRS from astropy import units as u from dorado.scheduling import mission, skygrid from matplotlib import pyplot as plt import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 19-20 Select a HEALPix resolution for spatial calculations. .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: Python hpx = HEALPix(nside=512, frame=ICRS()) .. GENERATED FROM PYTHON SOURCE LINES 24-25 Determine the area of the field of view. .. GENERATED FROM PYTHON SOURCE LINES 25-29 .. code-block:: Python fov = mission.dorado().fov fov_area = len(fov.footprint_healpix(hpx)) * hpx.pixel_area .. GENERATED FROM PYTHON SOURCE LINES 30-31 Compute the filling factor for all sky grid methods. .. GENERATED FROM PYTHON SOURCE LINES 31-65 .. code-block:: Python methods = { 'geodesic(class_="I")': partial(skygrid.geodesic, class_='I'), 'geodesic(class_="II")': partial(skygrid.geodesic, class_='II'), 'geodesic(class_="III")': partial(skygrid.geodesic, class_='III'), 'golden_angle_spiral': skygrid.golden_angle_spiral, 'sinusoidal': skygrid.sinusoidal } fig_width, fig_height = plt.rcParams['figure.figsize'] fig, (ax1, ax2) = plt.subplots( 1, 2, figsize=(2 * fig_width, fig_height), sharey=True) ax1.set_xlabel('Number of tiles') ax2.set_xlabel('Requested area per tile (deg$^2$)') ax1.set_ylabel('1 - filling factor') ax1.set_yscale('log') areas = np.geomspace(0.5 * fov_area, fov_area).to(u.deg**2) for method_name, method in methods.items(): number_of_tiles = np.empty(len(areas), dtype=int) one_minus_fill_factors = np.empty(len(areas), dtype=float) for i, area in enumerate(areas): centers = method(area) rolls = np.asarray([0]) * u.deg pixels = set() for more_pixels, in fov.footprint_healpix_grid(hpx, centers, rolls): pixels |= set(more_pixels) number_of_tiles[i] = len(centers) one_minus_fill_factors[i] = 1 - len(pixels) / hpx.npix ax1.plot(number_of_tiles, one_minus_fill_factors, '.-', label=method_name) ax2.plot(areas, one_minus_fill_factors, '.-', label=method_name) ax1.legend() .. image-sg:: /examples/images/sphx_glr_plot_filling_factor_001.png :alt: plot filling factor :srcset: /examples/images/sphx_glr_plot_filling_factor_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (10 minutes 34.898 seconds) .. _sphx_glr_download_examples_plot_filling_factor.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_filling_factor.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_filling_factor.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_