Skip to content

Commit

Permalink
update vine3d
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Oct 26, 2023
1 parent 03243f0 commit a8b3d65
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
9 changes: 6 additions & 3 deletions bin/VINE3D/dataHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ QString getVarNameFromPlantVariable(plantVariable myVar)
return "";
}



/*
meteoVariable getMeteoVariable(int myVar)
{
if (myVar == 14) return(airTemperature);
Expand All @@ -89,6 +88,7 @@ meteoVariable getMeteoVariable(int myVar)
else if (myVar == 43) return(windVectorDirection);
else return(noMeteoVar);
}
*/

int getMeteoVarIndex(meteoVariable myVar)
{
Expand All @@ -104,7 +104,10 @@ int getMeteoVarIndex(meteoVariable myVar)
return NODATA;
}


float getTimeStepFromHourlyInterval(int myHourlyIntervals)
{ return 3600. / ((float)myHourlyIntervals);}
{
return 3600. / ((float)myHourlyIntervals);
}


2 changes: 1 addition & 1 deletion bin/VINE3D/dataHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

float getTimeStepFromHourlyInterval(int myHourlyIntervals);

meteoVariable getMeteoVariable(int myVar);
//meteoVariable getMeteoVariable(int myVar);
int getMeteoVarIndex(meteoVariable myVar);

QString getVarNameFromPlantVariable(plantVariable myVar);
Expand Down
12 changes: 6 additions & 6 deletions bin/VINE3D/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,22 +560,22 @@ void MainWindow::on_variableButton_clicked()

void MainWindow::on_rasterRestoreButton_clicked()
{
if (this->rasterObj->getRaster() == nullptr)
if (rasterObj->getRaster() == nullptr)
{
QMessageBox::information(nullptr, "No Raster", "Load raster before");
return;
}

setDefaultDEMScale(myProject.DEM.colorScale);
this->setCurrentRaster(&(myProject.DEM));
setColorScale(noMeteoTerrain, myProject.DEM.colorScale);
setCurrentRaster(&(myProject.DEM));
ui->labelRasterScale->setText(QString::fromStdString(getVariableString(noMeteoTerrain)));
}

void MainWindow::setCurrentRaster(gis::Crit3DRasterGrid *myRaster)
{
this->rasterObj->initializeUTM(myRaster, myProject.gisSettings, false);
this->rasterLegend->colorScale = myRaster->colorScale;
this->rasterObj->redrawRequested();
rasterObj->initializeUTM(myRaster, myProject.gisSettings, false);
rasterLegend->colorScale = myRaster->colorScale;
rasterObj->redrawRequested();
}

void MainWindow::on_dateEdit_dateChanged(const QDate &date)
Expand Down
17 changes: 14 additions & 3 deletions bin/VINE3D/vine3DProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,8 @@ float Vine3DProject::meteoDataConsistency(meteoVariable myVar, const Crit3DTime&
return dataConsistency;
}

bool Vine3DProject::meteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin)

bool Vine3DProject::isMeteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin)
{
for (int i = 0; i < nrMeteoPoints; i++)
if (meteoPoints[i].isDateIntervalLoadedH(myTimeIni, myTimeFin))
Expand All @@ -817,6 +818,8 @@ bool Vine3DProject::meteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTim
return false;
}


/*
//observed data: 5 minutes
bool Vine3DProject::loadObsDataSubHourly(int indexPoint, meteoVariable myVar, QDateTime d1, QDateTime d2, QString tableName)
{
Expand Down Expand Up @@ -952,6 +955,7 @@ bool Vine3DProject::loadObsDataHourly(int indexPoint, QDate d1, QDate d2, QStrin
myQuery.clear();
return(dataAvailable);
}
*/


