WSL/SLF GitLab Repository

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

The POT_RADIATION generator has been renamed as ALLSKY_SW for consistency and...

The POT_RADIATION generator has been renamed as ALLSKY_SW for consistency and its documentation updated. The ALLSKY_LW generator's documentation has also been updated.

A getHash() method has been added to the StationData. It is currently quite unsophisticated but should do the job. A better error message has been found for the "frac" lapse rates that can lead to a zero lapse rate (this is the case when there is no precipitation, for example). 
parent d338b905
......@@ -46,8 +46,8 @@ GeneratorAlgorithm* GeneratorAlgorithmFactory::getAlgorithm(const std::string& i
return new ClearSkyLWGenerator(vecArgs, i_algoname);
} else if (algoname == "ALLSKY_LW"){
return new AllSkyLWGenerator(vecArgs, i_algoname);
} else if (algoname == "POT_RADIATION"){
return new PotRadGenerator(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 {
......@@ -490,10 +490,10 @@ bool AllSkyLWGenerator::generate(const size_t& param, std::vector<MeteoData>& ve
}
const double PotRadGenerator::soil_albedo = .23; //grass
const double PotRadGenerator::snow_albedo = .85; //snow
const double PotRadGenerator::snow_thresh = .1; //if snow height greater than this threshold -> snow albedo
void PotRadGenerator::parse_args(const std::vector<std::string>& vecArgs)
const double AllSkySWGenerator::soil_albedo = .23; //grass
const double AllSkySWGenerator::snow_albedo = .85; //snow
const double AllSkySWGenerator::snow_thresh = .1; //if snow height greater than this threshold -> snow albedo
void AllSkySWGenerator::parse_args(const std::vector<std::string>& vecArgs)
{
//Get the optional arguments for the algorithm: constant value to use
if(!vecArgs.empty()) { //incorrect arguments, throw an exception
......@@ -501,7 +501,7 @@ void PotRadGenerator::parse_args(const std::vector<std::string>& vecArgs)
}
}
bool PotRadGenerator::generate(const size_t& param, MeteoData& md)
bool AllSkySWGenerator::generate(const size_t& param, MeteoData& md)
{
double &value = md(param);
if(value == IOUtils::nodata) {
......@@ -551,7 +551,7 @@ bool PotRadGenerator::generate(const size_t& param, MeteoData& md)
return true; //all missing values could be filled
}
bool PotRadGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMeteo)
bool AllSkySWGenerator::generate(const size_t& param, std::vector<MeteoData>& vecMeteo)
{
if(vecMeteo.empty()) return true;
......@@ -606,7 +606,7 @@ bool PotRadGenerator::generate(const size_t& param, std::vector<MeteoData>& vecM
return all_filled;
}
double PotRadGenerator::getSolarIndex(const double& ta, const double& rh, const double& ilwr)
double AllSkySWGenerator::getSolarIndex(const double& ta, const double& rh, const double& ilwr)
{// this is based on Kartsen cloudiness, Dilley clear sky emissivity and Unsworth ILWR
//this means that this solar index is the ratio of iswr for clear sky on a horizontal
//surface and the measured iswr
......
......@@ -76,7 +76,7 @@ namespace mio {
* - SIN: sinusoidal variation (see SinGenerator)
* - 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)
* - POT_RADIATION: generate the potential incoming short wave radiation, corrected for cloudiness if possible (see PotRadGenerator)
* - ALLSKY_SW: generate the incoming short wave radiation from the potential radiation, corrected for cloudiness if possible (see AllSkySWGenerator)
*
* @section generators_biblio Bibliography
* The data generators have been inspired by the following papers:
......@@ -273,7 +273,7 @@ class ClearSkyLWGenerator : public GeneratorAlgorithm {
/**
* @class AllSkyLWGenerator
* @brief ILWR all sky parametrization
* Using air temperature (TA) and relative humidity (RH) and optionnally cloud fraction (TAU_CLD, but please note that this name is not definitive yet),
* Using air temperature (TA) and relative humidity (RH) and optionnally cloud transmissivity (TAU_CLD),
* this offers the choice of several all-sky parametrizations:
* - OMSTEDT -- from Omstedt, <i>"A coupled one-dimensional sea ice-ocean model applied to a semi-enclosed basin"</i>,
* Tellus, <b>42 A</b>, 568-582, 1990, DOI:10.1034/j.1600-0870.1990.t01-3-00007.
......@@ -284,10 +284,10 @@ class ClearSkyLWGenerator : public GeneratorAlgorithm {
* - CRAWFORD -- from Crawford and Duchon, <i>"An Improved Parametrization for Estimating Effective Atmospheric Emissivity for Use in Calculating Daytime
* Downwelling Longwave Radiation"</i>, Journal of Applied Meteorology, <b>38</b>, 1999, pp 474-480
*
* If no cloudiness is provided in the data, it is calculated from the solar index (ratio of measured iswr to potential iswr, therefore using
* If no cloud transmissivity is provided in the data, it is calculated from the solar index (ratio of measured iswr to potential iswr, therefore using
* the current location (lat, lon, altitude) and ISWR to parametrize the cloud cover). This relies on (Kasten and Czeplak, 1980)
* except for Crawfor that provides its own parametrization.
* The last evaluation of cloudiness is used all along during the times when no ISWR is available if such ratio
* The last evaluation of cloud transmissivity is used all along during the times when no ISWR is available if such ratio
* is not too old (ie. no more than 1 day old).
* If only RSWR is measured, the measured snow height is used to determine if there is snow on the ground or not.
* In case of snow, a snow albedo of 0.85 is used while in the abscence of snow, a grass albedo of 0.23 is used
......@@ -331,22 +331,25 @@ class AllSkyLWGenerator : public GeneratorAlgorithm {
};
/**
* @class PotRadGenerator
* @brief potential ISWR parametrization
* This computes the potential incoming solar radiation, based on the position of the sun ine the sky
* @class AllSkySWGenerator
* @brief ISWR all sky parametrization
*
* Using air temperature (TA) and relative humidity (RH) and optionnally cloud transmissivity (TAU_CLD),
* This computes the potential incoming solar radiation, based on the position of the sun in the sky
* (as a function of the location and the date). Please note that although this is the radiation as perceived
* at ground level (on the horizontal). If an incoming long wave measurement is available, it corrects the
* generated iswr for cloudiness (basically doing like UnsworthGenerator in reverse), otherwise this assumes
* clear sky! If no TA or RH is available, average values will be used (in order to get an average value
* at ground level (on the horizontal). If a cloud transmissivity (TAU_CLD) has been provided, or if an
* incoming long wave measurement is available, it corrects the generated iswr for cloudiness
* (basically doing like UnsworthGenerator in reverse), otherwise this assumes clear sky!
* If no TA or RH is available, average values will be used (in order to get an average value
* for the precipitable water vapor).
* @note This relies on SunObject to perform the heavy duty computation.
* @code
* ISWR::generators = POT_RADIATION
* ISWR::generators = allsky_SW
* @endcode
*/
class PotRadGenerator : public GeneratorAlgorithm {
class AllSkySWGenerator : public GeneratorAlgorithm {
public:
PotRadGenerator(const std::vector<std::string>& vecArgs, const std::string& i_algo)
AllSkySWGenerator(const std::vector<std::string>& vecArgs, const std::string& i_algo)
: GeneratorAlgorithm(vecArgs, i_algo), sun() { parse_args(vecArgs); }
bool generate(const size_t& param, MeteoData& md);
bool generate(const size_t& param, std::vector<MeteoData>& vecMeteo);
......
......@@ -174,6 +174,7 @@ void InterpolationAlgorithm::getTrend(const std::vector<double>& vecAltitudes, c
const double avgData = Interpol1D::arithmeticMean(vecDat);
trend.setLapseRate(lapse_rate*avgData);
status = trend.fit();
if (lapse_rate*avgData==0.) status += " (null average input for frac lapse rate)";
} else {
throw InvalidArgumentException("Unknown argument \""+extraArg+"\" supplied for the "+algo+" algorithm", AT);
}
......
......@@ -93,6 +93,10 @@ std::string StationData::getStationName() const {
return stationName;
}
std::string StationData::getHash() const {
return stationID+"::"+stationName;
}
double StationData::getSlopeAngle() const {
return slope;
}
......
......@@ -57,6 +57,7 @@ class StationData {
std::string getStationID() const;
std::string getStationName() const;
Coords getPosition() const;
std::string getHash() const;
/**
* @brief Get local slope angle
......
......@@ -151,7 +151,7 @@ bool SimpleLinear::fit()
} else {
a=0.;
b=0.;
ss << mesg << "Computed regression with " << regname << " model (no regression for null lapse rate)";
ss << mesg << "Computed regression with " << regname << " model";
}
}
Lambda.push_back(a);
......@@ -183,7 +183,7 @@ bool NoisyLinear::fit()
} else {
a=0.;
b=0.;
ss << mesg << "Computed regression with " << regname << " model (no regression for null lapse rate)";
ss << mesg << "Computed regression with " << regname << " model";
}
}
Lambda.push_back(a);
......
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