WSL/SLF GitLab Repository

Commit 17fd45fc authored by Adrien Michel's avatar Adrien Michel
Browse files

Changes snow melt correction

parent ea30f3e6
......@@ -149,24 +149,22 @@ NumericVector applyQMCpp(const Rcpp::NumericMatrix swe,
for(size_t d = 0; d < doyArray_cpp.size(); ++d) {
const size_t doy(doyArray_cpp[d]-1);
double& target = swe_cpp[p+(d)*num_pixels];
if(target==0)
auto lower = std::upper_bound(sourcePDF[doy].begin(), sourcePDF[doy].end(), target);
size_t quantile = std::distance(sourcePDF[doy].begin(),lower);
//Apply the -1 correction and lower bound
// Here quantiles are 0...100, in R 1...101
quantile = (quantile <= 1) ? 1 : quantile - 1;
quantile = (quantile >= (sourcePDF[doy].size() - 1)) ? sourcePDF[doy].size() - 2 : quantile;
if(sourcePDF[doy][quantile]==0 && targetPDF[doy][quantile]>0)
{
if(d>0){
target = swe_cpp[p+(d-1)*num_pixels]/2;
}
target = d>0 ? swe_cpp[p+(d-1)*num_pixels]/2 : 0;
}
if(target>0){
auto lower = std::upper_bound(sourcePDF[doy].begin(), sourcePDF[doy].end(), target);
size_t quantile = std::distance(sourcePDF[doy].begin(),lower);
//Apply the -1 correction and lower bound
// Here quantiles are 0...100, in R 1...101
quantile = (quantile <= 1) ? 1 : quantile - 1;
quantile = (quantile >= (sourcePDF[doy].size() - 1)) ? sourcePDF[doy].size() - 2 : quantile;
else{
target += targetPDF[doy][quantile] - sourcePDF[doy][quantile];
if(target < 0.0005) {
target = 0;
}
}
// Set a lower limit on SWE
target = target > 0.0005 ? target : 0;
}
}
if (interrupt) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment