Skip to content

Commit

Permalink
clean vine3d
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jul 30, 2024
1 parent ce4e978 commit 26ebafc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 73 deletions.
2 changes: 2 additions & 0 deletions agrolib/project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,9 @@ float Project::meteoDataConsistency(meteoVariable myVar, const Crit3DTime& timeI
{
float dataConsistency = 0.0;
for (int i = 0; i < nrMeteoPoints; i++)
{
dataConsistency = MAXVALUE(dataConsistency, meteoPoints[i].obsDataConsistencyH(myVar, timeIni, timeFin));
}

return dataConsistency;
}
Expand Down
8 changes: 1 addition & 7 deletions bin/VINE3D/atmosphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@ bool vine3DInterpolationDem(Vine3DProject* myProject, meteoVariable myVar,
}


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


bool vine3DInterpolationDemRadiation(Vine3DProject* myProject, const Crit3DTime& myCrit3DTime, bool isLoadData)
{
bool myResult = false;
Expand All @@ -170,7 +164,7 @@ bool vine3DInterpolationDemRadiation(Vine3DProject* myProject, const Crit3DTime&

gis::Crit3DPoint myDEMCenter = myProject->DEM.getCenter();
int intervalWidth = radiation::estimateTransmissivityWindow(&(myProject->radSettings), myProject->DEM, myDEMCenter, myCrit3DTime, (int)(3600 / myProject->meteoSettings->getHourlyIntervals()));
int myTimeStep = getTimeStepFromHourlyInterval(myProject->meteoSettings->getHourlyIntervals());
int myTimeStep = int(myProject->getTimeStep());

float myDeltaTime = (intervalWidth-1) * 0.5 * myTimeStep;
Crit3DTime myTimeIni = myCrit3DTime.addSeconds(-myDeltaTime);
Expand Down
58 changes: 7 additions & 51 deletions bin/VINE3D/vine3DProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ bool Vine3DProject::loadFieldBook()
}


/*
int Vine3DProject::queryFieldPoint(double x, double y)
{
QString UTMx = QString::number(x, 'f', 1);
Expand Down Expand Up @@ -433,6 +434,7 @@ int Vine3DProject::queryFieldPoint(double x, double y)
else
return NODATA;
}
*/



Expand Down Expand Up @@ -612,16 +614,7 @@ bool Vine3DProject::loadFieldsProperties()
}


float Vine3DProject::findSoilMaxDepth()
{
double maxSoilDepth = 0;
for (unsigned int i = 0; i < nrSoils; i++)
{
maxSoilDepth = MAXVALUE(maxSoilDepth, soilList[i].totalDepth);
}
return MINVALUE(computationSoilDepth, maxSoilDepth);
}

/*
int Vine3DProject::getAggregatedVarCode(int rawVarCode)
{
for (int i=0; i<nrAggrVar; i++)
Expand All @@ -630,6 +623,7 @@ int Vine3DProject::getAggregatedVarCode(int rawVarCode)
return NODATA;
}
*/


int getMeteoVarIndex(meteoVariable myVar)
Expand Down Expand Up @@ -675,6 +669,7 @@ bool Vine3DProject::getMeteoVarIndexRaw(meteoVariable myVar, int* nrIndices, int
}


/*
bool Vine3DProject::loadDBPoints()
{
closeMeteoPointsDB();
Expand Down Expand Up @@ -740,6 +735,7 @@ bool Vine3DProject::loadDBPoints()
return(true);
}
void Vine3DProject::findVine3DLastMeteoDate()
{
QSqlQuery qry(dbVine3D);
Expand Down Expand Up @@ -771,25 +767,7 @@ void Vine3DProject::findVine3DLastMeteoDate()
setCurrentDate(lastDate.date());
setCurrentHour(12);
}

float Vine3DProject::meteoDataConsistency(meteoVariable myVar, const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin)
{
float dataConsistency = 0.0;
for (int i = 0; i < nrMeteoPoints; i++)
dataConsistency = MAXVALUE(dataConsistency, meteoPoints[i].obsDataConsistencyH(myVar, myTimeIni, myTimeFin));

return dataConsistency;
}


bool Vine3DProject::isMeteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin)
{
for (int i = 0; i < nrMeteoPoints; i++)
if (meteoPoints[i].isDateIntervalLoadedH(myTimeIni, myTimeFin))
return true;

return false;
}
*/


/*
Expand Down Expand Up @@ -1118,15 +1096,6 @@ bool Vine3DProject::loadObsDataAllPointsVar(meteoVariable myVar, QDate d1, QDate
}


int Vine3DProject::getIndexPointFromId(QString myId)
{
for (int i = 0; i < nrMeteoPoints; i++)
if (QString::fromStdString(meteoPoints[i].id) == myId)
return(i);
return(NODATA);
}


float Vine3DProject::getTimeStep()
{
return (3600 / meteoSettings->getHourlyIntervals());
Expand Down Expand Up @@ -1391,19 +1360,6 @@ bool Vine3DProject::isVineyard(unsigned row, unsigned col)
}


soil::Crit3DHorizon* Vine3DProject::getSoilHorizon(long row, long col, int layer)
{
int soilIndex = getSoilIndex(row, col);
if (soilIndex == NODATA) return nullptr;

int horizonIndex = soil::getHorizonIndex(soilList[unsigned(soilIndex)], layer);
if (horizonIndex == NODATA) return nullptr;

soil::Crit3DHorizon* horizonPtr = &(soilList[unsigned(soilIndex)].horizon[unsigned(horizonIndex)]);
return horizonPtr;
}


bool Vine3DProject::getFieldBookIndex(int firstIndex, QDate myDate, int fieldIndex, int* outputIndex)
{
*outputIndex = NODATA;
Expand Down
21 changes: 6 additions & 15 deletions bin/VINE3D/vine3DProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@
void loadVine3DSettings();

bool loadFieldsProperties();
bool loadDBPoints();

//bool loadDBPoints();
//void findVine3DLastMeteoDate();
//int queryFieldPoint(double x, double y);

bool loadGrapevineParameters();
bool loadTrainingSystems();

bool loadFieldBook();
float findSoilMaxDepth();
soil::Crit3DSoil *loadHorizons(int idSoil, QString soil_code);

bool loadVine3DProject(QString projectFileName);
bool openVine3DDatabase(QString fileName);
Expand All @@ -108,29 +110,20 @@

bool setModelCasesMap();

int queryFieldPoint(double x, double y);

bool readFieldQuery(QSqlQuery &myQuery, int &idField, GrapevineLanduse &landuse, int &vineIndex, int &trainingIndex, float &maxLaiGrass, float &maxIrrigationRate);
bool setField(int fieldIndex, int fieldId, GrapevineLanduse landuse, int soilIndex, int vineIndex, int trainingIndex,
float maxLaiGrass, float maxIrrigationRate);
bool getFieldBookIndex(int firstIndex, QDate myQDate, int fieldIndex, int* outputIndex);

int getAggregatedVarCode(int rawVarCode);
//int getAggregatedVarCode(int rawVarCode);
bool getMeteoVarIndexRaw(meteoVariable myVar, int *nrVarIndices, int **varIndices);

bool loadObsDataHourlyVar(int indexPoint, meteoVariable myVar, QDate d1, QDate d2, QString tableName, bool useAggrCodes);
bool loadObsDataAllPointsVar(meteoVariable myVar, QDate d1, QDate d2);

bool isMeteoDataLoaded(const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin);
float meteoDataConsistency(meteoVariable myVar, const Crit3DTime& myTimeIni, const Crit3DTime& myTimeFin);

void findVine3DLastMeteoDate();

bool loadStates(QDate myDate);
bool saveStateAndOutput(QDate myDate);

int getIndexPointFromId(QString myId);

float getTimeStep();

int getModelCaseIndex(int row, int col);
Expand All @@ -139,8 +132,6 @@

bool computeVine3DWaterSinkSource();

soil::Crit3DHorizon* getSoilHorizon(long row, long col, int layer);

bool runModels(QDateTime firstTime, QDateTime lastTime, bool saveOutput);

bool vine3dShell();
Expand Down

0 comments on commit 26ebafc

Please sign in to comment.