Module Sun :: Class Sun
[hide private]
[frames] | no frames]

Class Sun

source code

Instance Methods [hide private]
 
__init__(self) source code
 
daysSince2000Jan0(self, y, m, d)
A macro to compute the number of days elapsed since 2000 Jan 0.0 (which is equal to 1999 Dec 31, 0h UT)
source code
 
sind(self, x)
Returns the sin in degrees
source code
 
cosd(self, x)
Returns the cos in degrees
source code
 
tand(self, x)
Returns the tan in degrees
source code
 
atand(self, x)
Returns the arc tan in degrees
source code
 
asind(self, x)
Returns the arc sin in degrees
source code
 
acosd(self, x)
Returns the arc cos in degrees
source code
 
atan2d(self, y, x)
Returns the atan2 in degrees
source code
 
dayLength(self, year, month, day, lon, lat)
This macro computes the length of the day, from sunrise to sunset.
source code
 
dayCivilTwilightLength(self, year, month, day, lon, lat)
This macro computes the length of the day, including civil twilight.
source code
 
dayNauticalTwilightLength(self, year, month, day, lon, lat)
This macro computes the length of the day, incl.
source code
 
dayAstronomicalTwilightLength(self, year, month, day, lon, lat)
This macro computes the length of the day, incl.
source code
 
sunRiseSet(self, year, month, day, lon, lat)
This macro computes times for sunrise/sunset.
source code
 
civilTwilight(self, year, month, day, lon, lat)
This macro computes the start and end times of civil twilight.
source code
 
nauticalTwilight(self, year, month, day, lon, lat)
This macro computes the start and end times of nautical twilight.
source code
 
astronomicalTwilight(self, year, month, day, lon, lat)
This macro computes the start and end times of astronomical twilight.
source code
 
__sunriset__(self, year, month, day, lon, lat, altit, upper_limb)
Note:
source code
 
__daylen__(self, year, month, day, lon, lat, altit, upper_limb)
Note:
source code
 
sunpos(self, d)
Computes the Sun's ecliptic longitude and distance at an instant given in d, number of days since 2000 Jan 0.0.
source code
 
sunRADec(self, d)
Returns the angle of the Sun (RA) the declination (dec) and the distance of the Sun (r) for a given day d.
source code
 
revolution(self, x)
This function reduces any angle to within the first revolution by subtracting or adding even multiples of 360.0 until the result is >= 0.0 and < 360.0
source code
 
rev180(self, x)
Reduce angle to within +180..+180 degrees
source code
 
GMST0(self, d)
This function computes GMST0, the Greenwich Mean Sidereal Time at 0h UT (i.e.
source code
 
solar_altitude(self, latitude, year, month, day)
Compute the altitude of the sun.
source code
 
get_max_solar_flux(self, latitude, year, month, day)
Compute the maximal solar flux to reach the ground for this date and latitude.
source code
tuple
equation_of_time(self, year, month, day, latitude)
Subroutine computing the part of the equation of time needed in the computing of the theoritical solar flux Correction originating of the CMC GEM model.
source code
double
__Solcons(self, dAlf)
Description: Statement function that calculates the variation of the solar constant as a function of the julian day.
source code
 
Julian(self, year, month, day)
Return julian day.
source code
Method Details [hide private]

dayLength(self, year, month, day, lon, lat)

source code 

This macro computes the length of the day, from sunrise to sunset. Sunrise/set is considered to occur when the Sun's upper limb is 35 arc minutes below the horizon (this accounts for the refraction of the Earth's atmosphere).

dayCivilTwilightLength(self, year, month, day, lon, lat)

source code 

This macro computes the length of the day, including civil twilight. Civil twilight starts/ends when the Sun's center is 6 degrees below the horizon.

dayNauticalTwilightLength(self, year, month, day, lon, lat)

source code 

This macro computes the length of the day, incl. nautical twilight. Nautical twilight starts/ends when the Sun's center is 12 degrees below the horizon.

dayAstronomicalTwilightLength(self, year, month, day, lon, lat)

source code 

This macro computes the length of the day, incl. astronomical twilight. Astronomical twilight starts/ends when the Sun's center is 18 degrees below the horizon.

sunRiseSet(self, year, month, day, lon, lat)

source code 

This macro computes times for sunrise/sunset. Sunrise/set is considered to occur when the Sun's upper limb is 35 arc minutes below the horizon (this accounts for the refraction of the Earth's atmosphere).

civilTwilight(self, year, month, day, lon, lat)

source code 

This macro computes the start and end times of civil twilight. Civil twilight starts/ends when the Sun's center is 6 degrees below the horizon.

nauticalTwilight(self, year, month, day, lon, lat)

source code 

This macro computes the start and end times of nautical twilight. Nautical twilight starts/ends when the Sun's center is 12 degrees below the horizon.

astronomicalTwilight(self, year, month, day, lon, lat)

source code 

