skysurvey: simulate what your survey sees#
skysurvey is a Python package to simulate astronomical targets (supernovae, kilonovae, any transient) as they would be observed by a real or imagined survey. It produces realistic, noisy lightcurves in seconds, for millions of targets.
Draw populations of SNe Ia, core-collapse SNe, kilonovae or any
sncosmo source at the right rate, with parameter models you can
fully customise.
Use real observing logs (ZTF, LSST, DES, SNLS) or build your own from a list of pointings, with field-based or free-form strategies.
Combine both to get the lightcurves you would have collected, ready for detection studies, lightcurve fits or cosmology.
Installation#
pip install skysurvey
See Installation for optional dependencies and the development version.
skysurvey in three steps#
Every simulation follows the same pattern: create a target (the truth), a survey (the observations), and combine them into a dataset (the data). See Key concepts for details.
1. Draw the truth.
import skysurvey
snia = skysurvey.SNeIa.from_draw(tstart=56_000, tstop=56_100, zmax=0.2)
snia.data.head()
import skysurvey
snii = skysurvey.SNeII.from_draw(tstart=56_000, tstop=56_100, zmax=0.1)
snii.data.head()
import skysurvey
# any sncosmo template (https://sncosmo.readthedocs.io/en/stable/source-list.html)
# with a Gaussian absolute magnitude distribution (mean, scatter)
snib = skysurvey.TSTransient("v19-2005bf-corr", magabs=[-18, 1])
# no rate given: set the number of targets with size
snib.draw(size=5_000, tstart=56_000, tstop=56_100, zmax=0.1, inplace=True)
snib.data.head()
2. Describe what has been observed, and when.
import numpy as np
from shapely import geometry
from skysurvey.tools import utils
# camera footprint (a 2 deg radius disk) and observing logs
footprint = geometry.Point(0, 0).buffer(2)
size = 10_000
data = {"gain": 1, "zp": 30,
"skynoise": np.random.normal(size=size, loc=200, scale=20),
"mjd": np.random.uniform(56_000, 56_100, size=size),
"band": np.random.choice(["desg", "desr", "desi"], size=size)}
data["ra"], data["dec"] = utils.random_radec(size=size,
ra_range=[200, 250],
dec_range=[-20, 10])
survey = skysurvey.Survey.from_pointings(data, footprint=footprint)
import numpy as np
from shapely import geometry
# camera footprint and field centers
footprint = geometry.Point(0, 0).buffer(2)
radec = {"C1": {"ra": 234.27, "dec": -27.11},
"C2": {"ra": 234.27, "dec": -29.09},
"C3": {"ra": 232.65, "dec": -28.10}}
size = 10_000
data = {"gain": 1, "zp": 30,
"skynoise": np.random.normal(size=size, loc=200, scale=20),
"mjd": np.random.uniform(56_000, 56_100, size=size),
"band": np.random.choice(["desg", "desr", "desi"], size=size),
"fieldid": np.random.choice(list(radec), size=size)}
survey = skysurvey.GridSurvey.from_pointings(data, radec, footprint=footprint)
# requires the ztfcosmo package
survey = skysurvey.ZTF.from_logs()
# path to an LSST opsim simulation (large file: loading takes a while)
survey = skysurvey.LSST.from_opsim("baseline_v3.3_10yrs.db")
3. Get the lightcurves you would have observed.
dset = skysurvey.DataSet.from_targets_and_survey(snia, survey)
dset.data.head()
dset.show_target_lightcurve()
dset = skysurvey.DataSet.from_targets_and_survey(snia, survey,
incl_error=False)
# pass a list of targets
dset = skysurvey.DataSet.from_targets_and_survey([snia, snii], survey)
Where to go next#
An end-to-end simulation in five minutes.
Learn targets, surveys and datasets step by step.
Short recipes for common tasks.
Science use cases: detection efficiency, survey design, Hubble diagram.
The built-in transient models and their parameters.
Every class and function, organised by concept.