In [1]:
import os
home_dir = os.environ.get('HOME')
# Please enter the filename of the ztf_sim output file you would like to use. The example first determines
# your home directory and then uses a relative path (useful if working on several machines with different usernames)
survey_file = os.path.join(home_dir, 'data/ZTF/test_schedule_v6.db')
# Please enter the path to where you have placed the Schlegel, Finkbeiner & Davis (1998) dust map files
# You can also set the environment variable SFD_DIR to this path (in that case the variable below should be None)
sfd98_dir = os.path.join(home_dir, 'data/sfd98')
In [2]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from astropy.cosmology import Planck15
import simsurvey
import sncosmo
import simsurvey_tools as sst
In [3]:
# Load the ZTF CCD corners and filters
ccds = sst.load_ztf_ccds()
sst.load_ztf_filters()
In [4]:
# Load simulated survey from file (download from ftp://ftp.astro.caltech.edu/users/ebellm/one_year_sim_incomplete.db)
plan = simsurvey.SurveyPlan(load_opsim=survey_file, band_dict={'g': 'ztfg', 'r': 'ztfr', 'i': 'desi'}, ccds=ccds)
mjd_range = (plan.cadence['time'].min() - 30, plan.cadence['time'].max() + 30)
In [5]:
# The expanding black body model takes arguments that define the evolution of the transient (functions + parameters).
# This example is the black body fit to GW170817 from Kasliwal et al. (2017).
tr_prop = {
'lcmodel_prop': dict(
minphase=0.1,
maxphase=15.,
tempfunc=(lambda p, x: p[0] * x**p[1]),
tempparam=[6050, -0.62],
radiusfunc=(lambda p, x: p[0]*(1-np.exp(-p[1]*x)) + p[2]*x),
radiusparam=[24000, 0.42, 2500]
)
}
tr = simsurvey.get_transient_generator((0., 0.05),
ratefunc=lambda z: 5e-5,
transient='generic',
template='ExpandingBlackBody',
dec_range=(-30,90),
mjd_range=(mjd_range[0],
mjd_range[1]),
sfd98_dir=sfd98_dir,
transientprop=tr_prop)
In [6]:
survey = simsurvey.SimulSurvey(generator=tr, plan=plan)
lcs = survey.get_lightcurves(
#progress_bar=True, notebook=True # If you get an error because of the progress_bar, delete this line.
)
In [7]:
print len(lcs.lcs)
In [8]:
lcs[0]
Out[8]:
In [ ]: