Skip to content

Commit

Permalink
Merge commit '919ec2e8e91146c80cba2a48bda6c097254a65b1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jan 31, 2025
2 parents 7abf729 + 919ec2e commit 4e95a6a
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 10 deletions.
7 changes: 5 additions & 2 deletions agrolib/graphics/stationMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ void StationMarker::setToolTip()
QString name = QString::fromStdString(_name);
QString dataset = QString::fromStdString(_dataset);
QString altitude = QString::number(_altitude);
QString region = QString::fromStdString(_region);
QString province = QString::fromStdString(_province);
QString municipality = QString::fromStdString(_municipality);
QString lapseRateName = QString::fromStdString(getLapseRateCodeName(_lapseRateCode));

QString toolTipText = QString("Point: <b> %1 </b> <br/> ID: %2 <br/> dataset: %3 <br/> altitude: %4 m <br/> municipality: %5 <br/> lapse rate code: %6")
.arg(name, idpoint, dataset, altitude, municipality, lapseRateName);
QString toolTipText = QString("Point: <b> %1 </b> <br/> ID: %2 <br/> dataset: %3 <br/> altitude: %4 m <br/>"
"<br/> municipality: %7 <br/> province: %6 <br/> region: %5 <br/> <br/> lapse rate code: %8")
.arg(name, idpoint, dataset, altitude, region, province, municipality, lapseRateName);

double value = currentValue();
if (! isEqual(value, NODATA) || isMarked())
Expand Down
8 changes: 8 additions & 0 deletions agrolib/graphics/stationMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
void setLapseRateCode(lapseRateCodeType code)
{ _lapseRateCode = code; }

void setRegion(const std::string &region)
{ _region = region; }

void setProvince(const std::string &province)
{ _province = province; }

void setMunicipality(const std::string &municipality)
{ _municipality = municipality; }

Expand All @@ -48,6 +54,8 @@
std::string _id;
std::string _name;
std::string _dataset;
std::string _region;
std::string _province;
std::string _municipality;

double _altitude;
Expand Down
6 changes: 3 additions & 3 deletions agrolib/project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4384,7 +4384,7 @@ void Project::deleteProxyWidget()
}


void Project::showProxyGraph()
void Project::showProxyGraph(int macroAreaNumber)
{
Crit3DMeteoPoint* meteoPointsSelected;
int nSelected = 0;
Expand All @@ -4397,7 +4397,7 @@ void Project::showProxyGraph()
}
if (nSelected == 0)
{
proxyWidget = new Crit3DProxyWidget(&interpolationSettings, meteoPoints, nrMeteoPoints, currentFrequency, currentDate, currentHour, quality, &qualityInterpolationSettings, meteoSettings, &climateParameters, checkSpatialQuality);
proxyWidget = new Crit3DProxyWidget(&interpolationSettings, meteoPoints, nrMeteoPoints, currentFrequency, currentDate, currentHour, quality, &qualityInterpolationSettings, meteoSettings, &climateParameters, checkSpatialQuality, macroAreaNumber);
}
else
{
Expand All @@ -4411,7 +4411,7 @@ void Project::showProxyGraph()
posMpSelected = posMpSelected + 1;
}
}
proxyWidget = new Crit3DProxyWidget(&interpolationSettings, meteoPointsSelected, nSelected, currentFrequency, currentDate, currentHour, quality, &qualityInterpolationSettings, meteoSettings, &climateParameters, checkSpatialQuality);
proxyWidget = new Crit3DProxyWidget(&interpolationSettings, meteoPointsSelected, nSelected, currentFrequency, currentDate, currentHour, quality, &qualityInterpolationSettings, meteoSettings, &climateParameters, checkSpatialQuality, macroAreaNumber);
}
QObject::connect(proxyWidget, SIGNAL(closeProxyWidget()), this, SLOT(deleteProxyWidget()));
return;
Expand Down
2 changes: 1 addition & 1 deletion agrolib/project/project.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
void showMeteoWidgetPoint(std::string idMeteoPoint, std::string namePoint, std::string dataset,
double altitude, std::string lapseRateCode, bool isAppend);
void showMeteoWidgetGrid(std::string idCell, bool isAppend);
void showProxyGraph();
void showProxyGraph(int macroAreaNumber);
void showLocalProxyGraph(gis::Crit3DGeoPoint myPoint);

void clearSelectedPoints();
Expand Down
55 changes: 52 additions & 3 deletions agrolib/proxyWidget/proxyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <QDate>


