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

Module crepyscule_graphic

source code

Package that contains everything to plot graphics for crepyscule. Based on rpy and GDD (R language). All images are in the png format.

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

Functions [hide private]
 
init_time_values(lDateISO8601)
Set the value of time used by the graphs.
source code
 
plot_altitude(tToday, lSunAltitude, lDateISO8601, sFilename, sBackgroundColor, lSunAltitude2=None)
Plot the altitude of the sun during a year.
source code
 
__draw_today_sun(tToday, fSunriseTime, fSunsetTime)
Add information about current day on the graphics of sunset and sunrise.
source code
 
__draw_today(tToday, fTodayValue, sLabel, fMiddleOfGraph)
Draw a line in the graphic for the value of the current day.
source code
 
plot_sunset_sunrise(lSunrise, lSunset, lDaylength, lDateISO8601, sFilename, tToday, sBackgroundColor, lSunrise2=None, lSunset2=None, lDaylength2=None)
Plot the sunset and the sunrise of one year.
source code
 
plot_monthly(lMonthLight, sFilename)
DEPRECATED Plot a graphical with total hour of light for each month.
source code
 
draw_sunrise_sunset(npSunrise, npSunset, npSunTime, nIndiceStartSunrise, nIndiceEndSunrise, nIndiceStartSunset, nIndiceEndSunset, lDateISO8601, sLty='solid', sColorSunrise='orange', sColorSunset='red', sColorTotalTime='blue')
Draw sunrise and sunset lines on the graphics.
source code
 
plot_daylight_differences(lSunrise1, lSunset1, lDaylength1, lDateISO8601, sFilename, tToday, sBackgroundColor, lSunrise2=None, lSunset2=None, lDaylength2=None)
Plot the difference of daylight time between consecutive days.
source code
 
plot_max_solar_flux(lDateISO8601, sFilename, tToday, sBackgroundColor, fLat1, fLat2=None)
Plot the maximal solar flux in W/m^2 for all year.
source code
 
