diff --git a/.Rbuildignore b/.Rbuildignore index 63c4b7c..fb50e23 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,4 +6,5 @@ ^codecov\.yml$ ^README\.Rmd$ ^tests/testthat/test_gcalibrateC\.R$ -^man/figures \ No newline at end of file +^man/figures +.vscode/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7b732e7..ebb9f0a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .RData .Ruserdata .DS_Store +.vscode/ \ No newline at end of file diff --git a/src/gcalibrate.cpp b/src/gcalibrate.cpp index 9fe0942..60ce788 100644 --- a/src/gcalibrate.cpp +++ b/src/gcalibrate.cpp @@ -1,3 +1,4 @@ +// [[Rcpp::plugins(cpp11)]] #include #include #include @@ -91,7 +92,7 @@ Rcpp::List gcalibrateC(Rcpp::Nullable pathname = R_NilValue, Rcpp: } Rcpp::NumericVector ws {5, 900, 3600}; - int startpage, endpage, blocksize = 12 * ws(2), minloadcrit = 72; + int startpage, endpage, blocksize = 12 * ws(2), minloadcrit = 168; double NR = ceil((90*pow(10, 6)) / (sf*10)) + 1000; // NR = number of '10' second rows (this is for 10 days at 80 Hz) int count = 0; // counter to keep track of the number of seconds that have been read double spherecrit = 0.3, sdcriter = 0.013; @@ -162,7 +163,8 @@ Rcpp::List gcalibrateC(Rcpp::Nullable pathname = R_NilValue, Rcpp: if((use > 0) && (use != LD)){ S = data(Rcpp::Range(use, LD-1), Rcpp::_); } - data = data(Rcpp::Range(0, use-1), Rcpp::_); + + if(use != 0) data = data(Rcpp::Range(0, use-1), Rcpp::_); if(data.nrow() < blocksize * 30){ LD = 0; @@ -274,7 +276,9 @@ Rcpp::List gcalibrateC(Rcpp::Nullable pathname = R_NilValue, Rcpp: for(int i = 0; i < input.nrow(); i++){ for(int j = 0; j < input.ncol(); j++){ - closestpoint(i, j) = curr(i, j) / sqrt(rsum[i]); + if(curr(i, j) != 0){ + closestpoint(i, j) = curr(i, j) / sqrt(rsum[i]); + } } } @@ -311,6 +315,7 @@ Rcpp::List gcalibrateC(Rcpp::Nullable pathname = R_NilValue, Rcpp: if((calErrorEnd < calErrorStart) && (calErrorEnd < 0.01) && (nhoursused > minloadcrit)){ LD = 0; + Rcpp::Rcout << "Recalibration done, no problems detected"; } } i += 1; diff --git a/src/resample_helpers.cpp b/src/resample_helpers.cpp index 3914301..b48a8bf 100644 --- a/src/resample_helpers.cpp +++ b/src/resample_helpers.cpp @@ -1,3 +1,4 @@ +// [[Rcpp::plugins(cpp11)]] #include using namespace Rcpp;