It seems that if an SNCosmo Model is initialized with Milky Way extinction (even if it is set to zero), and an SDSS bandpass is specified, that model.bandmag() and model.color() will return the exception:
Buffer dtype mismatch, expected 'double' but got 'long'
This is demonstrated below.
In [1]:
import numpy as np
import matplotlib.pyplot as plt
import sncosmo
import simulate_lsst as sl
%matplotlib inline
Following the example given in the documentation regarding adding dust to supernova models, I'll initialize an instance of the Model class with host extinction, but no MW extinction. Default values for the parameters are used.
In [2]:
dust = sncosmo.CCM89Dust()
model_no_mw = sncosmo.Model(source='hsiao',
effects=[dust],
effect_names=['host'],
effect_frames=['rest'])
# waves = np.arange(200.,1000.,10.0)
#model_no_mw.set(z=1.0, t0=0.0, amplitude=1.e-10)
#model_no_mw.set(z=1.0, t0=0.0, x1=1.0, c=.1, hostebv=0.0)
#model_no_mw.set_source_peakabsmag(-19.0, 'bessellb', 'ab')
print model_no_mw
In [3]:
model_no_mw.bandflux('desi', time=[.1, .5, 1.])
Out[3]:
In [4]:
model_no_mw.bandflux('sdssi', time=[.1, .5, 1.])
Out[4]:
In [5]:
model_no_mw.color('desi', 'desr', time=[.1, .5, 1.], magsys='ab')
Out[5]:
In [6]:
model_no_mw.color('sdssi', 'sdssr', time=[.1, .5, 1.], magsys='ab')
Out[6]:
Things seem okay; bandflux() and color() return reasonable values for both SDSS and DES.
Now, I'll initialize another model that is identical, except for the addition of the MW dust parameter.
In [7]:
model_mw_ext = sncosmo.Model(source='hsiao',
effects=[dust, dust],
effect_names=['host', 'mw'],
effect_frames=['rest', 'obs'])
# waves = np.arange(200.,1000.,10.0)
#model_mw_ext.set(z=1.0, t0=0.0, x1=1.0, c=.1, mwebv=0.05)
#model_mw_ext.set_source_peakabsmag(-19.0, 'bessellb', 'ab')
#model_mw_ext.set(z=.5, t0=0.0, amplitude=1.e-10)
print model_mw_ext
In [8]:
model_mw_ext.bandflux('desi', time=[.1, .5, 1.])
Out[8]:
In [9]:
model_mw_ext.bandflux('sdssi', time=[.1, .5, 1.])
In [10]:
model_mw_ext.color('desi', 'desr', time=[.1, .5, 1.], magsys='ab')
Out[10]:
In [11]:
model_mw_ext.color('sdssi', 'sdssr', time=[.1, .5, 1.], magsys='ab')
This also errors even if mwebv=0.0.
In [12]:
model_mw_ext.set(mwebv=0.0)
print model_mw_ext
In [13]:
model_mw_ext.bandflux('sdssi', time=[.1, .5, 1.])
In [14]:
model_mw_ext.color('sdssi', 'sdssr', time=[.1, .5, 1.], magsys='ab')
In [15]:
bpdesi = sncosmo.get_bandpass('desi')
In [16]:
bpdesi.wave.dtype
Out[16]:
In [17]:
bpi = sncosmo.get_bandpass('sdssi')
In [18]:
bpi.wave.dtype
Out[18]:
So DES and SDSS have different datatypes for the wave attribute. If we instead give bandflux() a modified sdssi, where the values in the wave array has been converted to floats, then we see that the aforementioned functions no longer error in this way.
In [19]:
sdssi =sncosmo.Bandpass(map(float, bpi.wave), bpi.trans)
In [20]:
model_mw_ext.bandflux(sdssi, time=[.1, .5, 1.])
Out[20]:
In [21]:
bpr = sncosmo.get_bandpass('sdssr')
sdssr =sncosmo.Bandpass(map(float, bpr.wave), bpr.trans)
In [22]:
model_mw_ext.color(sdssi, sdssr, time=[.1, .5, 1.], magsys='ab')
Out[22]:
In [ ]: