Simulating lightcurves using an expanding black body model


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.
)


/home/ufeindt/anaconda2/envs/simsurvey-dev/lib/python2.7/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in double_scalars

In [7]:
print len(lcs.lcs)


25

In [8]:
lcs[0]


Out[8]:
<Table length=61>
timebandfluxfluxerrzpzpsysfieldccdcomment
float64str4float64float64int64str2int64int64unicode7
57638.49337179176ztfg355.32161087553584528.257861186867130ab7815all_sky
57638.50834715247ztfr496.6356884816409585.668937381148930ab7815all_sky
57639.49319883449ztfg-1112.7071252858323540.8884820250430ab7815all_sky
57639.517170348794ztfr221.48953614664978569.185634243840830ab7815all_sky
57643.49337246782ztfg608.910422918301518.608650195621430ab7815all_sky
57647.48978592098ztfr-1300.77605796609671188.46345002381330ab7815all_sky
57647.49024888394ztfr2258.4176245559491188.46345002381330ab7815all_sky
57647.51940756444ztfg442.12984942724836933.990634460798630ab7815all_sky
57648.451528856065ztfr173.891087380027781312.861889300339530ab7815all_sky
57648.47325177754ztfr-171.9277807960561202.101159501611830ab7815all_sky
...........................
57661.487685212844ztfr-431.5411916847549457.1770312002181530ab7815all_sky
57661.51321976452ztfg-17.465872295173572446.454039064052930ab7815all_sky
57662.45303431503ztfr218.72622480657733514.857686437242530ab7815all_sky
57662.48860440247ztfr298.7950641112394453.344450467359130ab7815all_sky
57662.48958709119ztfr815.2006577100309453.3444500663188730ab7815all_sky
57662.511167906334ztfg-51.96389214686333444.2833133857764730ab7815all_sky
57663.47080696784ztfg-586.5353604412023479.049324709260730ab7815all_sky
57663.49141153485ztfr-198.64342351845895450.806667536370630ab7815all_sky
57663.49234626219ztfr1.1121113150068207450.806667362535230ab7815all_sky
57663.51181453953ztfr-292.6608887183434449.9090376019330530ab7815all_sky

In [ ]: