WSL/SLF GitLab Repository

Commit fb2a9daf authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Added a range check on RH before computing the dew point temperature in the RH...

Added a range check on RH before computing the dew point temperature in the RH spatial interpolation method. Renammed and documented the ESOLIP precipitation generator after adding the reference.
parent 0714a71b
......@@ -50,8 +50,8 @@ GeneratorAlgorithm* GeneratorAlgorithmFactory::getAlgorithm(const std::string& i
return new AllSkyLWGenerator(vecArgs, i_algoname);
} else if (algoname == "ALLSKY_SW"){
return new AllSkySWGenerator(vecArgs, i_algoname);
} else if (algoname == "HS_SWE"){
return new HSSweGenerator(vecArgs, i_algoname);
} else if (algoname == "ESOLIP"){
return new ESOLIPGenerator(vecArgs, i_algoname);
} else {
throw IOException("The generator algorithm '"+algoname+"' is not implemented" , AT);
}
......@@ -671,22 +671,22 @@ double AllSkySWGenerator::getSolarIndex(const double& ta, const double& rh, cons
}
const bool HSSweGenerator::soft = true;
void HSSweGenerator::parse_args(const std::vector<std::string>& vecArgs)
const bool ESOLIPGenerator::soft = true;
void ESOLIPGenerator::parse_args(const std::vector<std::string>& vecArgs)
{
if(vecArgs.size()>0) { //incorrect arguments, throw an exception
throw InvalidArgumentException("Wrong number of arguments supplied for the "+algo+" generator", AT);
}
}
bool HSSweGenerator::generate(const size_t& /*param*/, MeteoData& /*md*/)
bool ESOLIPGenerator::generate(const size_t& /*param*/, MeteoData& /*md*/)
{//HACK: modify prototype so we can get the full vector + the index of the replacement
return false; //all missing values could be filled
}
//when we can not guarantee HNW=0, we leave it at nodata. Therefore, it is highly recommended to
//run through a Cst=0 data generator afterward
bool HSSweGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMeteo)
bool ESOLIPGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMeteo)
{
if (param!=MeteoData::HNW)
throw InvalidArgumentException("Trying to use "+algo+" generator on " + MeteoData::getParameterName(param) + " but it can only be applied to HNW!!", AT);
......@@ -728,7 +728,7 @@ bool HSSweGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMe
return all_filled;
}
double HSSweGenerator::newSnowDensity(const MeteoData& md) const
double ESOLIPGenerator::newSnowDensity(const MeteoData& md) const
{ //C. Zwart, "Significance of new-snow properties for snowcover development",
//master's thesis, 2007, Institute for Marine and Atmospheric Research, University of Utrecht, 78 pp.
const double vw = max(2., md(MeteoData::VW));
......
......@@ -78,6 +78,7 @@ namespace mio {
* - CLEARSKY_LW: use a clear sky model to generate ILWR from TA, RH (see ClearSkyLWGenerator)
* - ALLSKY_LW: use an all sky model to generate ILWR from TA, RH and cloudiness (see AllSkyLWGenerator)
* - ALLSKY_SW: generate the incoming short wave radiation from the potential radiation, corrected for cloudiness if possible (see AllSkySWGenerator)
* - ESOLIP: generate precipitation from snow height changes (see ESOLIPGenerator)
*
* @section generators_biblio Bibliography
* The data generators have been inspired by the following papers:
......@@ -95,6 +96,8 @@ namespace mio {
* Downwelling Longwave Radiation"</i>, Journal of Applied Meteorology, <b>38</b>, 1999, pp 474-480
* - Unsworth and Monteith -- <i>"Long-wave radiation at the ground"</i>, Q. J. R. Meteorolo. Soc., Vol. 101, 1975, pp 13-24
* - Meeus -- <i>"Astronomical Algorithms"</i>, second edition, 1998, Willmann-Bell, Inc., Richmond, VA, USA
* - Mair et al. -- <i>" ESOLIP–estimate of solid and liquid precipitation at sub-daily time resolution by combining snow height
* and rain gauge measurements"</i>, Hydrology and Earth System Sciences Discussions, <b>10(7)</b>, 8683-8714, 2013.
*
*
* @author Mathias Bavay
......@@ -381,9 +384,24 @@ class AllSkySWGenerator : public GeneratorAlgorithm {
static const double soil_albedo, snow_albedo, snow_thresh; //to try using rswr if not iswr is given
};
class HSSweGenerator : public GeneratorAlgorithm {
/**
* @class ESOLIPGenerator
* @brief Generate precipitation from changes in snow height.
* This implements the approach laid out in
* Mair et al., <i>" ESOLIP–estimate of solid and liquid precipitation at sub-daily time resolution by combining snow height
* and rain gauge measurements"</i>, Hydrology and Earth System Sciences Discussions, <b>10(7)</b>, 8683-8714, 2013.
* The snow density relies on Zwart, <i>"Significance of new-snow properties for snowcover development"</i>,master's thesis,
* Institute for Marine and Atmospheric Research, University of Utrecht, 78 pp, 2007.
*
* @note only identified precipitation events are written out, this means that it is recommended to run through a Cst=0 data generator afterward
*
* @code
* HNW::generators = ESOLIP
* @endcode
*/
class ESOLIPGenerator : public GeneratorAlgorithm {
public:
HSSweGenerator(const std::vector<std::string>& vecArgs, const std::string& i_algo)
ESOLIPGenerator(const std::vector<std::string>& vecArgs, const std::string& i_algo)
: GeneratorAlgorithm(vecArgs, i_algo) { parse_args(vecArgs); }
bool generate(const size_t& param, MeteoData& md);
bool generate(const size_t& param, std::vector<MeteoData>& vecMeteo);
......
......@@ -511,7 +511,13 @@ void RHAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
//Compute dew point temperatures at stations
std::vector<double> vecTd(vecDataRH.size());
for (size_t ii=0; ii<vecDataRH.size(); ii++){
vecTd[ii] = Atmosphere::RhtoDewPoint(vecDataRH[ii], vecDataTA[ii], 1);
const double rh = vecDataRH[ii];
if (rh<0. || rh>1.) {
ostringstream ss;
ss << "Invalid relative humidity: " << rh << " on " << date.toString(Date::ISO) << "\n";
throw InvalidArgumentException(ss.str(), AT);
}
vecTd[ii] = Atmosphere::RhtoDewPoint(rh, vecDataTA[ii], 1);
}
Fit1D trend;
......
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