Skip to content

Commit

Permalink
Merge 5db4822 into b1bd69b
Browse files Browse the repository at this point in the history
  • Loading branch information
djones1040 committed May 21, 2021
2 parents b1bd69b + 5db4822 commit 546d2e4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sncosmo/models.py
Expand Up @@ -1100,6 +1100,7 @@ def __init__(self, modeldir=None,
# model covariance is interpolated to 1st order
for key in ['LCRV00', 'LCRV11', 'LCRV01']:
phase, wave, values = read_griddata_ascii(names_or_objs[key])
values *= self._SCALE_FACTOR**2.
self._model[key] = BicubicInterpolator(phase, wave, values)

# Set the colorlaw based on the "color correction" file.
Expand Down Expand Up @@ -1128,8 +1129,8 @@ def _bandflux_rvar_single(self, band, phase):
m0 = self._model['M0'](phase, wave)
m1 = self._model['M1'](phase, wave)
tmp = trans * wave
f0 = np.sum(m0 * tmp, axis=1) * dwave / HC_ERG_AA
m1int = np.sum(m1 * tmp, axis=1) * dwave / HC_ERG_AA
f0 = np.sum(m0 * tmp, axis=1)/tmp.sum()
m1int = np.sum(m1 * tmp, axis=1)/tmp.sum()
ftot = f0 + x1 * m1int

# In the following, the "[:,0]" reduces from a 2-d array of shape
Expand All @@ -1138,7 +1139,7 @@ def _bandflux_rvar_single(self, band, phase):
lcrv11 = self._model['LCRV11'](phase, band.wave_eff)[:, 0]
lcrv01 = self._model['LCRV01'](phase, band.wave_eff)[:, 0]

v = lcrv00 + 2.0 * x1 * lcrv01 + x1 * x1 * lcrv11
v = (lcrv00 + 2.0 * x1 * lcrv01 + x1 * x1 * lcrv11)

# v is supposed to be variance but can go negative
# due to interpolation. Correct negative values to some small
Expand All @@ -1149,11 +1150,10 @@ def _bandflux_rvar_single(self, band, phase):
# avoid warnings due to evaluating 0. / 0. in f0 / ftot
with np.errstate(invalid='ignore'):
# new SALT3 error prescription
result = v/(ftot/(trans*wave*dwave).sum())/HC_ERG_AA/1e12
result = v/ftot**2.

# treat cases where ftot is negative the same as snfit
result[ftot <= 0.0] = 10000.

return result


Expand Down

0 comments on commit 546d2e4

Please sign in to comment.