Skip to content

Commit

Permalink
Merge commit 'ed625d62f777b0b2feed8f49328eb69a220535cf'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Sep 12, 2024
2 parents 5b5fcf2 + ed625d6 commit 5030a32
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
6 changes: 4 additions & 2 deletions agrolib/interpolation/interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,11 +1458,13 @@ bool proxyValidityWeighted(std::vector <Crit3DInterpolationDataPoint> &myPoints,
return true;
}

bool setHeightTemperatureRange(Crit3DProxyCombination myCombination, Crit3DInterpolationSettings* mySettings)
bool setMultipleDetrendingHeightTemperatureRange(Crit3DInterpolationSettings* mySettings)
{
if (mySettings->getPointsRange().empty() || !mySettings->getUseMultipleDetrending())
return 0;

Crit3DProxyCombination myCombination = mySettings->getSelectedCombination();

for (unsigned i=0; i < myCombination.getProxySize(); i++)
if (myCombination.isProxyActive(i) == true)
{
Expand Down Expand Up @@ -2155,7 +2157,7 @@ bool preInterpolation(std::vector <Crit3DInterpolationDataPoint> &myPoints, Crit
if (mySettings->getUseMultipleDetrending())
{
if (!mySettings->getUseLocalDetrending())
setHeightTemperatureRange(mySettings->getSelectedCombination(), mySettings);
setMultipleDetrendingHeightTemperatureRange(mySettings);

if (! multipleDetrendingMain(myPoints, mySettings, myVar, errorStr)) return false;
}
Expand Down
2 changes: 1 addition & 1 deletion agrolib/interpolation/interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
bool proxyValidityWeighted(std::vector <Crit3DInterpolationDataPoint> &myPoints, int proxyPos,
float stdDevThreshold);

bool setHeightTemperatureRange(Crit3DProxyCombination myCombination, Crit3DInterpolationSettings* mySettings);
bool setMultipleDetrendingHeightTemperatureRange(Crit3DInterpolationSettings* mySettings);

void calculateFirstGuessCombinations(Crit3DProxy* myProxy);

Expand Down
2 changes: 1 addition & 1 deletion agrolib/meteo/meteo.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
snowWaterEquivalent, snowFall, snowSurfaceTemperature, snowInternalEnergy, snowSurfaceEnergy,
snowAge, snowLiquidWaterContent, snowMelt, sensibleHeat, latentHeat,
dailyWaterTableDepth, leafAreaIndex,
anomaly, elaboration, noMeteoTerrain,
anomaly, elaboration, cvResidual, noMeteoTerrain,
noMeteoVar};


Expand Down
20 changes: 12 additions & 8 deletions agrolib/project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,12 @@ bool Project::interpolationCv(meteoVariable myVar, const Crit3DTime& myTime, cro
}
else
{
if(!setMultipleDetrendingHeightTemperatureRange(&interpolationSettings))
{
errorString = "Error in function preInterpolation: \n couldn't set temperature ranges for height proxy.";
return false;
}

if (! computeResidualsLocalDetrending(myVar, myTime, meteoPoints, nrMeteoPoints, interpolationPoints,
&interpolationSettings, meteoSettings, &climateParameters, true, true))
return false;
Expand Down Expand Up @@ -2417,7 +2423,7 @@ bool Project::interpolationDemLocalDetrending(meteoVariable myVar, const Crit3DT
gis::Crit3DRasterHeader myHeader = *(DEM.header);
myRaster->initializeGrid(myHeader);

if(!setHeightTemperatureRange(myCombination, &interpolationSettings))
if(!setMultipleDetrendingHeightTemperatureRange(&interpolationSettings))
{
errorString = "Error in function preInterpolation: \n couldn't set temperature ranges for height proxy.";
return false;
Expand Down Expand Up @@ -2681,6 +2687,11 @@ bool Project::interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime)
{
myCombination = interpolationSettings.getSelectedCombination();
interpolationSettings.setCurrentCombination(myCombination);
if(!setMultipleDetrendingHeightTemperatureRange(&interpolationSettings))
{
errorString = "Error in function preInterpolation: \n couldn't set temperature ranges for height proxy.";
return false;
}
}

// proxy aggregation
Expand All @@ -2694,13 +2705,6 @@ bool Project::interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime)
std::vector <double> proxyValues;
proxyValues.resize(unsigned(interpolationSettings.getProxyNr()));

if (interpolationSettings.getUseLocalDetrending())
if(!setHeightTemperatureRange(myCombination, &interpolationSettings))
{
errorString = "Error in function preInterpolation: \n couldn't set temperature ranges for height proxy.";
return false;
}

float interpolatedValue = NODATA;
unsigned int i, proxyIndex;

Expand Down
2 changes: 1 addition & 1 deletion agrolib/proxyWidget/localProxyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void Crit3DLocalProxyWidget::modelLRClicked(int toggled)
if (comboAxisX.currentText() == "elevation")
{
std::string errorStr;
setHeightTemperatureRange(interpolationSettings->getSelectedCombination(), interpolationSettings);
setMultipleDetrendingHeightTemperatureRange(interpolationSettings);
interpolationSettings->setCurrentCombination(interpolationSettings->getSelectedCombination());
interpolationSettings->clearFitting();
if (! multipleDetrendingElevationFitting(proxyPos, subsetInterpolationPoints, interpolationSettings, myVar, errorStr)) return;
Expand Down
2 changes: 1 addition & 1 deletion agrolib/proxyWidget/proxyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void Crit3DProxyWidget::modelLRClicked(int toggled)
{
std::string errorStr;

setHeightTemperatureRange(interpolationSettings->getSelectedCombination(), interpolationSettings);
setMultipleDetrendingHeightTemperatureRange(interpolationSettings);
interpolationSettings->setCurrentCombination(interpolationSettings->getSelectedCombination());
interpolationSettings->clearFitting();
if (! multipleDetrendingElevationFitting(proxyPos, outInterpolationPoints, interpolationSettings, myVar, errorStr)) return;
Expand Down

0 comments on commit 5030a32

Please sign in to comment.