Skip to content

Commit

Permalink
interpolation period on output points
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Nov 28, 2023
1 parent 65d21fc commit b397344
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 11 deletions.
6 changes: 2 additions & 4 deletions dbMeteoPoints/dbMeteoPointsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ bool Crit3DMeteoPointsDbHandler::importHourlyMeteoData(QString csvFileName, bool
}


bool Crit3DMeteoPointsDbHandler::writeDailyDataList(QString pointCode, QList<QString> listEntries, QString& log)
bool Crit3DMeteoPointsDbHandler::writeDailyDataList(const QString &pointCode, const QList<QString> &listEntries, QString& log)
{
if (! existIdPoint(pointCode))
{
Expand All @@ -1412,7 +1412,6 @@ bool Crit3DMeteoPointsDbHandler::writeDailyDataList(QString pointCode, QList<QSt

queryStr = queryStr + listEntries.join(",");

// exec query
QSqlQuery qry(_db);
qry.prepare(queryStr);
if (! qry.exec())
Expand All @@ -1425,7 +1424,7 @@ bool Crit3DMeteoPointsDbHandler::writeDailyDataList(QString pointCode, QList<QSt
}


bool Crit3DMeteoPointsDbHandler::writeHourlyDataList(QString pointCode, QList<QString> listEntries, QString &log)
bool Crit3DMeteoPointsDbHandler::writeHourlyDataList(const QString &pointCode, const QList<QString> &listEntries, QString &log)
{
if (! existIdPoint(pointCode))
{
Expand All @@ -1446,7 +1445,6 @@ bool Crit3DMeteoPointsDbHandler::writeHourlyDataList(QString pointCode, QList<QS

queryStr = queryStr + listEntries.join(",");

// exec query
QSqlQuery qry(_db);
qry.prepare(queryStr);
if (! qry.exec())
Expand Down
4 changes: 2 additions & 2 deletions dbMeteoPoints/dbMeteoPointsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
int* nrMissingData, int* nrWrongData, Crit3DQuality* dataQuality);
bool importHourlyMeteoData(QString fileNameComplete, bool deletePreviousData, QString *log);

bool writeDailyDataList(QString pointCode, QList<QString> listEntries, QString& log);
bool writeHourlyDataList(QString pointCode, QList<QString> listEntries, QString& log);
bool writeDailyDataList(const QString &pointCode, const QList<QString> &listEntries, QString& log);
bool writeHourlyDataList(const QString &pointCode, const QList<QString> &listEntries, QString& log);

bool setAllPointsActive();
bool setAllPointsNotActive();
Expand Down
73 changes: 69 additions & 4 deletions pragaProject/pragaProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,72 @@ bool PragaProject::hourlyDerivedVariablesGrid(QDate first, QDate last, bool load
return true;
}

bool PragaProject::interpolationMeteoGridPeriod(QDate dateIni, QDate dateFin, QList <meteoVariable> variables, QList <meteoVariable> aggrVariables, bool saveRasters, int nrDaysLoading, int nrDaysSaving)

bool PragaProject::interpolationOutputPointsPeriod(QDate dateIni, QDate dateFin, QList <meteoVariable> variables)
{
// check
if (variables.size() == 0)
{
errorString = "No variables";
return false;
}

if (! meteoPointsLoaded || nrMeteoPoints == 0)
{
errorString = "No meteo points";
return false;
}

if (! outputMeteoPointsLoaded || outputPoints.empty())
{
errorString = "No output points";
return false;
}

// check dates
if (dateIni.isNull() || dateFin.isNull() || dateIni > dateFin)
{
errorString = "Wrong period.";
return false;
}

// check variables
bool isDaily = false;
bool isHourly = false;
QList<meteoVariable> varToSave;
meteoVariable myVar;

foreach (myVar, variables)
{
frequencyType freq = getVarFrequency(myVar);

if (freq == noFrequency)
{
errorString = "Unknown variable: " + QString::fromStdString(getMeteoVarName(myVar));
return false;
}
else if (freq == hourly)
isHourly = true;
else if (freq == daily)
isDaily = true;

varToSave.push_back(myVar);

// save two variables for vector wind
if (myVar == windVectorIntensity)
varToSave.push_back(windVectorDirection);
else if (myVar == windVectorDirection)
varToSave.push_back(windVectorIntensity);
}

errorString = "TODO";
return false;
}


bool PragaProject::interpolationMeteoGridPeriod(QDate dateIni, QDate dateFin, QList <meteoVariable> variables,
QList <meteoVariable> aggrVariables, bool saveRasters,
int nrDaysLoading, int nrDaysSaving)
{
// check variables
if (variables.size() == 0)
Expand Down Expand Up @@ -1916,9 +1981,7 @@ bool PragaProject::interpolationMeteoGridPeriod(QDate dateIni, QDate dateFin, QL
return false;
}

//order variables for derived computation

std::string id;
// order variables for derived computation
std::string errString;
QString myError, rasterName, varName;
int myHour;
Expand Down Expand Up @@ -3549,6 +3612,8 @@ bool PragaProject::saveLogProceduresGrid(QString nameProc, QDate date)
}


// --------------------------- OUTPUT METEO POINTS ----------------------------------

void PragaProject::closeOutputMeteoPointsDB()
{
if (outputMeteoPointsDbHandler != nullptr)
Expand Down
6 changes: 5 additions & 1 deletion pragaProject/pragaProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@
bool downloadDailyDataArkimet(QList<QString> variables, bool prec0024, QDate startDate, QDate endDate, bool showInfo);
bool downloadHourlyDataArkimet(QList<QString> variables, QDate startDate, QDate endDate, bool showInfo);

bool interpolationOutputPointsPeriod(QDate dateIni, QDate dateFin, QList <meteoVariable> variables);

bool interpolationMeteoGrid(meteoVariable myVar, frequencyType myFrequency, const Crit3DTime& myTime);
bool interpolationMeteoGridPeriod(QDate dateIni, QDate dateFin, QList <meteoVariable> variables, QList<meteoVariable> aggrVariables, bool saveRasters, int nrDaysLoading, int nrDaysSaving);
bool interpolationMeteoGridPeriod(QDate dateIni, QDate dateFin, QList <meteoVariable> variables,
QList<meteoVariable> aggrVariables, bool saveRasters, int nrDaysLoading, int nrDaysSaving);

bool saveGrid(meteoVariable myVar, frequencyType myFrequency, const Crit3DTime& myTime, bool showInfo);
bool timeAggregateGridVarHourlyInDaily(meteoVariable dailyVar, Crit3DDate dateIni, Crit3DDate dateFin);
bool timeAggregateGrid(QDate dateIni, QDate dateFin, QList <meteoVariable> variables, bool loadData, bool saveData);
Expand Down

0 comments on commit b397344

Please sign in to comment.