WSL/SLF GitLab Repository

Commit 37bfdf83 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Several HACKS have been removed (either the HACK had been fixed but the...

Several HACKS have been removed (either the HACK had been fixed but the comment was still there, or it has now been fixed, or after more (careful) consideration, it has been decided that the HACK was not a HACK)
parent 1bcad13b
......@@ -352,24 +352,19 @@ double Date::getTruncatedJulianDate(const bool& gmt) const {
/**
* @brief Return Unix time (or POSIX time).
* The Unix time is defined as the number of seconds since 1970-01-01T00:00 UTC (Unix Epoch).
* It is therefore ALWAYS in GMT.
* (defined as IEEE P1003.1 POSIX. See http://www.mail-archive.com/leapsecs@rom.usno.navy.mil/msg00109.html
* for some technical, historical and funny insight into the standardization process)
* @param gmt convert returned value to GMT? (default: false)
* @return Unix time in the current timezone / in GMT depending on the gmt parameter
*/
time_t Date::getUnixDate(const bool& gmt) const { //HACK: should Unix date always be GMT?
time_t Date::getUnixDate() const {
if(undef==true)
throw UnknownValueException("Date object is undefined!", AT);
if (gmt_julian < Unix_offset)
throw IOException("Dates before 1970 cannot be displayed in Unix epoch time", AT);
throw IOException("Dates before 1970 cannot be displayed in Unix epoch time", AT);
if(gmt) {
return ( (time_t)floor( (gmt_julian - Unix_offset) * (24*60*60) ));
} else {
const double local_julian = GMTToLocal(gmt_julian);
return ( (time_t)floor( (local_julian - Unix_offset) * (24*60*60) ));
}
return ( (time_t)floor( (gmt_julian - Unix_offset) * (24*60*60) ));
}
/**
......
......@@ -115,7 +115,7 @@ class Date {
double getJulianDate(const bool& gmt=false) const;
double getModifiedJulianDate(const bool& gmt=false) const;
double getTruncatedJulianDate(const bool& gmt=false) const;
time_t getUnixDate(const bool& gmt=false) const;
time_t getUnixDate() const;
double getExcelDate(const bool& gmt=false) const;
double getMatlabDate(const bool& gmt=false) const;
......
......@@ -140,7 +140,6 @@ bool Grid2DObject::grid_to_WGS84(Coords& point) const {
point.copyProj(tmp_proj); //back to the original projection -> reproject the coordinates
}
//HACK: when calling setXY, we reset i,j to nodata
point.setGridIndex(i, j, IOUtils::unodata, false);
return true;
}
......
......@@ -55,9 +55,9 @@ double Atmosphere::stdAirPressure(const double& altitude) {
const double sea_level_temp = 288.15; // K
const double expo = Cst::gravity / (lapse_rate * Cst::gaz_constant_dry_air);
const double R0 = Cst::earth_R0; // Earth's radius in m
const double p = p0 * pow( 1. - ( (lapse_rate * R0 * altitude) / (sea_level_temp * (R0 + altitude)) ), expo );
return(p);
}
......@@ -82,7 +82,7 @@ double Atmosphere::waterVaporDensity(const double& Temperature, const double& Va
}
/**
* @brief Standard atmosphere wet bulb temperature.
* @brief Standard atmosphere wet bulb temperature.
* This gives the lowest temperature that could be reached by water evaporation. It is therefore linked to
* relative humidity. This implementation assumes a standard atmosphere for pressure and saturation pressure.
* @param T air temperature (K)
......@@ -138,14 +138,14 @@ double Atmosphere::Omstedt_emissivity(const double& RH, const double& TA, const
const double a3 = 0.18;
const double ea = (eps_w * (a1 + a2 * sqrt(e0)) * (1. + a3 * cloudiness * cloudiness)); //emissivity
if(ea > 1.0)
if(ea > 1.0)
return 1.0;
return ea;
}
/**
* @brief Evaluate the long wave radiation from RH, TA and cloudiness.
* @brief Evaluate the long wave radiation from RH, TA and cloudiness.
* This is according to A. Omstedt, "A coupled one-dimensional sea ice-ocean model applied to a semi-enclosed basin",
* Tellus, 42 A, 568-582, 1990, DOI:10.1034/j.1600-0870.1990.t01-3-00007.
* @param RH relative humidity (between 0 and 1)
......@@ -159,7 +159,7 @@ double Atmosphere::Omstedt_ilwr(const double& RH, const double& TA, const double
}
/**
* @brief Evaluate the atmosphere emissivity for clear sky.
* @brief Evaluate the atmosphere emissivity for clear sky.
* This uses the formula from Brutsaert -- "On a Derivable
* Formula for Long-Wave Radiation From Clear Skies", Journal of Water Resources
* Research, Vol. 11, No. 5, October 1975, pp 742-744.
......@@ -177,7 +177,7 @@ double Atmosphere::Brutsaert_emissivity(const double& RH, const double& TA) {
}
/**
* @brief Evaluate the long wave radiation for clear sky.
* @brief Evaluate the long wave radiation for clear sky.
* This uses the formula from Brutsaert -- "On a Derivable
* Formula for Long-Wave Radiation From Clear Skies", Journal of Water Resources
* Research, Vol. 11, No. 5, October 1975, pp 742-744.
......@@ -192,7 +192,7 @@ double Atmosphere::Brutsaert_ilwr(const double& RH, const double& TA) {
}
/**
* @brief Convert a relative humidity to a dew point temperature.
* @brief Convert a relative humidity to a dew point temperature.
* @param RH relative humidity between 0 and 1
* @param TA air temperature (K)
* @param force_water if set to true, compute over water. Otherwise, a smooth transition between over ice and over water is computed.
......@@ -238,7 +238,7 @@ double Atmosphere::RhtoDewPoint(double RH, double TA, const bool& force_water)
}
/**
* @brief Convert a dew point temperature to a relative humidity.
* @brief Convert a dew point temperature to a relative humidity.
* @param TD dew point temperature (K)
* @param TA air temperature (K)
* @param force_water if set to true, compute over water. Otherwise, a smooth transition between over ice and over water is computed.
......@@ -299,22 +299,23 @@ double Atmosphere::DewPointtoRh(double TD, double TA, const bool& force_water)
}
/**
* @brief Calculate the relative Humidity (RH) from specific humidity.
* @brief Calculate the relative Humidity (RH) from specific humidity.
* @param altitude altitude over sea level (m)
* @param TA air temperature (K)
* @param qi specific humidity
* @param qi specific humidity
* @return relative humidity between 0 and 1
*/
double Atmosphere::specToRelHumidity(const double& altitude, const double& TA, const double& qi)
{//HACK: should we check that RH in [0;1]?
{
const double SatVaporDensity = waterVaporDensity(TA, waterSaturationPressure(TA));
const double RH = (qi/(1.-qi))*stdDryAirDensity(altitude, TA)/SatVaporDensity;
return RH;
if(RH>1.) return 1.;
else return RH;
}
/**
* @brief Calculate the specific Humidity from relative humidity (RH).
* @brief Calculate the specific Humidity from relative humidity (RH).
* @param altitude altitude over sea level (m)
* @param TA air temperature (K)
* @param RH relative humidity (between 0 and 1)
......
......@@ -69,7 +69,6 @@ class SunObject {
friend std::ostream& operator<<(std::ostream& os, const SunObject& data);
private:
void update();
double lw_SaturationPressure(const double& T); //HACK: remove it in final library to use the meteolaws version of it
void getBeamPotential(const double& sun_elevation, const double& Eccentricity_corr,
const double& ta, const double& rh, const double& pressure, const double& mean_albedo,
double& R_toa, double& R_direct, double& R_diffuse);
......
......@@ -250,7 +250,7 @@ void SunMeeus::getEquatorialSunVector(double& sunx, double& suny, double& sunz)
double azi_Sacw;
// Convert to angle measured from South, counterclockwise (rad)
if ( SolarAzimuthAngle <= 90. ) { //HACK: to check!
if ( SolarAzimuthAngle <= 90. ) {
azi_Sacw = M_PI - SolarAzimuthAngle*to_rad;
} else {
azi_Sacw = 3.*M_PI - SolarAzimuthAngle*to_rad;
......
......@@ -38,8 +38,6 @@ namespace mio {
class SunTrajectory {
public:
SunTrajectory() {};
/*SunTrajectory(const double& _latitude, const double& _longitude) {};
SunTrajectory(const double& _latitude, const double& _longitude, const double& _julian, const double& TZ=0.) {};*/ //HACK!!!!
virtual ~SunTrajectory() {};
/** @brief Set the date and time
......
......@@ -89,8 +89,6 @@ class Quadratic : public FitLeastSquare {
double f(const double& x);
};
//HACK: write copy constructor for Fit1D!!! needed to pass a Fit1D object by copy
/**
* @class Fit1D
* @brief A class to perform 1D regressions
......
......@@ -346,7 +346,6 @@ void ARPSIO::readGridLayer(const std::string& parameter, const unsigned int& lay
}
}
//HACK TODO swap ix/iy (for speed) and number cells from llcorner (cf ARCIO)
//read the data we are interested in
for (unsigned int ix = 0; ix < dimx; ix++) {
for (unsigned int iy = 0; iy < dimy; iy++) {
......
......@@ -26,7 +26,7 @@ namespace mio {
/**
* @page imis IMIS
* @section imis_format Format
* This plugin reads data directly from the IMIS network database (Oracle database).
* This plugin reads data directly from the IMIS network database (Oracle database).
* It retrieves standard IMIS data as well as ENETZ and ANETZ data.
*
* @section imis_units Units
......@@ -319,7 +319,7 @@ void ImisIO::readStationMetaData(oracle::occi::Connection*& conn)
IOUtils::convertString(north, stationMetaData.at(2), std::dec);
IOUtils::convertString(alt, stationMetaData.at(3), std::dec);
// HACK to obtain a valid station_name w/o spaces within
//obtain a valid station_name w/o spaces within
if (station_name == "") {
if (stao_name != "") {
station_name += vecStationID[ii] + ":" + stao_name;
......@@ -470,7 +470,7 @@ void ImisIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
closeDBConnection(env, conn);
} catch (exception& e){
closeDBConnection(env, conn);
closeDBConnection(env, conn);
throw IOException("Oracle Error: " + string(e.what()), AT); //Translation of OCCI exception to IOException
}
}
......@@ -496,10 +496,10 @@ void ImisIO::assimilateAnetzData(const Date& dateStart, const AnetzData& ad,
}
if (counter >= current_station_psum.size()) { break; } //should never happen
//cout << "Current slice date: " << current_slice_date.toString(Date::ISO)
//cout << "Current slice date: " << current_slice_date.toString(Date::ISO)
// << " value: " << current_station_psum.at(counter) << endl;
double& hnw = vecMeteo[stationindex][jj].hnw;
//cout << vecMeteo[stationindex][jj].date.toString(Date::ISO) << ": " << hnw;
if ((hnw == IOUtils::nodata) || (IOUtils::checkEpsilonEquality(hnw, 0.0, 0.001))){
......@@ -526,7 +526,7 @@ void ImisIO::getAnetzHNW(const AnetzData& ad, const std::map<std::string, unsign
for (unsigned int kk=0; kk<vec_of_psums.at(vecIndex.at(0)).size(); kk++){
double sum = 0.0;
for (unsigned int ii=0; ii<ad.nrOfCoefficients; ii++){
sum += ad.coeffs[ii] * vec_of_psums.at(vecIndex[ii])[kk];
sum += ad.coeffs[ii] * vec_of_psums.at(vecIndex[ii])[kk];
}
psum.push_back(sum/12.0);
......@@ -681,7 +681,7 @@ void ImisIO::readData(const Date& dateStart, const Date& dateEnd, std::vector< s
tmpmd.hnw /= 2; //half hour accumulated value for IMIS stations only
}
vecMeteo.at(stationindex).push_back(tmpmd); //Now insert tmpmd
vecMeteo.at(stationindex).push_back(tmpmd); //Now insert tmpmd
}
}
......@@ -795,7 +795,7 @@ unsigned int ImisIO::getSensorDepths(const std::string& stat_abk, const std::str
try {
Statement *stmt = conn->createStatement(sqlQuery);
ResultSet *rs = NULL;
stmt->setString(1, stat_abk); // set 1st variable's value
stmt->setString(2, stao_nr); // set 2nd variable's value
......
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