skysurvey#

skysurvey is a python package made to simulate astronomical targets as they would be observed by a survey.

To simulate a realistic lightcurves you need two things:

  1. target properties as given by nature.

  2. survey observing data providing what has been observed when and under which condition.

Joining these to create:

  1. a dataset, i.e. simulated data of the targets observed by your survey.

Elements#

Targets

Target are objects as given by natures. You can generate realistic targets, building complex parametrisation thanks to the modeldag backend. skysurvey provides multi-predefined targets, such as SNeIa, SNII, or any sncosmo TimeSerie Source.

Survey

Survey objects handle your observations. It can match sky positions with observing logs and provide observing statistics. There are two kinds of surveys: Survey that accept any observing pattern and GridSurvey that are customed for field-based surveys.

DataSet

DataSet corresponds the actual data you would have collected observing target (s) with your survey. A dataset is easy and fast to load, and it contains analytical and visualisation tools.

Make Targets
Build a Survey
Create a DataSet
_images/concept_image.png

Sharp start#

You need to create a Transient object, a Survey object and then to simulate how your survey would observe your targets. This latter is called a DataSet.

Step 1: transients#

Draw the ‘truth’

import skysurvey
snia = skysurvey.SNeIa()
data = snia.draw(size=50_000)
data.head(5) # see also self.data
import skysurvey
snii = skysurvey.SNII()
data = snii.draw(size=50_000)
data.head(5) # see also self.data
import skysurvey
snib = skysurvey.TSTransient("v19-2005bf-corr")
# see https://sncosmo.readthedocs.io/en/stable/source-list.html
snib.draw(50_000)
snib.data.head(5) # also self.data

You have more built-in targets. You can also directly use target = Target.from_draw().

Step 2: survey#

provide what has been observed when

import skysurvey

# footprint
from shapely import geometry
footprint = geometry.Point(0,0).buffer(2)

# observing logs
import numpy as np
from skysurvey.tools import utils
size = 10_000

data = {}
data["gain"] = 1
data["zp"] = 30
data["skynoise"] = np.random.normal(size=size, loc=200, scale=20)
data["mjd"] = np.random.uniform(56_000, 56_200, size=size)
data["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])

# Load a GridSurvey
survey = skysurvey.Survey.from_pointings(data, footprint=footprint)
import skysurvey

# footprint
from shapely import geometry
footprint = geometry.Point(0,0).buffer(2)

# fields
import numpy as np
radec = {'C1': {'dec': -27.11161, 'ra': 54.274292+180},
         'C2': {'dec': -29.08839, 'ra': 54.274292+180},
         'C3': {'dec': -28.10000, 'ra': 52.648417+180}
         }

# observing logs
size = 10_000

data = {}
data["gain"] = 1
data["zp"] = 30
data["skynoise"] = np.random.normal(size=size, loc=200, scale=20)
data["mjd"] = np.random.uniform(56_000, 56_200, size=size)
data["band"] = np.random.choice(["desg","desr","desi"], size=size)

data["fieldid"] = np.random.choice(list(radec.keys()), size=size)

# Load a GridSurvey
survey = skysurvey.GridSurvey.from_pointings(data, radec,
                                             footprint=footprint)
import skysurvey

survey = skysurvey.ZTF.from_logs() # need password.
import skysurvey
# lsst opsim files are large, this may take a few minutes (see options)
opsim_path = "baseline_v3.3_10yrs.db" # provide fullpath
survey = skysurvey.LSST.from_opsim(opsim_path)

Survey uses healpy as backend to match position with observing history, while GridSurvey uses shapely and geopandas. Yet, both can be used equally in any skysurvey input ; especially for DataSet.

There are several surveys already implemented, such as ZTF and DES (shallow and deep fields).

Step 3: dataset#

and get lightcurve data

as you would observe them i.e., the dataset. The simulated lightcurves are in dset.data, the input survey is stored in dset.survey, the input targets is stored in dset.targets.

import skysurvey
dset = skysurvey.DataSet.from_targets_and_survey(snia, survey)
dset.data
import skysurvey
dset = skysurvey.DataSet.from_targets_and_survey(snia, survey,
                                                 incl_error=False)
dset.data
import skysurvey
targets = skysurvey.TargetCollection([snia, snii])
dset = skysurvey.DataSet.from_targets_and_survey(targets, survey)
dset.data
_images/lc_example.png

Tutorials#

API documentation