In [1]:
%load_ext autoreload
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sncosmo
In [2]:
import os
from copy import deepcopy
In [3]:
import gedankenLSST
import numpy as np
import pandas as pd
In [4]:
from LSSTmetrics import PerSNMetric
In [5]:
import LSSTmetrics
In [6]:
LSSTmetrics.__file__
Out[6]:
In [7]:
LSSTmetrics.__version__
Out[7]:
In [8]:
from lsst.sims.photUtils import BandpassDict
In [9]:
lsst_bp = BandpassDict.loadTotalBandpassesFromFiles()
In [10]:
# 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 [21]:
SVDCadence = deepcopy(gedankenLSST.LSSTReq)
In [23]:
# This is a dictionary with the following keys
SVDCadence.keys()
Out[23]:
In [24]:
SVDCadence['Duration']
Out[24]:
In [25]:
SVDCadence['bF']
Out[25]:
In [26]:
SVDCadence['meanNumVisits']
Out[26]:
In [27]:
SVDCadence['medianSVD']
Out[27]:
In [29]:
#Now create a set of observations at a particular ra, dec within a a time window
SVD_obs = gedankenLSST.GSN_Obs(mjd_center=49570.,
lsstrequirements=SVDCadence,
ra=58., dec=-27.,
timeWindow=[-30., 50.])
In [36]:
SN_SVD = PerSNMetric(summarydf=SVD_obs.summary,t0=49570., raCol='ra', decCol='dec', lsst_bp=lsst_bp)
In [37]:
# What are the properties of the SN?
In [39]:
_ = SN_SVD.lcplot()
In [32]:
SN_SVD.SN.SNstate
Out[32]:
In [40]:
# Change the redshift
SN_SVD.redshiftSN(1.0)
In [41]:
SN_SVD.SN.SNstate
Out[41]:
In [42]:
SN_SVD.lcplot()
Out[42]:
In [50]:
snDaily.qualityMetric()
Out[50]:
Here we set up an example where the SN are measured at a daily cadence
In [43]:
dailyCadence = deepcopy(gedankenLSST.LSSTReq)
In [44]:
# This is a dictionary with the following keys
dailyCadence.keys()
Out[44]:
In [13]:
dailyCadence['Duration'] # Says the survey is 10 years
Out[13]:
In [14]:
dailyCadence['meanNumVisits'] # Gives the number of visits during the duration, (mean is over LSST fields)
Out[14]:
In [15]:
dailyCadence['bF'] # bumpFactors increase the cadence in filters by these factors
Out[15]:
In [16]:
dailyCadence['medianSVD'] # median single visit 5 sigma depth in LSST
Out[16]:
In [17]:
# Now, we will make the cadence a 'daily cadence' in each band
dailyCadence['meanNumVisits'] = pd.Series(np.repeat(3650.,6), index=['u','g','r','i','z','y'], copy=True)
In [18]:
dailyCadence['meanNumVisits']
Out[18]:
In [45]:
#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 [46]:
# This is a pandas.DataFrame which should look like columns of OpSim
observations.summary.head()
Out[46]:
In [47]:
snDaily = PerSNMetric(summarydf=observations.summary,t0=49570., raCol='ra', decCol='dec', lsst_bp=lsst_bp)
In [48]:
snDaily.SN.SNstate
Out[48]:
In [49]:
snDaily.lcplot()
Out[49]:
In [ ]:
snDaily.redshiftSN(1.0)
In [ ]:
snDaily.SN.SNstate
In [ ]:
snDaily.lcplot()
In [ ]:
from lsst.sims.catUtils.supernovae import SNObject
In [ ]:
snobj = SNObject.fromSNState(snstate)
In [ ]:
snstate
In [ ]:
In [ ]:
snobj.SNstate
In [ ]:
# Now we can look at a light curve (no scatter)
snDaily.lightcurve.head()
In [ ]:
# We can coadd the light curve in nights if necessary
snDaily.coaddedLightCurve.head()
In [ ]:
# We can get plots with scatter, and a seed. This can also have a nightly coadd
snDaily.lcplot(scattered=True, seed=0)
In [ ]:
# the same light curves in a format where we can easily fit
snDaily.SNCosmoLC()
In [ ]:
lsstCadence = deepcopy(gedankenLSST.LSSTReq)
In [ ]:
lsst_obs = gedankenLSST.GSN_Obs(mjd_center=49570.,
lsstrequirements=lsstCadence,
ra=58., dec=-27.,
timeWindow=[-30., 50.])
In [ ]:
lsstCadence
In [ ]:
snLSST = PerSNMetric(summarydf=lsst_obs.summary,t0=49570., raCol='ra', decCol='dec', lsst_bp=lsst_bp)
In [ ]:
snLSST.lcplot()
In [ ]:
snLSST.SNCosmoLC()
In [ ]:
thriceLsstCadence = deepcopy(gedankenLSST.LSSTReq)
In [ ]:
thriceLsstCadence['bF'] = 3
In [ ]:
lsst_Denseobs = gedankenLSST.GSN_Obs(mjd_center=49570.,
lsstrequirements=thriceLsstCadence,
ra=58., dec=-27.,
timeWindow=[-30., 50.])
In [ ]:
snLSSTdense = PerSNMetric(summarydf=lsst_Denseobs.summary,t0=49570., raCol='ra', decCol='dec', lsst_bp=lsst_bp)
In [ ]:
snLSSTdense.lcplot(scattered=True)
In [ ]:
df = sn.summary
In [ ]:
df['filter'].unique()
In [ ]:
df.columns
In [ ]:
df[df['filter'] == 'u'].hist('night',bins=80)
In [ ]:
s = gedankenLSST.SNObs(summarydf=df, t0=49530, lsst_bp=lsst_bp)
In [ ]:
np.degrees(0)
In [ ]:
s.radeg
In [ ]:
l = s.lightcurve
In [ ]:
type(l)
In [ ]:
l.query('SNR > 5.').night
In [ ]:
import sncosmo
In [ ]:
dir(sn)
In [ ]:
In [ ]:
In [ ]: