obrl-soil / mpspline2

A revamped mass-preserving spline function for soils data
6 stars 2 forks source link

1cm indexing behaviour #5

Open obrl-soil opened 5 years ago

obrl-soil commented 5 years ago

So GSIF::mpspline() and ithir::ea_spline() both iterate over 1:n when making 1cm spline predictions, so that 1 = 0-1cm. mpspline2 and splinetool.exe iterate over 0:n-1, so that 0 = 0-1cm. The index, as k, is fed into the 1cm fit equations - see lines 246-285 of mpspline and lines 193-207 of ea_spline.

I changed my indexing to match splinetool.exe's outputs on purpose, but now I'm having second thoughts. Not sure which approach is actually correct. With 0-indexing, the 0-1cm prediction

alfa[h] + b0[h] * (k - s[[2]][h]) + gamma[h] * (k - s[[2]][h])^2

simplifies out to alfa(h1) + gamma(h1) as k and s[[2]]h are both 0. Not sure if that's a problem.