Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ARPA-SIMC/PRAGA
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Aug 14, 2024
2 parents 9e790cc + 6a60145 commit 8b67014
Show file tree
Hide file tree
Showing 78 changed files with 1,997 additions and 1,398 deletions.
2 changes: 1 addition & 1 deletion climate/climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ float thomDailyMean(TObsDataH* hourlyValues, float minimumPercentage)
if ( (float(nData) / 24 * 100) < minimumPercentage)
thomDailyMean = NODATA;
else
thomDailyMean = statistics::mean(thomValues, nData);
thomDailyMean = statistics::mean(thomValues);


return thomDailyMean;
Expand Down
79 changes: 61 additions & 18 deletions commonChartElements/dialogChangeAxis.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,57 @@
#include "dialogChangeAxis.h"

DialogChangeAxis::DialogChangeAxis(bool isLeftAxis_)
DialogChangeAxis::DialogChangeAxis(int nrAxis, bool isDate_)
{
isLeftAxis = isLeftAxis_;
isDateAxis = isDate_;

QString title;
if (isLeftAxis)
if (nrAxis == 0)
{
title = "Change X Axis";
}
else if (nrAxis == 1)
{
title = "Change Left Axis";
}
else
else if (nrAxis == 2)
{
title = "Change Right Axis";
}
this->setWindowTitle(title);

QVBoxLayout* mainLayout = new QVBoxLayout;
this->resize(200, 100);

QHBoxLayout *layoutOk = new QHBoxLayout;
QHBoxLayout *layoutEdit = new QHBoxLayout;

QLabel minValueLabel("Minimum value:");
minValueLabel.setBuddy(&minVal);
minVal.setValidator(new QDoubleValidator(-999.0, 999.0, 3));
layoutEdit->addWidget(&minValueLabel);
if (isDateAxis)
{
minValueLabel.setBuddy(&minDate);
layoutEdit->addWidget(&minDate);
}
else
{
minValueLabel.setBuddy(&minVal);
minVal.setValidator(new QDoubleValidator(-9999.0, 9999.0, 3));
layoutEdit->addWidget(&minVal);
}

QLabel maxValueLabel("Maximum value:");
maxValueLabel.setBuddy(&maxVal);
maxVal.setValidator(new QDoubleValidator(-999.0, 999.0, 3));

layoutEdit->addWidget(&minValueLabel);
layoutEdit->addWidget(&minVal);
layoutEdit->addWidget(&maxValueLabel);
layoutEdit->addWidget(&maxVal);
if (isDateAxis)
{
minValueLabel.setBuddy(&maxDate);
layoutEdit->addWidget(&maxDate);
}
else
{
maxValueLabel.setBuddy(&maxVal);
maxVal.setValidator(new QDoubleValidator(-9999.0, 9999.0, 3));
layoutEdit->addWidget(&maxVal);
}

QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

Expand All @@ -55,16 +76,28 @@ void DialogChangeAxis::done(bool res)
{
if (res) // ok
{
if (minVal.text().isEmpty())
if (isDateAxis)
{
QMessageBox::information(nullptr, "Missing min value", "Insert min val");
return;
if (minDate.date() >= maxDate.date())
{
QMessageBox::warning(nullptr, "Wrong dates!", "Insert correct dates.");
return;
}
}
if (maxVal.text().isEmpty())
else
{
QMessageBox::information(nullptr, "Missing max value", "Insert max val");
return;
if (minVal.text().isEmpty())
{
QMessageBox::warning(nullptr, "Missing min value", "Insert minimum value.");
return;
}
if (maxVal.text().isEmpty())
{
QMessageBox::warning(nullptr, "Missing max value", "Insert maximum value.");
return;
}
}

QDialog::done(QDialog::Accepted);
return;
}
Expand All @@ -84,3 +117,13 @@ float DialogChangeAxis::getMaxVal() const
{
return maxVal.text().toFloat();
}

QDate DialogChangeAxis::getMinDate() const
{
return minDate.date();
}

QDate DialogChangeAxis::getMaxDate() const
{
return maxDate.date();
}
12 changes: 10 additions & 2 deletions commonChartElements/dialogChangeAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@
Q_OBJECT

private:
bool isLeftAxis;
bool isDateAxis;

QDateEdit minDate;
QLineEdit minVal;

QDateEdit maxDate;
QLineEdit maxVal;

public:
DialogChangeAxis(bool isLeftAxis);
DialogChangeAxis(int nrAxis, bool isDate_);
~DialogChangeAxis() override;
void done(bool res);

float getMinVal() const;
float getMaxVal() const;

QDate getMinDate() const;
QDate getMaxDate() const;
};

#endif // DIALOGCHANGEAXIS_H
12 changes: 9 additions & 3 deletions criteria1DWidget/criteria1DWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,23 @@ Criteria1DWidget::Criteria1DWidget()
waterContentGroup->setFixedWidth(this->width() * widthRatio);
carbonNitrogenGroup->setFixedWidth(this->width() * widthRatio);

infoCaseGroup->setTitle("Case");
infoCropGroup->setTitle("Crop");
QFont normalFont, boldFont;
boldFont.setBold(true);
normalFont.setBold(false);

infoCaseGroup->setFont(boldFont);
infoCaseGroup->setTitle("Case study");
infoMeteoGroup->setTitle("Meteo");
infoSoilGroup->setTitle("Soil");
infoCropGroup->setTitle("Crop");
laiParametersGroup->setTitle("Crop parameters");
rootParametersGroup->setTitle("Root parameters");
irrigationParametersGroup->setTitle("Irrigation parameters");
waterStressParametersGroup->setTitle("Water Stress parameters");
waterContentGroup->setTitle("Water Content variable");
carbonNitrogenGroup->setTitle("Carbon Nitrogen variable");

caseListComboBox.setFont(normalFont);
caseInfoLayout->addWidget(&caseListComboBox);

cropInfoLayout->addWidget(cropId, 0, 0);
Expand Down Expand Up @@ -435,9 +441,9 @@ Criteria1DWidget::Criteria1DWidget()
carbonNitrogenGroup->setLayout(carbonNitrogenLayout);

infoLayout->addWidget(infoCaseGroup);
infoLayout->addWidget(infoCropGroup);
infoLayout->addWidget(infoMeteoGroup);
infoLayout->addWidget(infoSoilGroup);
infoLayout->addWidget(infoCropGroup);
infoLayout->addWidget(laiParametersGroup);
infoLayout->addWidget(rootParametersGroup);
infoLayout->addWidget(irrigationParametersGroup);
Expand Down
3 changes: 2 additions & 1 deletion criteriaModel/criteria1DCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool Crit1DCase::initializeNumericalFluxes(std::string &error)
double maxSurfaceWater = crop.getSurfaceWaterPonding() * 0.001; // [m]
double roughnessManning = 0.024; // [s m^-0.33]
int surfaceIndex = 0;
soilFluxes3D::setSurfaceProperties(surfaceIndex, roughnessManning, maxSurfaceWater);
soilFluxes3D::setSurfaceProperties(surfaceIndex, roughnessManning);

// center
float x0 = 0;
Expand All @@ -194,6 +194,7 @@ bool Crit1DCase::initializeNumericalFluxes(std::string &error)
int nodeIndex = 0;
soilFluxes3D::setNode(nodeIndex, x0, y0, z0, area, isSurface, true, BOUNDARY_RUNOFF, float(unit.slope), float(ly));
soilFluxes3D::setNodeSurface(nodeIndex, surfaceIndex);
soilFluxes3D::setNodePond(nodeIndex, maxSurfaceWater);
soilFluxes3D::setNodeLink(nodeIndex, nodeIndex + 1, DOWN, float(area));

// set soil nodes
Expand Down
2 changes: 1 addition & 1 deletion crop/crop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Crit3DCrop::Crit3DCrop()
void Crit3DCrop::clear()
{
idCrop = "";
type = HERBACEOUS_ANNUAL;
type = BARESOIL;

roots.clear();

Expand Down
2 changes: 1 addition & 1 deletion crop/crop.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#endif

enum speciesType {HERBACEOUS_ANNUAL, HERBACEOUS_PERENNIAL, HORTICULTURAL, GRASS, TREE, FALLOW, FALLOW_ANNUAL, BARESOIL};
#define NR_CROP_SPECIES 7
#define NR_CROP_SPECIES 8

/*!
* \brief The Crit3DCrop class
Expand Down
10 changes: 0 additions & 10 deletions crop/landUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,3 @@ bool loadLandUnitList(const QSqlDatabase &dbCrop, std::vector<Crit3DLandUnit> &l

return true;
}


int getLandUnitIndex(const std::vector<Crit3DLandUnit> &landUnitList, int idLandUnit)
{
for (int index = 0; index < int(landUnitList.size()); index++)
if (landUnitList[index].id == idLandUnit)
return index;

return NODATA;
}
2 changes: 0 additions & 2 deletions crop/landUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@

bool loadLandUnitList(const QSqlDatabase &dbCrop, std::vector<Crit3DLandUnit> &landUnitList, QString &errorStr);

int getLandUnitIndex(const std::vector<Crit3DLandUnit> &landUnitList, int idLandUnit);


#endif // LANDUNIT_H
4 changes: 2 additions & 2 deletions dbMeteoGrid/dbMeteoGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ std::vector<float> Crit3DMeteoGridDbHandler::loadGridDailyVar(QString *errorStr,

// read last date
qry.last();
if (!getValue(qry.value(_tableDaily.fieldTime), &lastDateDB))
if (! getValue(qry.value(_tableDaily.fieldTime), &lastDateDB))
{
*errorStr = "Missing last date";
return dailyVarList;
Expand Down Expand Up @@ -4126,7 +4126,7 @@ bool Crit3DMeteoGridDbHandler::MeteoGridToRasterFlt(double cellSize, const gis::
{
myGrid.getXY(row, col, utmx, utmy);
gis::getLatLonFromUtm(gisSettings, utmx, utmy, &lat, &lon);
gis::getGridRowColFromXY (latlonHeader, lon, lat, &dataGridRow, &dataGridCol);
gis::getRowColFromLonLat (latlonHeader, lon, lat, &dataGridRow, &dataGridCol);
if (dataGridRow < 0 || dataGridRow >= latlonHeader.nrRows || dataGridCol < 0 || dataGridCol >= latlonHeader.nrCols)
{
myValue = NODATA;
Expand Down
1 change: 1 addition & 0 deletions dbMeteoGrid/dbMeteoGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
std::vector<float> loadGridHourlyVar(QString *errorStr, QString meteoPoint, meteoVariable variable, QDateTime first, QDateTime last, QDateTime* firstDateDB);
std::vector<float> loadGridHourlyVarFixedFields(QString *errorStr, QString meteoPoint, meteoVariable variable, QDateTime first, QDateTime last, QDateTime* firstDateDB);
std::vector<float> exportAllDataVar(QString *errorStr, frequencyType freq, meteoVariable variable, QString id, QDateTime myFirstTime, QDateTime myLastTime, std::vector<QString> &dateStr);

bool getYearList(QString *errorStr, QString meteoPoint, QList<QString>* yearList);
bool idDailyList(QString *errorStr, QList<QString>* idMeteoList);

Expand Down
Loading

0 comments on commit 8b67014

Please sign in to comment.