bool Vine3DProject::loadObsDataHourlyVar(int indexPoint, meteoVariable myVar, QDate d1, QDate d2, QString tableName, bool useAggrCodes)
Expand Down Expand Up @@ -980,10 +984,14 @@ bool Vine3DProject::loadObsDataHourlyVar(int indexPoint, meteoVariable myVar, QD
else
{
queryString = "SELECT date_, hour_, obs_value, data_valid FROM " + tableName;
if (!this->getMeteoVarIndexRaw(myVar, &nrIndices, &varIndices)) return false;
if (! this->getMeteoVarIndexRaw(myVar, &nrIndices, &varIndices))
return false;

queryString += " WHERE id_variable IN (";
for (int i=0; i<nrIndices-1; i++)
{
queryString += QString::number(varIndices[i]) + ",";
}
queryString += QString::number(varIndices[nrIndices-1]) + ")";
}

Expand Down Expand Up @@ -1038,6 +1046,7 @@ bool Vine3DProject::loadObsDataHourlyVar(int indexPoint, meteoVariable myVar, QD
}


/*
bool Vine3DProject::loadObsDataAllPoints(QDate d1, QDate d2, bool showInfo)
{
isObsDataLoaded = false;
Expand Down Expand Up @@ -1092,6 +1101,7 @@ bool Vine3DProject::loadObsDataAllPoints(QDate d1, QDate d2, bool showInfo)
return(isObsDataLoaded);
}
*/


bool Vine3DProject::loadObsDataAllPointsVar(meteoVariable myVar, QDate d1, QDate d2)
Expand Down Expand Up @@ -1126,7 +1136,6 @@ bool Vine3DProject::loadObsDataAllPointsVar(meteoVariable myVar, QDate d1, QDate
if (loadObsDataHourlyVar(i, myVar, d1, d2, "obs_values_h", false))
isObsDataWMSLoaded = true;
}

}

isObsDataLoaded = (isObsDataBoundaryLoaded || isObsDataWMSLoaded || isForecastLoaded);
Expand All @@ -1151,6 +1160,7 @@ float Vine3DProject::getTimeStep()
}


/*
bool Vine3DProject::loadObsDataFilled(QDateTime firstTime, QDateTime lastTime)
{
QDate d1 = firstTime.date().addDays(-30);
Expand Down Expand Up @@ -1183,6 +1193,7 @@ bool Vine3DProject::loadObsDataFilled(QDateTime firstTime, QDateTime lastTime)
return true;
}
*/


bool Vine3DProject::runModels(QDateTime firstTime, QDateTime lastTime, bool saveOutput)
Expand Down
14 changes: 8 additions & 6 deletions bin/VINE3D/vine3DProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,19 @@
float maxLaiGrass, float maxIrrigationRate);
bool getFieldBookIndex(int firstIndex, QDate myQDate, int fieldIndex, int* outputIndex);


int getAggregatedVarCode(int rawVarCode);
bool getMeteoVarIndexRaw(meteoVariable myVar, int *nrVarIndices, int **varIndices);
bool loadObsDataSubHourly(int indexPoint, meteoVariable myVar, QDateTime d1, QDateTime d2, QString tableName);
bool loadObsDataHourly(int indexPoint, QDate d1, QDate d2, QString tableName, bool useAggrCodes);

bool loadObsDataHourlyVar(int indexPoint, meteoVariable myVar, QDate d1, QDate d2, QString tableName, bool useAggrCodes);
bool loadObsDataAllPoints(QDate d1, QDate d2, bool showInfo);
bool loadObsDataAllPointsVar(meteoVariable myVar, QDate d1, QDate d2);
bool meteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin);

bool isMeteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin);
float meteoDataConsistency(meteoVariable myVar, const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin);
bool loadObsDataFilled(QDateTime firstTime, QDateTime lastTime);

//bool loadObsDataSubHourly(int indexPoint, meteoVariable myVar, QDateTime d1, QDateTime d2, QString tableName);
//bool loadObsDataHourly(int indexPoint, QDate d1, QDate d2, QString tableName, bool useAggrCodes);
//bool loadObsDataFilled(QDateTime firstTime, QDateTime lastTime);
//bool loadObsDataAllPoints(QDate d1, QDate d2, bool showInfo);
void findVine3DLastMeteoDate();

bool loadStates(QDate myDate);
Expand Down

0 comments on commit a8b3d65

Please sign in to comment.