Skip to content

Commit 1fd14a0

Browse files
Consider None and NaNs in growth rate initial values
NaNs can appear with non-linear calibrations when the backscatter is below the lower limit just by chance.
1 parent ac1d8e5 commit 1fd14a0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bletl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
from . splines import get_crossvalidated_spline
1414

1515

16-
__version__ = '1.0.0'
16+
__version__ = '1.0.1'

bletl/growth.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ def _make_random_walk(name:str, *, sigma:float, nu: float=1, length:int, student
172172
if student_t:
173173
# a random walk of length N is just the cumulative sum over a N-dimensional random variable:
174174
return pymc3.Deterministic(name, tt.cumsum(
175-
pymc3.StudentT(f'{name}__diff_', mu=0, sd=sigma, nu=5, shape=(length,), testval=numpy.diff(initval, prepend=0))
175+
pymc3.StudentT(
176+
f'{name}__diff_',
177+
mu=0, sd=sigma, nu=5,
178+
shape=(length,),
179+
testval=numpy.diff(initval, prepend=0) if initval is not None else initval
180+
)
176181
))
177182
else:
178183
return pymc3.GaussianRandomWalk(name, mu=0, sigma=sigma, shape=(length,), testval=initval)
@@ -213,6 +218,9 @@ def _get_smoothed_mu(t: numpy.ndarray, y: numpy.ndarray, cm_cdw: calibr8.Calibra
213218

214219
# smooth again to reduce peaking
215220
mu = numpy.convolve(mu, numpy.ones(5)/5, "same")
221+
222+
# Replace NaNs that can show up with non-linear calibration models
223+
mu[numpy.isnan(mu)] = 0
216224
return mu
217225

218226

0 commit comments

Comments
 (0)