Cut: Sky Region#

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/contains() convention ~uvex_transients.surveys.base.SurveySchedule uses for its own instrument FOV, so no WCS is needed.

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.")
Generating events:   0%|          | 0/10 [00:00<?, ?bin/s]
Generating events:   0%|          | 0/10 [00:00<?, ?bin/s, bin=1/10, type=slsn]

Building HEALPix coverage index for (nside=32, order='nested'); this can be slow for a long schedule.

Generating events:   0%|          | 0/10 [00:00<?, ?bin/s, bin=1/10, type=slsn]
Generating events:  10%|█         | 1/10 [00:07<01:07,  7.48s/bin, bin=1/10, type=slsn]
Generating events:  10%|█         | 1/10 [00:07<01:07,  7.48s/bin, bin=2/10, type=slsn]
Generating events:  20%|██        | 2/10 [00:07<00:59,  7.48s/bin, bin=3/10, type=slsn]
Generating events:  30%|███       | 3/10 [00:07<00:52,  7.48s/bin, bin=4/10, type=slsn]
Generating events:  40%|████      | 4/10 [00:07<00:08,  1.45s/bin, bin=4/10, type=slsn]
Generating events:  40%|████      | 4/10 [00:07<00:08,  1.45s/bin, bin=5/10, type=slsn]
Generating events:  50%|█████     | 5/10 [00:07<00:07,  1.45s/bin, bin=6/10, type=slsn]
Generating events:  60%|██████    | 6/10 [00:07<00:05,  1.45s/bin, bin=7/10, type=slsn]
Generating events:  70%|███████   | 7/10 [00:07<00:02,  1.45bin/s, bin=7/10, type=slsn]
Generating events:  70%|███████   | 7/10 [00:07<00:02,  1.45bin/s, bin=8/10, type=slsn]
Generating events:  80%|████████  | 8/10 [00:07<00:01,  1.45bin/s, bin=9/10, type=slsn]
Generating events:  90%|█████████ | 9/10 [00:07<00:00,  1.45bin/s, bin=10/10, type=slsn]
Generating events: 100%|██████████| 10/10 [00:07<00:00,  2.46bin/s, bin=10/10, type=slsn]
Generating events: 100%|██████████| 10/10 [00:07<00:00,  1.28bin/s, bin=10/10, type=slsn]
28550 events sampled.

A circular region around the median sampled position#

Any ~regions.SkyRegion works; a circle is the simplest.

700 events fall within 20.0 deg of <SkyCoord (ICRS): (ra, dec) in deg
    (183.67607776, -2.33389402)>.

Sky positions, in and out of the region#

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()
Effect of the region cut

Total running time of the script: (0 minutes 9.059 seconds)

Gallery generated by Sphinx-Gallery