plot_twilight_length(sFilename, tToday, sBackgroundColor, fLat1, dTwilightLength1, fLat2=None, dTwilightLength2=None)
Plot the twilight length in minutes for all year.
source code
Variables [hide private]
  t = gettext.translation('crepyscule_graphic', sys.path [0]+ '/...
  lMonthString = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL...
  nPngWidth = 640
  nPngHeight = 480
  rlMonth = None
  rX_axis = None
  sColor = 'white'
  sFirstCityColor = 'blue'
  sSecondCityColor = 'limegreen'
Function Details [hide private]

init_time_values(lDateISO8601)

source code 

Set the value of time used by the graphs. Declare the import here because a lot of output are written when it is done and we do not want to have it every time crepyscule is invoked, only when this module is called.

Parameters:
  • lDateISO8601 (liste) - Create the X axis based on the values of the list. Values are one year date in iso8601 format.

plot_altitude(tToday, lSunAltitude, lDateISO8601, sFilename, sBackgroundColor, lSunAltitude2=None)

source code 

Plot the altitude of the sun during a year.

Parameters:
  • tToday (tuple) - Tuple as returned by the function time.gmtime.
  • lSunAltitude (list) - list of Sun altitude for the first place.
  • lDateISO8601 (list) - List of strings for one year in iso8601 format.
  • sFilename (string) - Filename to save the graph. Filename is transformed like 'file.png' to 'file_alt.png'.
  • sBackgroundColor (string) - Color that will be used for the background color for the generated graphics. See Chart of R colors
  • lSunAltitude2 (list) - list of Sun altitude for the second place.

__draw_today_sun(tToday, fSunriseTime, fSunsetTime)

source code 

Add information about current day on the graphics of sunset and sunrise. Draw a vertical line for the current date. Draw a circle at the place where this vertical line cross each of the three lines (sunset, sunrise, total day light). Write the value of at these circles.

Parameters:
  • tToday (tuple) - Tuple as returned by the function time.gmtime.
  • fSunsetTime (float) - Time of sunset.
  • fSunriseTime (float) - Time of sunrise.

__draw_today(tToday, fTodayValue, sLabel, fMiddleOfGraph)

source code 

Draw a line in the graphic for the value of the current day. NOT for sunrise/sunset. See __draw_today_sun in this case. private

Parameters:
  • tToday (tuple) - Tuple as returned by the function time.gmtime.
  • fTodayValue (float) - Value to be mark on the curve.
  • sLabel (string) - Label to be written at the position of the mark.
  • fMiddleOfGraph (float) - Middle of the Y axis. Used to know if the label goes over or under the bullet on the curve.

plot_sunset_sunrise(lSunrise, lSunset, lDaylength, lDateISO8601, sFilename, tToday, sBackgroundColor, lSunrise2=None, lSunset2=None, lDaylength2=None)

source code 

Plot the sunset and the sunrise of one year.

Parameters:
  • lSunrise (list) - List of sunrise values for one year for the first place.
  • lSunset (list) - List of sunset values for one year for the first place.
  • lDaylength (list) - List of day length for each day of the year.
  • lDateISO8601 (list) - List of strings for one year in iso8601 format.
  • sFilename (string) - Filename to save the graph.
  • tToday (tuple) - Tuple as returned by the function time.gmtime.
  • sBackgroundColor (string) - Color that will be used for the background color for the generated graphics. See Chart of R colors
  • lSunrise2 (list) - List of sunrise values for one year for the second place.
  • lSunset2 (list) - List of sunset values for one year for the second place. @type lDaylength2 list
  • lDaylength2 - List of day length for each day of the year for the second place.

plot_monthly(lMonthLight, sFilename)

source code 

DEPRECATED Plot a graphical with total hour of light for each month. Was used for debugging and development phase. Probably won't work. Code source is left here in case someone wants to use it. If it is your case, please contact the author.

Parameters:
  • lMonthLight (list) - list containing the sum of day light for each month.
  • sFilename (string) - Filename to save the graph. Filename is transformed like 'file.png' to 'file_month.png'.

draw_sunrise_sunset(npSunrise, npSunset, npSunTime, nIndiceStartSunrise, nIndiceEndSunrise, nIndiceStartSunset, nIndiceEndSunset, lDateISO8601, sLty='solid', sColorSunrise='orange', sColorSunset='red', sColorTotalTime='blue')

source code 

Draw sunrise and sunset lines on the graphics. This function is empiric. It has been developed by trials and errors, there is not much to understand.

There is only two complex case that are handled: when the sunrise (sunset) curve goes under (over) zero (24) value during one segment. In this case, there is 3 curves that are created corresponding to the value of rX_axis1, rX_axis2 and rX_axis3.

Parameters:
  • npSunrise (numpy.array) - Array of sunrise values for one year to be displayed.
  • npSunset (numpy.array) - Array of sunset values for one year to be displayed.
  • nIndiceStartSunrise (int) - Indice where the sunrise goes under the zero value. If there is no such place, zero is given.
  • nIndiceEndSunrise (int) - Indice where the sunrise goes over zero if it ever goes under it. If it does not occurs, the length of the array (365 or 366) is given.
  • nIndiceStartSunset (int) - Indice where the sunrise goes over 24 value. If there is no such place, zero is given.
  • nIndiceEndSunset (int) - Indice where the sunset goes under 24 if it ever goes over it. If it does not occurs, the length of the array (365 or 366) is given.
  • lDateISO8601 (list) - List of strings for one year in iso8601 format.
  • sLty (string) - R Line style. See help for 'lty' in the 'par' documentation in R
  • sColorSunrise (string) - Color of sunrise curve. See Chart of R colors for possible values.
  • sColorSunset (string) - Color of sunset curve. See Chart of R colors for possible values.
  • sColorTotalTime (string) - Color of total time of day curve. See Chart of R colors for possible values.

plot_daylight_differences(lSunrise1, lSunset1, lDaylength1, lDateISO8601, sFilename, tToday, sBackgroundColor, lSunrise2=None, lSunset2=None, lDaylength2=None)

source code 

Plot the difference of daylight time between consecutive days.

Parameters:
  • lSunrise1 (list) - List of sunrise values for one year for the first place.
  • lSunset1 (list) - List of sunset values for one year for the first place.
  • lDaylength1 (list) - List of day length for each day of the year.
  • lDateISO8601 (list) - List of strings for one year in iso8601 format.
  • sFilename (string) - Filename to save the graph. Filename is transformed like 'file.png' to 'file_delta_t.png'.
  • tToday (tuple) - Tuple as returned by the function time.gmtime.
  • sBackgroundColor (string) - Color that will be used for the background color for the generated graphics. See Chart of R colors
  • lSunrise2 (list) - List of sunrise values for one year for the second place.
  • lSunset2 (list) - List of sunset values for one year for the second place. @type lDaylength2 list
  • lDaylength2 - List of day length for each day of the year for the second place.

plot_max_solar_flux(lDateISO8601, sFilename, tToday, sBackgroundColor, fLat1, fLat2=None)

source code 

Plot the maximal solar flux in W/m^2 for all year.

Parameters:
  • lDateISO8601 (list) - List of strings for one year in iso8601 format.
  • sFilename (string) - Filename to save the graph. Filename is transformed like 'file.png' to 'file_sf.png'.

plot_twilight_length(sFilename, tToday, sBackgroundColor, fLat1, dTwilightLength1, fLat2=None, dTwilightLength2=None)

source code 

Plot the twilight length in minutes for all year.

Parameters:
  • sFilename (string) - Filename to save the graph. Filename is transformed like 'file.png' to 'file_ss.png'.
  • tToday (tuple) - Tuple as returned by the function time.gmtime.
  • sBackgroundColor (string) - Color that will be used for the background color for the generated graphics. See Chart of R colors
  • fLat1 (float) - Latitude in decimal for the first place.
  • dTwilightLength1 (dictionnary) - dictionnary containing the date in ISO 8601 format and sunset speed for this first place.
  • fLat2 (float) - Latitude in decimal for the second place.
  • dTwilightLength2 (dictionnary) - dictionnary containing the date in ISO 8601 format and sunset speed for this second place.

Variables Details [hide private]

t

Value:
gettext.translation('crepyscule_graphic', sys.path [0]+ '/locale')

lMonthString

Value:
['JAN',
 'FEB',
 'MAR',
 'APR',
 'MAY',
 'JUN',
 'JUL',
 'AUG',
...