WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
976e9e31
Commit
976e9e31
authored
May 19, 2014
by
Mathias Bavay
Browse files
Implementing a workaround for Mingw bug 2152 and better documentation for the Sun class
parent
810ce347
Changes
3
Hide whitespace changes
Inline
Side-by-side
meteoio/Date.cc
View file @
976e9e31
...
...
@@ -30,6 +30,20 @@ using namespace std;
namespace
mio
{
#ifdef MINGW
//some version of MINGW have a buggy 64 bits implementation of difftime
//this is Mingw bug 2152
static
__inline__
double
difftime
(
time_t
__t1
,
time_t
__t0
)
{
if
(
sizeof
(
time_t
)
==
8
)
{
//time_t is 64 bits
return
(
double
)((
long
double
)(
__t1
)
-
(
long
double
)(
__t0
));
}
else
{
//return (double)((__int64)(__t1) - (__int64)(__t0));
return
(
double
)
__t1
-
(
double
)
__t0
;
}
}
#endif
const
int
Date
::
daysLeapYear
[
12
]
=
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
const
int
Date
::
daysNonLeapYear
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
const
double
Date
::
DST_shift
=
1.0
;
//in hours
...
...
@@ -105,15 +119,14 @@ void Date::setUndef(const bool& flag) {
* @brief Set internal gmt time from system time as well as system time zone.
*/
void
Date
::
setFromSys
()
{
/*const time_t curr = time(NULL); //current time in UTC
tm local = *localtime(&curr); //convert to local time
const double tz = (double)local.tm_gmtoff/3600.; //time zone shift*/
const
time_t
curr
=
time
(
NULL
);
// current time in UTC
tm
local
=
*
gmtime
(
&
curr
);
// current time in UTC, stored as tm
const
time_t
utc
=
(
mktime
(
&
local
));
// convert GMT tm to GMT time_t
const
time_t
utc
=
mktime
(
&
local
);
// convert GMT tm to GMT time_t
#ifndef MINGW
double
tz
=
-
difftime
(
utc
,
curr
)
/
3600.
;
//time zone shift (sign so that if curr>utc, tz>0)
#else //workaround for Mingw bug 2152
double
tz
=
-
mio
::
difftime
(
utc
,
curr
)
/
3600.
;
//time zone shift (sign so that if curr>utc, tz>0)
#endif
setDate
(
curr
);
//Unix time_t setter, always in gmt
setTimeZone
(
tz
);
}
...
...
meteoio/meteolaws/Sun.cc
View file @
976e9e31
...
...
@@ -137,7 +137,7 @@ void SunObject::getClearSky(const double& sun_elevation, const double& R_toa,
const
double
&
ta
,
const
double
&
rh
,
const
double
&
pressure
,
const
double
&
ground_albedo
,
double
&
R_direct
,
double
&
R_diffuse
)
const
{
//these pow cost us a lot here, but replacing them by fastPow() has a large impact o accuracy (because of the exp())
//these pow cost us a lot here, but replacing them by fastPow() has a large impact o
n
accuracy (because of the exp())
const
double
olt
=
0.32
;
//ozone layer thickness (cm) U.S.standard = 0.34 cm
const
double
w0
=
0.9
;
//fraction of energy scattered to total attenuation by aerosols (Bird and Hulstrom(1981))
const
double
fc
=
0.84
;
//fraction of forward scattering to total scattering (Bird and Hulstrom(1981))
...
...
meteoio/meteolaws/Sun.h
View file @
976e9e31
...
...
@@ -30,8 +30,10 @@ namespace mio {
/**
* @class SunObject
* @brief A class to calculate Sun's characteristics
*
* @brief A class to calculate Solar radiation characteristics
* This is largely based on M. Iqbal, <i>"An introduction to solar radiation"</i>, 1983, Academic Press, ISBN: 0-12-373750-8.
* The Sun's position is provided by the SunTrajectory class (currently the only implemented algorithm is Meeus).
* All units are SI. See http://www.meteoexploration.com/products/solarcalc.php for a validation calculator.
* @ingroup meteolaws
* @author Mathias Bavay
* @date 2010-06-10
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment