WSL/SLF GitLab Repository

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

Micro optimizations for Sun.cc, converted an exception into a warning in...

Micro optimizations for Sun.cc, converted an exception into a warning in ImisIO and fixing case in message in Smetio
parent 22f58077
......@@ -22,6 +22,7 @@
#include <meteoio/meteoLaws/Sun.h>
#include <meteoio/meteoLaws/Atmosphere.h>
#include <meteoio/meteoLaws/Meteoconst.h>
#include <meteoio/MathOptim.h>
namespace mio {
......@@ -149,8 +150,8 @@ void SunObject::getClearSky(const double& sun_elevation, const double& R_toa,
// relative optical air mass Young (1994), see http://en.wikipedia.org/wiki/Airmass
//const double mr = 1. / (cos_zenith + 0.50572 * pow( 96.07995-zenith , -1.6364 )); //pbl: this should use apparent zenith angle, and we only get true zenith angle here...
// relative optical air mass, Young, A. T. 1994. Air mass and refraction. Applied Optics. 33:1108–1110.
const double mr = ( 1.002432*cos_zenith*cos_zenith + 0.148386*cos_zenith + 0.0096467) /
( cos_zenith*cos_zenith*cos_zenith + 0.149864*cos_zenith*cos_zenith
const double mr = ( 1.002432*Optim::pow2(cos_zenith) + 0.148386*cos_zenith + 0.0096467) /
( Optim::pow3(cos_zenith) + 0.149864*Optim::pow2(cos_zenith)
+ 0.0102963*cos_zenith +0.000303978);
// actual air mass: because mr is applicable for standard pressure
......@@ -168,7 +169,7 @@ void SunObject::getClearSky(const double& sun_elevation, const double& R_toa,
// broadband transmittance by ozone (Iqbal (1983), p.189)
const double u3 = olt * mr; // ozone relative optical path length
const double alpha_oz = 0.1611 * u3 * pow(1. + 139.48 * u3, -0.3035) -
0.002715 * u3 / ( 1. + 0.044 * u3 + 0.0003 * u3 * u3); //ozone absorbance
0.002715 * u3 / ( 1. + 0.044 * u3 + 0.0003 * Optim::pow2(u3) ); //ozone absorbance
const double tauoz = 1. - alpha_oz;
// broadband transmittance by uniformly mixed gases (Iqbal (1983), p.189)
......
......@@ -285,9 +285,7 @@ void ImisIO::readStationData(const Date&, std::vector<StationData>& vecStation)
try {
openDBConnection(env, conn);
readStationMetaData(conn); //reads all the station meta data into the vecStationMetaData (member vector)
closeDBConnection(env, conn);
} catch (const exception& e){
closeDBConnection(env, conn);
......@@ -307,7 +305,6 @@ void ImisIO::readStationMetaData(oracle::occi::Connection*& conn)
vector<string> vecStationID;
readStationIDs(vecStationID);
Statement *stmt = conn->createStatement();
for (size_t ii=0; ii<vecStationID.size(); ii++) {
// Retrieve the station IDs - this only needs to be done once per instance
......@@ -320,11 +317,10 @@ void ImisIO::readStationMetaData(oracle::occi::Connection*& conn)
IOUtils::convertString(drift_stat_abk, stnIDs.at(1));
IOUtils::convertString(drift_stao_nr, stnIDs.at(2));
const string drift_stationID = drift_stat_abk + drift_stao_nr;
if (!drift_stationID.empty()) {
if (!drift_stationID.empty())
mapDriftStation[vecStationID[ii]] = drift_stationID;
} else {
throw ConversionFailedException("Error! No drift station for station "+stat_abk+stao_nr, AT);
}
else
std::cerr << "[W] No drift station for station " << stat_abk << stao_nr << "\n";
// Retrieve the station meta data - this only needs to be done once per instance
vector<string> stationMetaData;
......
......@@ -644,7 +644,7 @@ size_t SMETIO::getNrOfParameters(const std::string& stationname, const std::vect
actual_nr_of_parameters = current_size;
} else if (actual_nr_of_parameters != current_size){
//There is an inconsistency in the fields, print out a warning and proceed
cerr << "[w] While writing SMET file: Inconsistency in number of meteo "
cerr << "[W] While writing SMET file: Inconsistency in number of meteo "
<< "parameters for station " << stationname << endl;
actual_nr_of_parameters = MeteoData::nrOfParameters;
break;
......
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