diff --git a/agrolib/inOutDataXML/inOutDataXML.cpp b/agrolib/inOutDataXML/inOutDataXML.cpp index 2e7fd4278..6e84a378c 100644 --- a/agrolib/inOutDataXML/inOutDataXML.cpp +++ b/agrolib/inOutDataXML/inOutDataXML.cpp @@ -83,9 +83,13 @@ bool InOutDataXML::parserXML(QString *myError) { fileName_pragaName = secondChild.toElement().text(); } - else if (mySecondTag == "TEXT" || mySecondTag == "FIXEDTEXT") + else if (mySecondTag == "PREFIX" || mySecondTag == "FIXEDPREFIX") { - fileName_fixedText.append(secondChild.toElement().text()); + fileName_fixedPrefix.append(secondChild.toElement().text()); + } + else if (mySecondTag == "SUFFIX" || mySecondTag == "FIXEDSUFFIX") + { + fileName_fixedSuffix.append(secondChild.toElement().text()); } else if (mySecondTag == "NRCHAR" || mySecondTag == "NR_CHAR") { @@ -1141,11 +1145,32 @@ QString InOutDataXML::parseXMLPointCode(QString text) { if (format_type == XMLFORMATFIXED || (format_type == XMLFORMATDELIMITED && pointCode.getType().toUpper() == "FILENAMEDEFINED")) { - QString substring = text.mid(0,pointCode.getNrChar()); - if (pointCode.getFormat().isEmpty() || pointCode.getFormat() == "%s") + if (fileName_pragaName.isEmpty()) + { + QString substring = text.mid(0,pointCode.getNrChar()); + if (pointCode.getFormat().isEmpty() || pointCode.getFormat() == "%s") + { + // pointCode is a string + myPointCode = substring; + } + } + else { - // pointCode is a string - myPointCode = substring; + // con questa casistica l'import funziona anche con gli xml di export che hanno il campo filename e prefissi o suffissi nel nome del file + QString substring = text; + for (int i = 0; i fileName_fixedText; + QList fileName_fixedPrefix; + QList fileName_fixedSuffix; int fileName_nrChar; FieldXML time; FieldXML pointCode; diff --git a/agrolib/interpolation/interpolation.cpp b/agrolib/interpolation/interpolation.cpp index 521c35b7b..adc3b649d 100644 --- a/agrolib/interpolation/interpolation.cpp +++ b/agrolib/interpolation/interpolation.cpp @@ -28,11 +28,6 @@ #include #include -/*#include -#include -#include -*/ - #include "commonConstants.h" #include "basicMath.h" #include "furtherMathFunctions.h" @@ -1517,25 +1512,10 @@ bool multipleDetrending(std::vector &myPoints, Cr std::vector&)>> myFunc; setFittingParameters(myCombination, mySettings, myFunc, parametersMin, parametersMax, parametersDelta, parameters); - //auto start2 = std::chrono::high_resolution_clock::now(); - // multiple non linear fitting - /*interpolation::bestFittingMarquardt_nDimension(&functionSum, myFunc, 4, 3, parametersMin, parametersMax, parameters, parametersDelta, - 20, 0.05, 0.02, predictors, predictands, false, weights);*/ - interpolation::bestFittingMarquardt_nDimension(&functionSum, myFunc, 500, 5, parametersMin, parametersMax, parameters, parametersDelta, 100, 0.005, 0.01, predictors, predictands, false, weights); - /*auto end2 = std::chrono::high_resolution_clock::now(); - std::chrono::duration tempo2 = end2 - start2; - std::ofstream csvfile("C:/Github/tempoBestFit.csv", std::ios::app); - - if (!csvfile.is_open()) { - std::cerr << "Errore apertura file\n"; - } - csvfile << tempo2.count() << std::endl; - csvfile.close(); -*/ mySettings->setFittingFunction(myFunc); mySettings->setFittingParameters(parameters); diff --git a/agrolib/mathFunctions/furtherMathFunctions.cpp b/agrolib/mathFunctions/furtherMathFunctions.cpp index 825ca65f7..8f50d6b32 100644 --- a/agrolib/mathFunctions/furtherMathFunctions.cpp +++ b/agrolib/mathFunctions/furtherMathFunctions.cpp @@ -32,9 +32,6 @@ #include "commonConstants.h" #include "furtherMathFunctions.h" -#include -#include -#include double lapseRateRotatedSigmoid(double x, std::vector par) { @@ -1094,7 +1091,7 @@ namespace interpolation R2 = computeR2(y,ySim); else R2 = computeWeighted_R2(y,ySim,weights); - //printf("%d R2 = %f\n",iRandom,R2); + if (R2 > (bestR2-deltaR2)) { for (j=0;j deltaR2) ); -/* std::ofstream csvfile("C:/Github/counterR2.csv", std::ios::app); - - if (!csvfile.is_open()) { - std::cerr << "Errore apertura file\n"; - } - csvfile << counter << "," << R2 << std::endl; - csvfile.close(); -*/ for (i=0;i= 0; i--) { diff --git a/agrolib/meteoWidget/meteoWidget.cpp b/agrolib/meteoWidget/meteoWidget.cpp index 78daab9df..65cdc479f 100644 --- a/agrolib/meteoWidget/meteoWidget.cpp +++ b/agrolib/meteoWidget/meteoWidget.cpp @@ -625,8 +625,6 @@ void Crit3DMeteoWidget::resetValues() { QLineSeries* line = new QLineSeries(); line->setName(getFormattedLabel(pointName, nameLines[i])); - - //QColor lineColor = colorLine[i]; QColor lineColor = colorLines[i]; if (nMeteoPoints == 1) { @@ -2312,16 +2310,60 @@ void Crit3DMeteoWidget::on_actionDataAvailability() void Crit3DMeteoWidget::on_actionDataSum() { - // TO DO; - // Apre una finestra con l'elenco delle variabili attualmente visualizzate in modo che siano selezionabili quali vogliamo switchare sulla comulata DialogVariableToSum varToSum(currentVariables); QList varToSumList; if (varToSum.result() == QDialog::Accepted) { varToSumList = varToSum.getSelectedVariable(); } - qDebug() << "varToSumList " << varToSumList.join(","); + else + { + return; + } + if (!varToSumList.isEmpty()) + { + drawSum(varToSumList); + } +} +void Crit3DMeteoWidget::drawSum(QList varToSumList) +{ + // TO DO + int nMeteoPoints = meteoPoints.size(); + for (int i = 0; i < varToSumList.size(); i++) + { + qDebug() << "varToSumList: " << varToSumList[i]; + if (!lineSeries.isEmpty()) + { + for (int j = 0; j < nameLines.size(); j++) + { + qDebug() << "nameLines[j]: " << nameLines[j]; + if (nameLines[j] == varToSumList[i]) + { + qDebug() << "found: " << varToSumList[i]; + for (int mp=0; mppoints().size(); n++) + { + qDebug() << "lineSeries[mp][j]->points()[n].x(): " << lineSeries[mp][j]->points()[n].x(); + qDebug() << "lineSeries[mp][j]->points()[n].y(): " << lineSeries[mp][j]->points()[n].y(); + } + } + } + } + } + if (! barSeries.isEmpty()) + { + for (int j = 0; j < nameBar.size(); j++) + { + qDebug() << "nameBar[j]: " << nameBar[j]; + if (nameBar[j] == varToSumList[i]) + { + qDebug() << "found: " << varToSumList[i]; + } + } + } + } } diff --git a/agrolib/meteoWidget/meteoWidget.h b/agrolib/meteoWidget/meteoWidget.h index 3d5a9da26..497df9b31 100644 --- a/agrolib/meteoWidget/meteoWidget.h +++ b/agrolib/meteoWidget/meteoWidget.h @@ -58,6 +58,7 @@ void on_actionInfoPoint(); void on_actionDataAvailability(); void on_actionDataSum(); + void drawSum(QList varToSumList); private: int meteoWidgetID; diff --git a/agrolib/pragaProject/pragaProject.cpp b/agrolib/pragaProject/pragaProject.cpp index 0fd21c632..615caa07d 100644 --- a/agrolib/pragaProject/pragaProject.cpp +++ b/agrolib/pragaProject/pragaProject.cpp @@ -2438,6 +2438,7 @@ bool PragaProject::interpolationMeteoGrid(meteoVariable myVar, frequencyType myF } else { + if (! interpolationGrid(myVar, myTime)) return false; } diff --git a/agrolib/project/project.cpp b/agrolib/project/project.cpp index 484e8e626..74bb1f1af 100644 --- a/agrolib/project/project.cpp +++ b/agrolib/project/project.cpp @@ -23,9 +23,6 @@ #include #include -/*#include -#include -*/ Project::Project() { @@ -2309,7 +2306,6 @@ bool Project::interpolationDemLocalDetrending(meteoVariable myVar, const Crit3DT float z = DEM.value[row][col]; if (! isEqual(z, myHeader.flag)) { - //auto start1 = std::chrono::high_resolution_clock::now(); gis::getUtmXYFromRowCol(myHeader, row, col, &x, &y); std::vector subsetInterpolationPoints; @@ -2318,16 +2314,6 @@ bool Project::interpolationDemLocalDetrending(meteoVariable myVar, const Crit3DT getProxyValuesXY(x, y, &interpolationSettings, proxyValues); myRaster->value[row][col] = interpolate(subsetInterpolationPoints, &interpolationSettings, meteoSettings, myVar, x, y, z, proxyValues, true); - - /*auto end1 = std::chrono::high_resolution_clock::now(); - std::chrono::duration tempo1 = end1 - start1; - std::ofstream csvfile("C:/Github/rowCol.csv", std::ios::app); - - if (!csvfile.is_open()) { - std::cerr << "Errore apertura file\n"; - } - csvfile << row << "," << col << "," << tempo1.count() << std::endl; - csvfile.close();*/ } } } @@ -2598,6 +2584,10 @@ bool Project::interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime) if (interpolationSettings.getUseLocalDetrending()) { + if (row == 80 && col == 67) + { + std::cout << "cella individuata" << std::endl; + } std::vector subsetInterpolationPoints; localSelection(interpolationPoints, subsetInterpolationPoints, myX, myY, interpolationSettings); preInterpolation(subsetInterpolationPoints, &interpolationSettings, meteoSettings, &climateParameters, meteoPoints, nrMeteoPoints, myVar, myTime); @@ -2606,6 +2596,7 @@ bool Project::interpolationGrid(meteoVariable myVar, const Crit3DTime& myTime) if (interpolatedValue > 9000) { std::cout << "valore sballato" << std::endl; + std::cout << "riga " << row << " colonna " << col << std::endl; } } else