.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/simulating/plot_cut_region.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_auto_examples_simulating_plot_cut_region.py: Cut: Sky Region =================== :meth:`~uvex_transients.simulation.core.SurveySimulator.filter_by_region` keeps only events inside an arbitrary sky region: a `~regions.SkyRegion`/`~regions.Regions` instance, or a path to a region file (e.g. a DS9 ``.reg``). It uses the same ``regions``/:func:`~m4opt.fov.contains` convention `~uvex_transients.surveys.base.SurveySchedule` uses for its own instrument FOV, so no WCS is needed. .. GENERATED FROM PYTHON SOURCE LINES 12-37 .. code-block:: Python from astropy import units as u from astropy.coordinates import SkyCoord from matplotlib import pyplot as plt from regions import CircleSkyRegion from uvex_transients.missions import uvex_fast as uvex from uvex_transients.simulation.core import SurveySimulator from uvex_transients.surveys import get_schedule from uvex_transients.transients.supernovae import MagnetarSLSNe from uvex_transients.utils.plotting import resolve_fig_axes, set_plot_style set_plot_style() schedule = get_schedule() slsn = MagnetarSLSNe() simulator = SurveySimulator(schedule, transients={"slsn": slsn}, simulation_seed=42) TIME_BINS = 10 NSIDE = 32 DOWNSAMPLE = 50 catalog = simulator.generate_events(time_bins=TIME_BINS, nside=NSIDE, sampling_factor=1 / DOWNSAMPLE) print(f"{len(catalog) * DOWNSAMPLE} events sampled.") .. rst-class:: sphx-glr-script-out .. code-block:: none Generating events: 0%| | 0/10 [00:00. .. GENERATED FROM PYTHON SOURCE LINES 50-52 Sky positions, in and out of the region ---------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 52-69 .. code-block:: Python fig, ax = resolve_fig_axes(fig_size=(8, 4), subplot_kw={"projection": "aitoff"}) ax.grid(True) ax.scatter( catalog.coord.ra.wrap_at(180 * u.deg).radian, catalog.coord.dec.radian, s=2, alpha=0.2, color="#888888", label="All" ) ax.scatter( in_region.coord.ra.wrap_at(180 * u.deg).radian, in_region.coord.dec.radian, s=4, color="#4C72B0", label="In region", ) ax.legend(loc="lower right", markerscale=4) ax.set_title("Effect of the region cut") fig.tight_layout() plt.show() .. image-sg:: /auto_examples/simulating/images/sphx_glr_plot_cut_region_001.png :alt: Effect of the region cut :srcset: /auto_examples/simulating/images/sphx_glr_plot_cut_region_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.059 seconds) .. _sphx_glr_download_auto_examples_simulating_plot_cut_region.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cut_region.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cut_region.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_cut_region.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_