Skip to content

Commit

Permalink
better fitting for glocal detrending
Browse files Browse the repository at this point in the history
  • Loading branch information
cate-to committed Jan 28, 2025
1 parent 4bad11c commit 2147421
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion agrolib/mathFunctions/furtherMathFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,14 @@ namespace interpolation
std::vector <double> R2Previous(nrMinima,NODATA);
std::vector<double> ySim(nrData);

double maxZ = x.front();
for (int k = 0; k < x.size(); k++)
{
if (x[k] > maxZ) maxZ = x[k]; //look for max elevation station
}

bool isValid = 1;

//grigliato
for (int k = 0; k < int(firstGuessCombinations.size()); k++)
{
Expand All @@ -1396,7 +1404,10 @@ namespace interpolation
RMSEindex = k;
}

if (isEqual(bestR2, NODATA) || R2 > (bestR2 + deltaR2))
if (parameters.size() > 4)
isValid = ((parameters[0] + parameters[2]) < maxZ); //double inversion only: check whether second inversion point is above last available station

if (isEqual(bestR2, NODATA) || (R2 > (bestR2 + deltaR2) && isValid))
{
for (j=0; j<nrParameters; j++)
{
Expand Down

0 comments on commit 2147421

Please sign in to comment.