In [1]:
from copy import deepcopy
import os
import numpy as np
import sncosmo
In [11]:
%matplotlib inline
import matplotlib.pyplot as plt
In [2]:
from LSSTmetrics import PerSNMetric
import gedankenLSST
In [3]:
from lsst.sims.photUtils import BandpassDict
In [4]:
lsst_bp = BandpassDict.loadTotalBandpassesFromFiles()
In [5]:
dailyCadence = deepcopy(gedankenLSST.LSSTReq)
In [6]:
# sncosmo Bandpasses required for fitting
throughputsdir = os.getenv('THROUGHPUTS_DIR')
from astropy.units import Unit
bandPassList = ['u', 'g', 'r', 'i', 'z', 'y']
banddir = os.path.join(os.getenv('THROUGHPUTS_DIR'), 'baseline')
for band in bandPassList:
# setup sncosmo bandpasses
bandfname = banddir + "/total_" + band + '.dat'
# register the LSST bands to the SNCosmo registry
# Not needed for LSST, but useful to compare independent codes
# Usually the next two lines can be merged,
# but there is an astropy bug currently which affects only OSX.
numpyband = np.loadtxt(bandfname)
print band
sncosmoband = sncosmo.Bandpass(wave=numpyband[:, 0],
trans=numpyband[:, 1],
wave_unit=Unit('nm'),
name=band)
sncosmo.registry.register(sncosmoband, force=True)
In [7]:
#Now create a set of observations at a particular ra, dec within a a time window
observations = gedankenLSST.GSN_Obs(mjd_center=49570.,
lsstrequirements=dailyCadence,
ra=58., dec=-27.,
timeWindow=[-30., 50.])
In [20]:
observations.summary
Out[20]:
In [21]:
q = PerSNMetric(summarydf=observations.summary, t0=49570, raCol='ra', decCol='dec', lsst_bp=lsst_bp)
In [22]:
print q.SN
In [29]:
xx = q.lightcurve.copy()
In [36]:
xx['mag'] = -2.5 * np.log10(xx.flux)
In [41]:
q.lcplot()
Out[41]:
In [40]:
xx
Out[40]:
In [34]:
xx.groupby('band').get_group('r')
Out[34]:
In [ ]:
import opsimsummary as oss
In [ ]:
print(dir(oss))
In [ ]:
q.SN.SNstate
In [ ]:
model = sncosmo.Model(source='salt2')
In [ ]:
model.set(**q.SN.sncosmoParamDict(q.SN.SNstate, model))
In [ ]:
snState = deepcopy(q.SN.SNstate)
In [ ]:
model.set(z=0.7)
model.set_source_peakabsmag(-19.5, 'bessellB', 'ab')
In [ ]:
snState['z'] = model.get('z')
In [ ]:
snState['x0'] = model.get('x0')
In [ ]:
print snState
In [ ]:
newQM = PerSNMetric(summarydf=observations.summary, t0=49570, raCol='ra', decCol='dec', lsst_bp=lsst_bp, snState=snState)
In [ ]:
print newQM.snState
In [ ]:
In [ ]:
In [ ]: