WSL/SLF GitLab Repository

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

The Karsten method for converting cloud cover (in okta) to clearness index has...

The Karsten method for converting cloud cover (in okta) to clearness index has been implemented and is also available as a data generator (looking for a "CLD" parameter to use as cloud cover data)
parent 27134eba
......@@ -40,6 +40,8 @@ GeneratorAlgorithm* GeneratorAlgorithmFactory::getAlgorithm(const std::string& i
return new StandardPressureGenerator(vecArgs, i_algoname);
} else if (algoname == "RELHUM"){
return new RhGenerator(vecArgs, i_algoname);
} else if (algoname == "TAU_CLD"){
return new TauCLDGenerator(vecArgs, i_algoname);
} else if (algoname == "TS_OLWR"){
return new TsGenerator(vecArgs, i_algoname);
} else if (algoname == "ISWR_ALBEDO"){
......@@ -254,6 +256,36 @@ bool RhGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMeteo
}
bool TauCLDGenerator::generate(const size_t& param, MeteoData& md)
{
double &value = md(param);
if (value == IOUtils::nodata) {
if (md.param_exists("CLD")) {
const double cld = md("CLD");
if (cld==IOUtils::nodata) return false;
value = Atmosphere::Kasten_clearness( cld );
}
if (value==IOUtils::nodata) return false;
}
return true; //all missing values could be filled
}
bool TauCLDGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMeteo)
{
if (vecMeteo.empty()) return true;
bool status = true;
for (size_t ii=0; ii<vecMeteo.size(); ii++) {
if (!generate(param, vecMeteo[ii]))
status = false;
}
return status;
}
const double TsGenerator::e_snow = .983; //snow emissivity (0.969 - 0.997)
const double TsGenerator::e_soil = .9805; //grass emissivity (0.975 - 0.986)
const double TsGenerator::snow_thresh = .1; //if snow height greater than this threshold -> snow albedo
......
......@@ -217,6 +217,24 @@ class RhGenerator : public GeneratorAlgorithm {
bool generate(const size_t& param, std::vector<MeteoData>& vecMeteo);
};
/**
* @class TauCLDGenerator
* @brief Atmospheric transmissivity generator.
* Generate the atmospheric transmissivity (or clearness index) from other parameters.
* Right now, it only looks for a "CLD" parameter that should be the cloud cover / cloudiness (in okta but brought back between
* 0 and 1) and converts it into a clearness index.
* @code
* TAU_CLD::generators = TAU_CLD
* @endcode
*/
class TauCLDGenerator : public GeneratorAlgorithm {
public:
TauCLDGenerator(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);
};
/**
* @class TsGenerator
* @brief Surface temperature generator.
......
......@@ -17,6 +17,7 @@
*/
#include <assert.h>
#include <sstream>
#include <cmath>
#include <meteoio/meteoLaws/Atmosphere.h>
#include <meteoio/meteoLaws/Meteoconst.h>
......@@ -520,6 +521,26 @@ double Atmosphere::Konzelmann_ilwr(const double& RH, const double& TA, const dou
return blkBody_Radiation(ea, TA);
}
/**
* @brief Evaluate the solar clearness index for a given cloudiness.
* This uses the formula from Kasten and Czeplak -- <i>"Solar and terrestrial radiation
* dependent on the amount and type of cloud"</i>, Sol. Energy, <b>24</b>, 1980, pp 177-189.
* The solar index is defined as measured radiation / clear sky radiation, values
* outside of [0;1] will be truncated to [0;1].
* @param cloudiness in okta, between 0 and 1
* @return solar clearness index
*/
double Atmosphere::Kasten_clearness(const double& cloudiness) {
const double b1 = 0.75, b2 = 3.4;
if (cloudiness<0. || cloudiness>1.) {
std::ostringstream ss;
ss << "Invalid cloudiness value: " << cloudiness << " (it should be between 0 and 1)";
throw InvalidArgumentException(ss.str(), AT);
}
const double clearness = 1. - b1*pow(cloudiness, b2);
return clearness;
}
/**
* @brief Evaluate the cloudiness from a given solar index.
* This uses the formula from Kasten and Czeplak -- <i>"Solar and terrestrial radiation
......@@ -527,7 +548,7 @@ double Atmosphere::Konzelmann_ilwr(const double& RH, const double& TA, const dou
* The solar index is defined as measured radiation / clear sky radiation, values
* outside of [0;1] will be truncated to [0;1].
* @param solarIndex solar index
* @return cloudiness (between 0 and 1)
* @return cloudiness (in okta, between 0 and 1)
*/
double Atmosphere::Kasten_cloudiness(const double& solarIndex) {
const double b1 = 0.75, b2 = 3.4;
......
......@@ -73,6 +73,7 @@ class Atmosphere {
static double Unsworth_ilwr(const double& lat, const double& lon, const double& altitude,
const double& julian, const double& TZ,
const double& RH, const double& TA, const double& ISWR, const double& cloudiness=IOUtils::nodata);
static double Kasten_clearness(const double& cloudiness);
static double Kasten_cloudiness(const double& solarIndex);
static double ILWR_parametrized(const double& lat, const double& lon, const double& altitude,
const double& julian, const double& TZ,
......
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