Crit3DProxyWidget::Crit3DProxyWidget(Crit3DInterpolationSettings* interpolationSettings, Crit3DMeteoPoint *meteoPoints, int nrMeteoPoints, frequencyType currentFrequency, QDate currentDate, int currentHour, Crit3DQuality *quality, Crit3DInterpolationSettings* SQinterpolationSettings, Crit3DMeteoSettings *meteoSettings, Crit3DClimateParameters *climateParam, bool checkSpatialQuality)
:interpolationSettings(interpolationSettings), meteoPoints(meteoPoints), nrMeteoPoints(nrMeteoPoints), currentFrequency(currentFrequency), currentDate(currentDate), currentHour(currentHour), quality(quality), SQinterpolationSettings(SQinterpolationSettings), meteoSettings(meteoSettings), climateParam(climateParam), checkSpatialQuality(checkSpatialQuality)
Crit3DProxyWidget::Crit3DProxyWidget(Crit3DInterpolationSettings* interpolationSettings, Crit3DMeteoPoint *meteoPoints, int nrMeteoPoints, frequencyType currentFrequency, QDate currentDate, int currentHour, Crit3DQuality *quality, Crit3DInterpolationSettings* SQinterpolationSettings, Crit3DMeteoSettings *meteoSettings, Crit3DClimateParameters *climateParam, bool checkSpatialQuality, int macroAreaNumber)
:interpolationSettings(interpolationSettings), meteoPoints(meteoPoints), nrMeteoPoints(nrMeteoPoints), currentFrequency(currentFrequency), currentDate(currentDate), currentHour(currentHour), quality(quality), SQinterpolationSettings(SQinterpolationSettings), meteoSettings(meteoSettings), climateParam(climateParam), checkSpatialQuality(checkSpatialQuality), macroAreaNumber(macroAreaNumber)
{
this->setWindowTitle("Proxy analysis over " + QString::number(nrMeteoPoints) + " points");
this->resize(1024, 700);
Expand Down Expand Up @@ -380,6 +380,11 @@ void Crit3DProxyWidget::plot()
{
modelLRClicked(1);
}

if (macroAreaNumber != NODATA)
{
addMacroAreaLR();
}
}


Expand Down Expand Up @@ -474,7 +479,7 @@ void Crit3DProxyWidget::modelLRClicked(int toggled)
}
lapseRate.setText(QString("%1").arg(regressionSlope*1000, 0, 'f', 2));
}
else if (interpolationSettings->getUseMultipleDetrending() && ! interpolationSettings->getUseLocalDetrending())
else if (interpolationSettings->getUseMultipleDetrending() && ! interpolationSettings->getUseLocalDetrending() && ! interpolationSettings->getUseGlocalDetrending())
{
std::string errorStr;

Expand Down Expand Up @@ -541,3 +546,47 @@ void Crit3DProxyWidget::modelLRClicked(int toggled)
}
}

void Crit3DProxyWidget::addMacroAreaLR()
{
//controllo is glocal ready viene fatto a monte
chartView->cleanModelLapseRate();
r2.clear();
lapseRate.clear();
if (macroAreaNumber < interpolationSettings->getMacroAreas().size())
{
std::string errorStr;
setMultipleDetrendingHeightTemperatureRange(interpolationSettings);
glocalDetrendingFitting(outInterpolationPoints, interpolationSettings, myVar,errorStr);

//plot
std::vector<std::vector<double>> myParameters = interpolationSettings->getMacroAreas()[macroAreaNumber].getParameters();

if (myParameters.empty()) return;
if (myParameters.front().size() < 4) return; //elevation is not significant

double xMin = getZmin(outInterpolationPoints);
double xMax = getZmax(outInterpolationPoints);
QList<QPointF> point_vector;
QPointF point;

std::vector <double> xVector;
for (int m = xMin; m < xMax; m += 5)
xVector.push_back(m);

for (int p = 0; p < int(xVector.size()); p++)
{
point.setX(xVector[p]);
if (myParameters.front().size() == 4)
point.setY(lapseRatePiecewise_two(xVector[p], myParameters.front()));
else if (myParameters.front().size() == 5)
point.setY(lapseRatePiecewise_three(xVector[p], myParameters.front()));
else if (myParameters.front().size() == 6)
point.setY(lapseRatePiecewise_three_free(xVector[p], myParameters.front()));
point_vector.append(point);
}

macroAreaNumber = NODATA;
chartView->drawModelLapseRate(point_vector);
}
return;
}
4 changes: 3 additions & 1 deletion agrolib/proxyWidget/proxyWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Q_OBJECT

public:
Crit3DProxyWidget(Crit3DInterpolationSettings* interpolationSettings, Crit3DMeteoPoint* meteoPoints, int nrMeteoPoints, frequencyType currentFrequency, QDate currentDate, int currentHour, Crit3DQuality* quality, Crit3DInterpolationSettings* SQinterpolationSettings, Crit3DMeteoSettings *meteoSettings, Crit3DClimateParameters *climateParam, bool checkSpatialQuality);
Crit3DProxyWidget(Crit3DInterpolationSettings* interpolationSettings, Crit3DMeteoPoint* meteoPoints, int nrMeteoPoints, frequencyType currentFrequency, QDate currentDate, int currentHour, Crit3DQuality* quality, Crit3DInterpolationSettings* SQinterpolationSettings, Crit3DMeteoSettings *meteoSettings, Crit3DClimateParameters *climateParam, bool checkSpatialQuality, int macroAreaNumber);
~Crit3DProxyWidget();
void closeEvent(QCloseEvent *event);
void updateDateTime(QDate newDate, int newHour);
Expand All @@ -23,6 +23,7 @@
void plot();
void climatologicalLRClicked(int toggled);
void modelLRClicked(int toggled);
void addMacroAreaLR();

private:
Crit3DInterpolationSettings* interpolationSettings;
Expand All @@ -47,6 +48,7 @@
ChartView *chartView;
meteoVariable myVar;
int proxyPos;
int macroAreaNumber;

Crit3DTime getCurrentTime();

Expand Down

0 comments on commit 4e95a6a

Please sign in to comment.