Module crepyscule
[hide private]
[frames] | no frames]

Module crepyscule

source code

Package to get different information related to the sun going around the Earth. It is based on one or two locations on the Earth, based on the lat/lon and, optional, the different time zone and summer time codes. Currently the following information is given by this code: sunrise, sunset, sun altitude, daylight variation, solar flux and twilight.

crepyscule could be use in two modes: for graphics and as a module.

  1. The python module numpy is required.
  2. The graphic mode required other modules and is more tedious to install. rpy for python and GDD in R are required.
  3. Starting from version 1.0.0, it is possible to use crepyscule as a module, one only needs to uncompress crepyscule and could import it and use it directly. It only uses standard python package and numpy.

Project home page is http://ptaff.ca/crepyscule/

Note:

Functions [hide private]
 
crepyscule(dDataRequest, fLat1, fLon1, ctime, fUTC1=0, sFilename='', sSummerTime1='', fLat2=None, fLon2=None, sSummerTime2='', fUTC2=0, sBackgroundColor='white')
This is the main function for using crepyscule in command line.
source code
float
get_sunrise_day(ctime, fLat, fLon, fUTC=0, sSummerTime='')
Get the sunrise value for this day.
source code
float
get_sunset_day(ctime, fLat, fLon, fUTC=0, sSummerTime='')
Get the sunset value for this day.
source code
dictionnary
get_sunrise_as_dict(ctime, fLat, fLon, fUTC=0, sSummerTime='')
Get a dictionary containing the sunrise time for the year of the ctime.
source code
dictionnary
get_sunset_as_dict(ctime, fLat, fLon, fUTC=0, sSummerTime='')
Return a list containing the sunset time for this ctime.
source code
list
get_sunrise_sunset_as_csv(ctime, fLat1, fLon1, fUTC1=0, sSummerTime1='', fLat2=None, fLon2=None, fUTC2=0, sSummerTime2='')
Returns a list containing the date,sunrise,sunset in a CSV format.
source code
list
get_sun_altitude_as_csv(ctime, fLat1, fLat2=None)
Returns a list containing the date,sun_altitude
source code
dictionnary
get_sun_altitude_as_dict(ctime, fLat)
Return a list containing the sun altitude for this ctime.
source code
float
get_sun_altitude_day(ctime, fLat)
Get the sun altitude value for this day.
source code
list
get_daylight_variation_as_csv(ctime, fLat1, fLat2=None)
Returns a list containing the date, variation in daylight.
source code
dictionnary
get_daylight_variation_as_dict(ctime, fLat)
Return a list containing the daylight variation for the year correspoding to this ctime in a dictionnary.
source code
float
get_daylight_variation_day(ctime, fLat)
Get the sun dayligth variation value for this day.
source code
list
get_max_sf_as_csv(ctime, fLat1, fLat2=None)
Returns a list containing the date, maximum solar flux
source code
dictionnary
get_max_sf_as_dict(ctime, fLat)
Return a list containing the maximum solar flux for each day in the year where this ctime belongs.
source code
float
get_max_sf_day(ctime, fLat)
Get the maximum solar flux value for this day.
source code
list
get_twilight_length_as_csv(ctime, fLat1, fLat2=None)
Returns a list containing the date and the twilight length in minute.
source code
dictionnary
get_twilight_length_as_dict(ctime, fLat)
Return a list containing the twilight length in minute for each day in the year where this ctime belongs.
source code
float
get_twilight_length_day(ctime, fLat)
Get the twilight length in minute value for this day.
source code
 
check_required(parser, opt)
Extention of class OptionParser for mandatory argument.
source code
 