This macro computes the start and end times of astronomical twilight. Astronomical twilight starts/ends when the Sun's center is 18 degrees below the horizon.

__sunriset__(self, year, month, day, lon, lat, altit, upper_limb)

source code 

Note:

  • year,month,date = calendar date, 1801-2099 only. Eastern longitude positive, Western longitude negative Northern latitude positive, Southern latitude negative The longitude value IS critical in this function!
  • altit = the altitude which the Sun should cross Set to -35/60 degrees for rise/set, -6 degrees for civil, -12 degrees for nautical and -18 degrees for astronomical twilight.
  • upper_limb: non-zero -> upper limb, zero -> center Set to non-zero (e.g. 1) when computing rise/set times, and to zero when computing start/end of twilight.
  • *rise = where to store the rise time
  • *set = where to store the set time Both times are relative to the specified altitude, and thus this function can be used to compute various twilight times, as well as rise/set times
  • Return value:
  • 0 = sun rises/sets this day, times stored at *trise and *tset.
  • +1 = sun above the specified 'horizon' 24 hours. *trise set to time when the sun is at south, minus 12 hours while *tset is set to the south time plus 12 hours. 'Day' length = 24 hours
  • -1 = sun is below the specified 'horizon' 24 hours 'Day' length = 0 hours, *trise and *tset are both set to the time when the sun is at south.

__daylen__(self, year, month, day, lon, lat, altit, upper_limb)

source code 

Note:

  • year,month,date = calendar date, 1801-2099 only. Eastern longitude positive, Western longitude negative Northern latitude positive, Southern latitude negative The longitude value is not critical. Set it to the correct longitude if you're picky, otherwise set to, say, 0.0
  • The latitude however IS critical - be sure to get it correct
  • altit = the altitude which the Sun should cross Set to -35/60 degrees for rise/set, -6 degrees for civil, -12 degrees for nautical and -18 degrees for astronomical twilight.
  • upper_limb: non-zero -> upper limb, zero -> center Set to non-zero (e.g. 1) when computing day length and to zero when computing day+twilight length.

sunpos(self, d)

source code 

Computes the Sun's ecliptic longitude and distance at an instant given in d, number of days since 2000 Jan 0.0. The Sun's ecliptic latitude is not computed, since it's always very near 0.

revolution(self, x)

source code 

This function reduces any angle to within the first revolution by subtracting or adding even multiples of 360.0 until the result is >= 0.0 and < 360.0

Reduce angle to within 0..360 degrees

GMST0(self, d)

source code 

This function computes GMST0, the Greenwich Mean Sidereal Time at 0h UT (i.e. the sidereal time at the Greenwhich meridian at 0h UT). GMST is then the sidereal time at Greenwich at any time of the day. I've generalized GMST0 as well, and define it as: GMST0 = GMST - UT -- this allows GMST0 to be computed at other times than 0h UT as well. While this sounds somewhat contradictory, it is very practical: instead of computing GMST like:

GMST = (GMST0) + UT * (366.2422/365.2422)

where (GMST0) is the GMST last time UT was 0 hours, one simply computes:

GMST = GMST0 + UT

where GMST0 is the GMST "at 0h UT" but at the current moment! Defined in this way, GMST0 will increase with about 4 min a day. It also happens that GMST0 (in degrees, 1 hr = 15 degr) is equal to the Sun's mean longitude plus/minus 180 degrees! (if we neglect aberration, which amounts to 20 seconds of arc or 1.33 seconds of time)

solar_altitude(self, latitude, year, month, day)

source code 

Compute the altitude of the sun. No atmospherical refraction taken in account. Altitude of the southern hemisphere are given relative to true north. Altitude of the northern hemisphere are given relative to true south. Declination is between 23.5° North and 23.5° South depending on the period of the year. Source of formula for altitude is PhysicalGeography.net http://www.physicalgeography.net/fundamentals/6h.html

get_max_solar_flux(self, latitude, year, month, day)

source code 

Compute the maximal solar flux to reach the ground for this date and latitude. Originaly comes from Environment Canada weather forecast model. Information was of the public domain before release by Environment Canada Output is in W/M^2.

equation_of_time(self, year, month, day, latitude)

source code 

Subroutine computing the part of the equation of time needed in the computing of the theoritical solar flux Correction originating of the CMC GEM model.

Parameters:
  • year (int) - Year
  • month (int) - Month
  • day (int) - Day
  • latitude (float) - latitude to comput the equation of time
Returns: tuple
(double fEot, double fR0r, tuple tDeclsc)
  • dEot: Correction for the equation of time
  • dR0r: Corrected solar constant for the equation of time
  • tDeclsc: Declinaison

__Solcons(self, dAlf)

source code 

Description: Statement function that calculates the variation of the solar constant as a function of the julian day. (dAlf, in radians)

Parameters:
  • dAlf (double) - Solar constant to correct the excentricity
Returns: double
Variation of the solar constant