WSL/SLF GitLab Repository

Commit 4f0131ad authored by Mathias Bavay's avatar Mathias Bavay
Browse files

A bug was fixed in SMETIO: when given OLWR, it should have computed TSS, but...

A bug was fixed in SMETIO: when given OLWR, it should have computed TSS, but it was not... (using the wrong MeteoData object).

Documentation and error messages improvements. A new method was added to Atmosphere: virtualTemperatureFactor.
parent 2f7f93e4
......@@ -112,6 +112,11 @@ class BufferedIOHandler : public IOInterface {
#endif
virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
/**
* @brief Returns the average sampling rate in the data.
* This computes the average sampling rate from the data that is contained in the buffer.
* @return average sampling rate in seconds, nodata if the buffer is empty
*/
double getAvgSamplingRate();
friend std::ostream& operator<<(std::ostream& os, const BufferedIOHandler& data);
......
......@@ -151,6 +151,11 @@ class IOManager {
*/
void setMinBufferRequirements(const double& buffer_size, const double& buff_before);
/**
* @brief Returns the average sampling rate in the data.
* This computes the average sampling rate from the data that is contained in the buffer.
* @return average sampling rate in seconds, nodata if the buffer is empty
*/
double getAvgSamplingRate();
#ifdef _POPC_ //HACK popc
......
......@@ -43,6 +43,9 @@ namespace mio {
* HNW::resample = linear
* @endcode
*
* The search window size can be given with key WINDOW_SIZE that expresses (in seconds) how far a valid point can be searched for when
* re-interpolating a missing value (up to WINDOW_SIZE/2 before and after the requested point, ie the search window is centered).
*
* @section algorithms_available Available Resampling Algorithms
* Two algorithms for the resampling are implemented:
* - none: do not perform resampling, see ResamplingAlgorithms::NoResampling
......
......@@ -879,7 +879,7 @@ void SMETReader::read_header(std::ifstream& fin)
void SMETReader::checkSignature(const std::vector<std::string>& vecSignature, bool& isAscii)
{
if ((vecSignature.size() != 3) || (vecSignature[0] != "SMET"))
throw SMETException("The signature of file " + filename + " is invalid", SMET_AT);
throw SMETException("The signature of file " + filename + " is invalid. Is it really a SMET file?", SMET_AT);
std::string version = vecSignature[1];
if ((version != "0.9") && (version != "0.95") && (version != "0.99")
......
......@@ -28,6 +28,7 @@ namespace mio {
* @brief Calculate the black body emissivity
* @param lwr longwave radiation emitted by the body (W m-2)
* @param T surface temperature of the body (K)
* @return black body emissivity (0-1)
*/
double Atmosphere::blkBody_Emissivity(const double& lwr, const double& T) {
const double T2 = T*T;
......@@ -38,6 +39,7 @@ double Atmosphere::blkBody_Emissivity(const double& lwr, const double& T) {
* @brief Calculates the black body long wave radiation knowing its emissivity
* @param ea emissivity of the body (0-1)
* @param T surface temperature of the body (K)
* @return black body radiation (W/m^2)
*/
double Atmosphere::blkBody_Radiation(const double& ea, const double& T) {
const double T2 = T*T;
......@@ -100,7 +102,6 @@ double Atmosphere::wetBulbTemperature(const double& T, const double& RH, const d
return ( T - (RH*Vp - Vp) * mixing_ratio * L / p / Cst::specific_heat_air );
}
/**
* @brief Standard water vapor saturation
* @param T air temperature (K)
......@@ -121,6 +122,19 @@ double Atmosphere::waterSaturationPressure(const double& T) {
return( Cst::p_water_triple_pt * exp( exp_p_sat ) );
}
/**
* @brief Virtual temperature multiplying factor.
* In order to get a virtual temperature, multiply the original temperature by this factor. Note:
* since e/p is actually used, both pressures only need to have the same units.
* @param e vapor pressure (Pa)
* @param p air pressure (Pa)
* @return virtual temperature multiplying coefficient
*/
double Atmosphere::virtualTemperatureFactor(const double& e, const double& p) {
const double epsilon = 0.622;
return 1. / (1.-(1.-epsilon)*e/p);
}
/**
* @brief Evaluate the atmosphere emissivity from the water vapor pressure and cloudiness.
* This is according to A. Omstedt, "A coupled one-dimensional sea ice-ocean model applied to a semi-enclosed basin",
......
......@@ -34,6 +34,7 @@ class Atmosphere {
static double stdAirPressure(const double& altitude);
static double stdDryAirDensity(const double& altitude, const double& temperature);
static double waterSaturationPressure(const double& T);
static double virtualTemperatureFactor(const double& e, const double& p);
static double waterVaporDensity(const double& Temperature, const double& VaporPressure);
static double wetBulbTemperature(const double& T, const double& RH, const double& altitude);
......
......@@ -315,21 +315,20 @@ void SMETIO::copy_data(const smet::SMETReader& myreader,
if ((timestamps.size() == 0) && (!julian_present)) return; //nothing to do
bool olwr_present = md.param_exists("OLWR");
const bool olwr_present = md.param_exists("OLWR");
bool data_wgs84 = myreader.location_in_data(smet::WGS84);
bool data_epsg = myreader.location_in_data(smet::EPSG);
const bool data_wgs84 = myreader.location_in_data(smet::WGS84);
const bool data_epsg = myreader.location_in_data(smet::EPSG);
read_meta_data(myreader, md.meta);
double nodata_value = myreader.get_header_doublevalue("nodata");
const double nodata_value = myreader.get_header_doublevalue("nodata");
double current_timezone = myreader.get_header_doublevalue("tz");
if (current_timezone == nodata_value)
current_timezone = in_dflt_TZ;
const bool timestamp_present = myreader.contains_timestamp();
Date tmp_date;
size_t nr_of_lines = mydata.size() / indexes.size();
bool timestamp_present = myreader.contains_timestamp();
double lat=IOUtils::nodata, lon=IOUtils::nodata, east=IOUtils::nodata, north=IOUtils::nodata, alt=IOUtils::nodata;
size_t current_index = 0; //index to vec_data
......@@ -379,8 +378,9 @@ void SMETIO::copy_data(const smet::SMETReader& myreader,
current_index++;
}
if ((olwr_present) && (md(MeteoData::TSS) == IOUtils::nodata)) //HACK
md(MeteoData::TSS) = olwr_to_tss(md("OLWR"));
if ((olwr_present) && (tmp_md(MeteoData::TSS) == IOUtils::nodata)) {//HACK
tmp_md(MeteoData::TSS) = olwr_to_tss(tmp_md("OLWR"));
}
//cout << tmp_md << endl;
//cout << endl;
......
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