WSL/SLF GitLab Repository

Commit 333d94e3 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

First improvements for issue 3

Now ILWR must only be present once, there are no cross-checks with TA and RH
parent ed8d0e43
......@@ -200,33 +200,29 @@ void MeteoObj::checkInputsRequirements(std::vector<MeteoData>& vecData)
//This function checks that the necessary input data are available for the current timestamp
unsigned int nb_ta=0, nb_iswr=0, nb_rh=0, nb_ilwr=0;
unsigned int nb_ilwr_ta=0;
unsigned int nb_iswr_ta_rh=0;
if (vecData.empty())
throw IOException("Vector of input meteo data is empty!", AT);
for (size_t ii=0; ii<vecData.size(); ii++) {
if (vecData[ii](MeteoData::TA) != IOUtils::nodata) nb_ta++;
if (vecData[ii](MeteoData::ISWR) != IOUtils::nodata) nb_iswr++;
if (vecData[ii](MeteoData::RH) != IOUtils::nodata) nb_rh++;
if (vecData[ii](MeteoData::ILWR) != IOUtils::nodata) nb_ilwr++;
if (vecData[ii](MeteoData::ILWR) != IOUtils::nodata) {
//We need ILWR and TA at the same location (so that the emissivity can be computed)
//But since we rely on having one meteo1D station in the code, we also need ISWR at this place
//(since we use the location of the measurement for computations with ISWR)
if (vecData[ii](MeteoData::TA) != IOUtils::nodata && vecData[ii](MeteoData::ISWR) != IOUtils::nodata) nb_ilwr_ta++;
if (vecData[ii](MeteoData::ISWR) != IOUtils::nodata) {
//We need ISWR and TA+RH at the same location (so that the splitting coefficient and atmospheric losses can be computed)
if (vecData[ii](MeteoData::TA) != IOUtils::nodata && vecData[ii](MeteoData::RH) != IOUtils::nodata) nb_iswr_ta_rh++;
if ( nb_ta==0 || nb_iswr==0 || nb_rh==0 || nb_ilwr==0) {
printf("nb(ta)=%d nb(iswr)=%d nb(rh)=%d nb(ilwr)=%d\n",nb_ta, nb_iswr, nb_rh, nb_ilwr);
if ( nb_ta==0 || nb_rh==0 || nb_ilwr==0 || nb_iswr==0 || nb_iswr_ta_rh==0) {
printf("nb(ta)=%d nb(rh)=%d nb(ilwr)=%d nb(iswr)=%d\n",nb_ta, nb_rh, nb_ilwr, nb_iswr);
throw IOException("Not enough input meteo data on "+vecData[0].date.toString(Date::ISO), AT);
if ( nb_ilwr_ta==0 ) {
cout << "[e] For emissivity calculation, at least one set of both TA and ILWR are needed at the same station!\n";
if ( nb_iswr_ta_rh==0 ) {
cout << "[e] For short wave radiation calculation, at least one set of both TA and ILWR are needed at the same station!\n";
throw IOException("Not enough input meteo data", AT);
......@@ -165,7 +165,7 @@ void EnergyBalance::setMeteo(const mio::Grid2DObject& in_ilwr,
// note: parallelization has to take place inside the TerrainRadiationAlgorithm implementations
terrain_radiation->setMeteo(albedo.grid2D, in_ta.grid2D);
terrain_radiation->getRadiation(direct, diffuse, reflected, direct_unshaded_horizontal,
in_ilwr.grid2D,sky_ilwr,terrain_ilwr, solarAzimuth, solarElevation);
in_ilwr.grid2D, sky_ilwr, terrain_ilwr, solarAzimuth, solarElevation);
if (hasSP()){
terrain_radiation->setSP(radfields[0].getDate(), solarAzimuth, solarElevation);
......@@ -193,7 +193,8 @@ void EnergyBalance::setMeteo(const mio::Grid2DObject& in_ilwr,
void EnergyBalance::writeSP(const unsigned int max_steps){
void EnergyBalance::writeSP(const unsigned int max_steps)
if (hasSP()) terrain_radiation->writeSP(max_steps);
......@@ -81,9 +81,9 @@ class EnergyBalance
void setMeteo(const mio::Grid2DObject& in_ilwr,
const mio::Grid2DObject& in_ta, const mio::Grid2DObject& in_rh, const mio::Grid2DObject& in_p, const mio::Date timestamp);
void writeSP(const unsigned int max_steps);
void writeSP(const unsigned int max_steps); //write Solar Panels information
bool hasSP(){return terrain_radiation->hasSP();}
bool hasSP(){return terrain_radiation->hasSP();} //are Solar Panels defined?
void setStations(const std::vector<mio::MeteoData>& in_vecMeteo);
double getTiming() const;
void Destroy();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment