diff --git a/agrolib/weatherGenerator/weatherGenerator.cpp b/agrolib/weatherGenerator/weatherGenerator.cpp index 0328dde98..dcc8c6b30 100644 --- a/agrolib/weatherGenerator/weatherGenerator.cpp +++ b/agrolib/weatherGenerator/weatherGenerator.cpp @@ -1170,6 +1170,14 @@ bool computeSeasonalPredictions(TinputObsData *dailyObsData, TweatherGenClimate { outputDailyData[currentIndex].maxTemp = getTMax(myDoy, rainfallThreshold, wgClimate); outputDailyData[currentIndex].minTemp = getTMin(myDoy, rainfallThreshold, wgClimate); + if (outputDailyData[currentIndex].maxTemp < outputDailyData[currentIndex].minTemp) + { + float average,diff; + average = 0.5*(outputDailyData[currentIndex].maxTemp + outputDailyData[currentIndex].minTemp); + diff = outputDailyData[currentIndex].minTemp - outputDailyData[currentIndex].maxTemp; + outputDailyData[currentIndex].maxTemp = average + 0.5*diff; + outputDailyData[currentIndex].minTemp = average - 0.5*diff; + } outputDailyData[currentIndex].prec = getPrecip(myDoy, rainfallThreshold, wgClimate); indexWg.push_back(currentIndex); } diff --git a/agrolib/weatherGenerator2D/weatherGenerator2D.pro b/agrolib/weatherGenerator2D/weatherGenerator2D.pro index 869abf8f1..25c6e4b94 100644 --- a/agrolib/weatherGenerator2D/weatherGenerator2D.pro +++ b/agrolib/weatherGenerator2D/weatherGenerator2D.pro @@ -33,8 +33,10 @@ INCLUDEPATH += ../crit3dDate INCLUDEPATH += ../meteo INCLUDEPATH += ../gis INCLUDEPATH += ../crit3dDate +INCLUDEPATH += ../waterTable INCLUDEPATH += ../weatherGenerator + SOURCES += wg2D.cpp \ randomset.cpp \ wg2D_precipitation.cpp \ diff --git a/agrolib/weatherGenerator2D/wg2d.cpp b/agrolib/weatherGenerator2D/wg2d.cpp index 29bf0a011..97b2f458d 100644 --- a/agrolib/weatherGenerator2D/wg2d.cpp +++ b/agrolib/weatherGenerator2D/wg2d.cpp @@ -460,9 +460,9 @@ void weatherGenerator2D::computeMonthlyVariables() weibullDailyParameterLambda[i] = (double*)calloc(365,sizeof(double)); interpolatedDailyValuePrecAverage[i] = (float*)calloc(365,sizeof(float)); interpolatedDailyValuePrecVariance[i] = (float*)calloc(365,sizeof(float)); - cubicSplineYearInterpolate(monthlyAveragePrec[i],interpolatedDailyValuePrecAverage[i]); - cubicSplineYearInterpolate(monthlyStdDevPrec[i],interpolatedDailyValuePrecVariance[i]); - for (int j=0;j<365;j++) + interpolation::cubicSplineYearInterpolate(monthlyAveragePrec[i], interpolatedDailyValuePrecAverage[i]); + interpolation::cubicSplineYearInterpolate(monthlyStdDevPrec[i], interpolatedDailyValuePrecVariance[i]); + for (int j=0; j < 365; j++) { interpolatedDailyValuePrecVariance[i][j] *= interpolatedDailyValuePrecVariance[i][j]; }