Skip to content

Commit

Permalink
fixed graphs x values
Browse files Browse the repository at this point in the history
  • Loading branch information
gantolini committed Nov 9, 2023
1 parent abe5b25 commit 983a71a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
16 changes: 11 additions & 5 deletions bin/HEAT1D/colorMapGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,23 @@ void ColorMapGraph::draw(Crit3DOut* out, outputGroup graphType)

float maxDepth = myOut->layerThickness * ((float)(ny-1) + 0.5);
colorMap->data()->setSize(nx, ny);
colorMap->data()->setRange(QCPRange(0, nx), QCPRange(maxDepth,0));
graphic->xAxis->setRange(0, nx);

for (int z = 1; z <= ny; z++)
for (int y = 1; y <= ny; y++)
{
mySeries.clear();
mySeries = getProfileSeries(myOut, graphType, z, &minSeries, &maxSeries);
mySeries = getProfileSeries(myOut, graphType, y, &minSeries, &maxSeries);

if (y == 1)
{
graphic->xAxis->setRange(0, mySeries[mySeries.size()-1].x());
colorMap->data()->setRange(QCPRange(0, mySeries[mySeries.size()-1].x()), QCPRange(maxDepth,0));
}

for (unsigned int j = 0; j < mySeries.size(); j++)
{
colorMap->data()->setCell(mySeries[j].x(), z-1, mySeries[j].y());
colorMap->data()->setCell(j, y-1, mySeries[j].y());
}

minGraph = (minGraph == NODATA) ? minSeries : ((minSeries != NODATA && minSeries < minGraph) ? minSeries : minGraph);
maxGraph = (maxGraph == NODATA) ? maxSeries : ((maxSeries != NODATA && maxSeries > maxGraph) ? maxSeries : maxGraph);
}
Expand Down
21 changes: 15 additions & 6 deletions bin/HEAT1D/graphFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ QVector<QPointF> getSingleSeries(Crit3DOut* myOut, outputVar myVar, float* MINVA
*MAXVALUE = NODATA;

for (int i=0; i<myOut->nrValues; i++)
{
myPoint.setX(i+1);

{
switch (myVar)
{
case outputVar::surfaceNetIrradiance :
Expand Down Expand Up @@ -108,6 +106,7 @@ QVector<QPointF> getSingleSeries(Crit3DOut* myOut, outputVar myVar, float* MINVA
myVal = myOut->bottomFluxes[i].drainage.y();
}

myPoint.setX(myOut->landSurfaceOutput[i].netRadiation.x());
myPoint.setY(myVal);
mySeries.push_back(myPoint);
*MINVALUE = (*MINVALUE == NODATA) ? myVal : ((myVal < *MINVALUE) ? myVal : *MINVALUE);
Expand All @@ -121,62 +120,72 @@ QVector<QPointF> getProfileSeries(Crit3DOut* myOut, outputGroup myVar, int layer
{
QVector<QPointF> mySeries;
QPointF myPoint;
qreal myVal;
qreal myVal, myX;

*MINVALUE = NODATA;
*MAXVALUE = NODATA;

for (int i=0; i<myOut->nrValues; i++)
{
myPoint.setX(i);

switch (myVar)
{
case outputGroup::soilTemperature :
myX = myOut->profileOutput[i].temperature[layerIndex].x();
myVal = myOut->profileOutput[i].temperature[layerIndex].y();
break;

case outputGroup::soilWater :
myX = myOut->profileOutput[i].waterContent[layerIndex].x();
myVal = myOut->profileOutput[i].waterContent[layerIndex].y();
break;

case outputGroup::soilHeatConductivity :
myX = myOut->profileOutput[i].heatConductivity[layerIndex].x();
myVal = myOut->profileOutput[i].heatConductivity[layerIndex].y();
break;

case outputGroup::totalHeatFlux :
myX = myOut->profileOutput[i].totalHeatFlux[layerIndex].x();
myVal = myOut->profileOutput[i].totalHeatFlux[layerIndex].y();
break;

case outputGroup::latentHeatFluxIso :
myX = myOut->profileOutput[i].isothermalLatentHeatFlux[layerIndex].x();
myVal = myOut->profileOutput[i].isothermalLatentHeatFlux[layerIndex].y();
break;

case outputGroup::latentHeatFluxTherm :
myX = myOut->profileOutput[i].thermalLatentHeatFlux[layerIndex].x();
myVal = myOut->profileOutput[i].thermalLatentHeatFlux[layerIndex].y();
break;

case outputGroup::diffusiveHeatFlux :
myX = myOut->profileOutput[i].diffusiveHeatFlux[layerIndex].x();
myVal = myOut->profileOutput[i].diffusiveHeatFlux[layerIndex].y();
break;

case outputGroup::waterIsothLiquidFlux :
myX = myOut->profileOutput[i].waterIsothermalLiquidFlux[layerIndex].x();
myVal = myOut->profileOutput[i].waterIsothermalLiquidFlux[layerIndex].y();
break;

case outputGroup::waterThermLiquidFlux :
myX = myOut->profileOutput[i].waterThermalLiquidFlux[layerIndex].x();
myVal = myOut->profileOutput[i].waterThermalLiquidFlux[layerIndex].y();
break;

case outputGroup::waterIsothVaporFlux :
myX = myOut->profileOutput[i].waterIsothermalVaporFlux[layerIndex].x();
myVal = myOut->profileOutput[i].waterIsothermalVaporFlux[layerIndex].y();
break;

case outputGroup::waterThermVaporFlux :
myX = myOut->profileOutput[i].waterThermalVaporFlux[layerIndex].x();
myVal = myOut->profileOutput[i].waterThermalVaporFlux[layerIndex].y();
break;
}

myPoint.setX(myX);
myPoint.setY(myVal);
mySeries.push_back(myPoint);
*MINVALUE = (*MINVALUE == NODATA) ? myVal : ((myVal < *MINVALUE) ? myVal : *MINVALUE);
Expand Down
6 changes: 3 additions & 3 deletions bin/HEAT1D/heat1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ bool isValid(double myValue)
return (myValue != MEMORY_ERROR && myValue != MISSING_DATA_ERROR && myValue != INDEX_ERROR);
}

void getOutputAllPeriod(long firstIndex, long lastIndex, Crit3DOut *output)
void getOutputAllPeriod(long firstIndex, long lastIndex, Crit3DOut *output, double timeH)
{
long myIndex;
double myValue;
Expand All @@ -344,7 +344,7 @@ void getOutputAllPeriod(long firstIndex, long lastIndex, Crit3DOut *output)

for (myIndex = firstIndex ; myIndex <= lastIndex ; myIndex++ )
{
myPoint.setX(myIndex);
myPoint.setX(timeH);

myValue = soilFluxes3D::getTemperature(myIndex);
if (isValid(myValue)) myValue -= 273.16;
Expand Down Expand Up @@ -425,7 +425,7 @@ void getOutputAllPeriod(long firstIndex, long lastIndex, Crit3DOut *output)
output->profileOutput[output->nrValues-1].waterThermalVaporFlux.push_back(myPoint);
}

myPoint.setX(output->landSurfaceOutput.size() + 1);
myPoint.setX(timeH);

// net radiation (positive downward)
myValue = soilFluxes3D::getBoundaryRadiativeFlux(1);
Expand Down
2 changes: 1 addition & 1 deletion bin/HEAT1D/heat1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void setWaterTable(bool isWaterTable, double depth);
void setHeatProcesses(bool computeHeatAdvection, bool computeHeatLatent, bool computeHeatSensible);
void setProcesses(bool computeWaterProcess, bool computeHeatProcess, bool computeSolutesProcess);
void setProcessesHeat(bool computeLatent_, bool computeAdvection_);
void getOutputAllPeriod(long firstIndex, long lastIndex, Crit3DOut *output);
void getOutputAllPeriod(long firstIndex, long lastIndex, Crit3DOut *output, double timeH);
long getNodesNumber();
void setSoilHorizonNumber(int myHorizonNumber);

Expand Down
2 changes: 1 addition & 1 deletion bin/HEAT1D/linearGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void LinearGraph::draw(Crit3DColorScale colorScale, Crit3DOut* out, outputGroup
curve->setColor(color);
curve->setName(myCurveNames[i]);
mySeries = getSingleSeries(myOut, outputVar(i+startIndex), &minSeries, &maxSeries);
axisX->setRange(1, mySeries.size());
axisX->setRange(0, mySeries[mySeries.size()-1].x());
for (unsigned int j = 0; j < mySeries.size(); j++)
{
curve->append(mySeries[j]);
Expand Down
9 changes: 6 additions & 3 deletions bin/HEAT1D/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void MainWindow::on_pushRunAllPeriod_clicked()
myPIniHour = ui->lineEditPrecStart->text().toInt();
myPHours = ui->lineEditPrecHours->text().toInt();

int outTimeStep = ui->lineEditTimeStep->text().toInt();
double outTimeStep = ui->lineEditTimeStep->text().toDouble();

int hourFin;
if (!useInputMeteoData)
Expand All @@ -144,6 +144,8 @@ void MainWindow::on_pushRunAllPeriod_clicked()

ui->prgBar->setMaximum(hourFin);

double totalHours = 0;

do
{
myTime = myTime.addSecs(outTimeStep);
Expand All @@ -169,15 +171,16 @@ void MainWindow::on_pushRunAllPeriod_clicked()
myWS = ui->lineEditAtmWS->text().toDouble();
myNR = ui->lineEditAtmFlux->text().toDouble();

if ((indexHour >= myPIniHour) && (indexHour < myPIniHour + myPHours))
if ((indexHour >= myPIniHour) && (indexHour <= myPIniHour + myPHours))
myP = ui->lineEditPrecHourlyAmount->text().toDouble();
else
myP = 0.;
}

runHeat1D(myT, myRH, myWS, myNR, myP, outTimeStep);

getOutputAllPeriod(0, getNodesNumber(), &myHeatOutput);
totalHours += outTimeStep / 3600;
getOutputAllPeriod(0, getNodesNumber(), &myHeatOutput, totalHours);

ui->prgBar->setValue(indexHour);
qApp->processEvents();
Expand Down

0 comments on commit 983a71a

Please sign in to comment.