get_command_line()
Parse the command line and perform all the checks.
source code
Variables [hide private]
  t = gettext.translation('crepyscule', sys.path [0]+ '/locale')
  VERSION = '1.1.3'
  CFG_LONG_OPTIONS = ['help', 'version', 'filename', 'ctime', 'b...
Function Details [hide private]

crepyscule(dDataRequest, fLat1, fLon1, ctime, fUTC1=0, sFilename='', sSummerTime1='', fLat2=None, fLon2=None, sSummerTime2='', fUTC2=0, sBackgroundColor='white')

source code 

This is the main function for using crepyscule in command line. The result is png images and/or text files containing the requested information about the Sun.

Parameters:
  • dDataRequest (dictionnary) - Contains what file(s) or image(s) should be created. See the command line options. Keys are options with '--' and values are booleans. Keys are: 'GRAPH-SUNRISE','GRAPH-ALTITUDE' 'GRAPH-DAYLIGHT_VARIATION','GRAPH-SOLAR_FLUX', 'GRAPH-TWILIGHT_LENGTH', 'TEXT-SUNRISE'
  • fLat1 (float) - latitude of the first place. Latitude is in decimal degrees. Example: 30°30' should be 30.5
  • fLon1 (float) - longitude of the first place. Longitude is in decimal degrees. Example: 30°30' should be 30.5. West longitude are negative East longitude are positive.
  • ctime (float) - Any ctime in the day for the wanted value. If a graphic is created and there is only one place, a line is drawn with the values written at the intersection for this specific day.
  • fUTC1 (float) - Time to add/substract for each time values for the first place. Usually used for UTC value of place.
  • sFilename (string) - Filename for the images or text. Filename must ends with 'png' extension. The sunrise/sunset image is written with this filename. This terminology is used:
    sunrise/sunset: filename.png
    altitude: filename_alt.png 
    daylight variation: filename_delta_t.png
    solar flux: filename_sf.png
    sunrise/sunset text file: filename.txt
    
  • sSummerTime1 (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the first place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
  • fLat2 (float) - latitude of the second place. See fLat1.
  • fLon2 (float) - longitude of the second place. See fLon1.
  • sSummerTime2 (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the seconde place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
  • fUTC2 (float) - Time to add/substract for each time values for the second place.
  • sBackgroundColor (string) - Color that will be used for the background color for the generated graphics. See Chart of R colors

get_sunrise_day(ctime, fLat, fLon, fUTC=0, sSummerTime='')

source code 

Get the sunrise value for this day.

Parameters:
  • fLat (float) - Latitude in decimal.
  • fLon (float) - Longitude in decimal. West longitude are negative East longitude are positive.
  • ctime (float) - Any ctime in the day for the wanted value.
  • fUTC (float) - Time to add/substract for each time values. Usually used for UTC value of place.
  • sSummerTime (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the first place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
Returns: float
Time of the day in float.

get_sunset_day(ctime, fLat, fLon, fUTC=0, sSummerTime='')

source code 

Get the sunset value for this day.

Parameters:
  • fLat (float) - Latitude in decimal.
  • fLon (float) - Longitude in decimal. West longitude are negative East longitude are positive.
  • ctime (float) - Any ctime in the day for the wanted value.
  • fUTC (float) - Time to add/substract for each time values. Usually used for UTC value of place.
  • sSummerTime (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the first place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
Returns: float
Time of the day in float.

get_sunrise_as_dict(ctime, fLat, fLon, fUTC=0, sSummerTime='')

source code 

Get a dictionary containing the sunrise time for the year of the ctime. Keys of dictionary are date in iso8601 format.

Parameters:
  • fLat (float) - Latitude in decimal.
  • fLon (float) - Longitude in decimal. West longitude are negative East longitude are positive.
  • ctime (float) - Any ctime in the year of the result.
  • fUTC (float) - Time to add/substract for each time values. Usually used for UTC value of place.
  • sSummerTime (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the first place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
Returns: dictionnary
Dictionnary containing sunrise time for the year of the ctime. Keys of dictionary are date in iso8601 format.

get_sunset_as_dict(ctime, fLat, fLon, fUTC=0, sSummerTime='')

source code 

Return a list containing the sunset time for this ctime.

Parameters:
  • fLat (float) - Latitude in decimal.
  • fLon (float) - Longitude in decimal. West longitude are negative East longitude are positive.
  • ctime (float) - Any ctime in the year of the result.
  • fUTC (float) - Time to add/substract for each time values. Usually used for UTC value of place.
  • sSummerTime (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the first place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
Returns: dictionnary
Dictionnary containing sunset time for the year of the ctime. Keys of dictionary is a string in iso8601 format like 'YYYY-MM-DD'.

get_sunrise_sunset_as_csv(ctime, fLat1, fLon1, fUTC1=0, sSummerTime1='', fLat2=None, fLon2=None, fUTC2=0, sSummerTime2='')

source code 

Returns a list containing the date,sunrise,sunset in a CSV format. See function crepyscule_tools.get_sunrise_sunset_as_csv for detailed information.

Parameters:
  • fLat1 (float) - Latitude in decimal for the first place.
  • fLon1 (float) - Longitude in decimal for the first place. West longitude are negative. East longitude are positive.
  • ctime (float) - Any ctime in the year of the result.
  • fUTC1 (float) - Time to add/substract for each time values for the first place. Usually used for UTC value of place.
  • sSummerTime1 (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the first place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
  • fLat2 (float) - latitude of the second place. See fLat1.
  • fLon2 (float) - longitude of the second place. See fLon1.
  • sSummerTime2 (string) - This variable is a 2 letters code indicating when is the daylight saving time (DST) starting and ending in the year for the seconde place. Default is no DST. For a list of DST code, see crepyscule_summer_time.lTimezone.
  • fUTC2 (float) - Time to add/substract for each time values for the second place.
Returns: list
list containing the date,sunrise,sunset in CSV format. One line per item in the list.

get_sun_altitude_as_csv(ctime, fLat1, fLat2=None)

source code 

Returns a list containing the date,sun_altitude

No use for longitude, UTC or summer time. Use default values.

See function crepyscule.get_sun_altitude_as_csv for detailed information.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat1 (float) - Latitude in decimal for the first place.
  • fLat2 (float) - latitude in decimal for the second place.
Returns: list
list containing the date,sun_altitude in CSV format. One line per item in the list.

get_sun_altitude_as_dict(ctime, fLat)

source code 

Return a list containing the sun altitude for this ctime.

No use for longitude, UTC or summer time. Use default values.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: dictionnary
Dictionnary containing sun altitude for the year of the ctime. Keys of dictionary is a string in iso8601 format like 'YYYY-MM-DD'.

get_sun_altitude_day(ctime, fLat)

source code 

Get the sun altitude value for this day. No use for longitude, UTC or summer time. Use default values.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: float
Sun altitude for this day in float.

get_daylight_variation_as_csv(ctime, fLat1, fLat2=None)

source code 

Returns a list containing the date, variation in daylight.

See function crepyscule_tools.get_daylight_variation_as_csv for detailed information.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat1 (float) - Latitude in decimal for the first place.
  • fLat2 (float) - latitude in decimal for the second place.
Returns: list
list containing the date,variation in daylight in CSV format. One line per item in the list.

get_daylight_variation_as_dict(ctime, fLat)

source code 

Return a list containing the daylight variation for the year correspoding to this ctime in a dictionnary.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: dictionnary
Dictionnary containing daylight variation for the year of the ctime. Keys of dictionary is a string in iso8601 format like 'YYYY-MM-DD'.

get_daylight_variation_day(ctime, fLat)

source code 

Get the sun dayligth variation value for this day.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: float
Daylight variation for this day in float.

get_max_sf_as_csv(ctime, fLat1, fLat2=None)

source code 

Returns a list containing the date, maximum solar flux

See function crepyscule_tools.get_solar_flux_as_csv for detailed information.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat1 (float) - Latitude in decimal for the first place.
  • fLat2 (float) - Latitude in decimal for the second place.
Returns: list
list containing the date,max_solar_flux in CSV format. One line per item in the list. Solar flux is in watt per meter square.

get_max_sf_as_dict(ctime, fLat)

source code 

Return a list containing the maximum solar flux for each day in the year where this ctime belongs.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: dictionnary
Dictionnary containing maximum solar flux of each day for the year of the ctime. Keys of dictionary is a string in iso8601 format like 'YYYY-MM-DD'. Solar flux is in watt per meter square.

get_max_sf_day(ctime, fLat)

source code 

Get the maximum solar flux value for this day.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: float
Maximum solar flux for this day in float. Solar flux is in watt per meter square.

get_twilight_length_as_csv(ctime, fLat1, fLat2=None)

source code 

Returns a list containing the date and the twilight length in minute. Note: the twilight length is defined as the duration while the sun is below the horizon and less than 12° below (nautical twilight).

See function crepyscule_tools.get_twilight_length_as_csv for detailed information.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat1 (float) - Latitude in decimal for the first place.
  • fLat2 (float) - Latitude in decimal for the second place.
Returns: list
list containing the date, twilight_length in CSV format. One line per item in the list. Twilight length is minutes

get_twilight_length_as_dict(ctime, fLat)

source code 

Return a list containing the twilight length in minute for each day in the year where this ctime belongs.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: dictionnary
Dictionnary containing the twilight length of each day for the year of the ctime. Keys of dictionary is a string in iso8601 format like 'YYYY-MM-DD'. Solar flux is in watt per meter square.

get_twilight_length_day(ctime, fLat)

source code 

Get the twilight length in minute value for this day.

Parameters:
  • ctime (float) - Any ctime in the year of the result.
  • fLat (float) - Latitude in decimal for the place.
Returns: float
Twilight length for this day in float. Length is in degree/hour

check_required(parser, opt)

source code 

Extention of class OptionParser for mandatory argument. Comes from http://www.python.org/doc/2.3.4/lib/optparse-extending-examples.html

Parameters:
  • parser (OptionParser) - Parser containing the values in the command line
  • opt (string) - option to check if it is required.

Variables Details [hide private]

CFG_LONG_OPTIONS

Value:
['help',
 'version',
 'filename',
 'ctime',
 'background-color',
 'lat1',
 'lon1',
 'utc1',
...