EarthyScience / REddyProc

Processing data from micrometeorological Eddy-Covariance systems
58 stars 33 forks source link

Error in sEddyProc_sEstUstarThresholdDistribution with quantile vector of length one #15

Closed bgctw closed 6 years ago

bgctw commented 6 years ago

There is be a small bug that it throws error when arg probs is assigned only one numeric value. I hope you can replicate the problem with this command:

(uStarRes <- EddyProc.C$sEstUstarThresholdDistribution(
  nSample = 5L, probs = 0.5,
  ctrlUstarEst.l = usControlUstarEst(isUsingCPTSeveralT = TRUE)))

Error:

Error in `[<-`(`*tmp*`, iInvalid, , value = NA_real_) : 
  (subscript) logical subscript too long

Actually it works if I repeat the probability value:

(uStarRes <- EddyProc.C$sEstUstarThresholdDistribution(
  nSample = 5L, probs = c(0.5, 0.5),
  ctrlUstarEst.l = usControlUstarEst(isUsingCPTSeveralT = TRUE)))

Thank you for your feedback! It was really helpful.

bgctw commented 6 years ago

I can replicate the error.

Its a problem of apply function returning a vector instead of a matrix, because the quantile function returns a scalar instead of a vector for a single quantile.

The names generated by quantile are dropped too, sigh. We will probably need a workaround: extend a single value in the call to the quantile function in order to make sure the return value format is correct.