• Français
  • English

crepyscule

Screenshots
Sunrise, sunset and time of light, Montreal
Maximum altitude of the sun, Montreal
Daily variation of daylight, Montreal
Solar flux, Montreal
Twilight length, Montreal
Sunrise, sunset and time of light, Montreal vs. New York
Maximum altitude of the sun, Montreal vs. New York
Daily variation of daylight, Montreal vs. New York
Solar flux, Montreal vs. New York
Twilight length, Montreal vs. New York

Python source code for creation of sunrise/sunset graphs

Introduction

You can find here the code used to generate the data of the web page http://ptaff.ca/soleil/?lang=en_CA. This project was inspired by the file used to compute the sunset and the sunrise of the sun, this file is written by Henrik Härkönen and can be found on this web page.

For 1 or 2 geographical place on the earth, crepyscule produces four graphics:

  1. One graphic showing the time of sunrise, sunset and the total time of a day (the total time being defined, in this case, as the time elapsed between the sunset and the sunrise) for every day of the year;
  2. One graphic showing the maximum altitude of the sun for every day of the year;
  3. One graphic showing the daily variation of daylight;
  4. One graphic showing the solar flux for every day of the year.

If one chooses to show 2 places, the curves of these 2 places will lie on the same graphic, using different colors.

For now, the title of the graphs can be in english or in french, the default language being english. See the example of usage for more details.

Requirements

Developed under GNU/Linux, this script is known to work under GNU/Linux and Windows; if you use another platform than GNU/Linux, please inform the developer in order to publish the documentation for this specific implementation.

Download

Manual

In a general way, this application should be called in command line like this:

python crepyscule.py --filename=filename --ctime=ctime --background-color=bg_color --lat1=latitude1 --lon1=longitude1 --utc1=utc1 --tz1=timezone1 [--lat2=latitude2 --lon2=longitude2 --utc2=utc2 --tz2=timezone2] [--graph-sunrise-sunset] [--graph-sun-altitude] [--graph-daylight-variation] [--graph-solar-flux] [--text-sunrise-sunset] [--graph-all]

Parameters summary
Parameter Description
--versionShow program's version number and exit
-h, --helpShow help message and exit
-f FILENAME, --filename=FILENAMEFilename of the graphic
--ctime=FTIMEctime for the current day
--background-color=SBACKGROUNDCOLORBackground color of the graphics
--lat1=FLAT1Latitude of the first place (negative value for south)
--lon1=FLON1Longitude of the first place (negative value for west)
--utc1=FUTC1Difference of the time zone compared to the UTC time for the first place
--tz1=STZ1Time zone parameter used for summer time. Possible value are: IR, JD, EU, IQ, US, CH, EG, MX, SK, HK, NB, FK, PY, NZ, TS, BZ, CL, AU, TG, ZN, LB, SY, RU
--lat2=FLAT2Latitude of the second place (negative value for south)
--lon2=FLON2Longitude of the second place (negative value for west)
--utc2=FUTC2Difference of the time zone compared to the UTC time for the second place
--tz2=STZ2Time zone parameter for 2nd place. See --tz1 for possible value
--graph-sunrise-sunsetCreate the graphic for sunrise/sunset
--graph-sun-altitudeCreate the graphic for sun altitude
--graph-daylight-variationCreate the graphic for daylight variation
--graph-solar-fluxCreate the graphic for the solar flux
--graph-twilight-lengthCreate the graphic for the twilight length
--text-sunrise-sunsetCreate a text file containing the sunrise/sunset value
--graph-allCreate all the graphics for these lat/lon
  • The parameters between [] are optional; you may compare two places this way. Note that you should give at least one of the following options: --graph-sunrise-sunset, --graph-sun-altitude, --graph-daylight-variation, --graph-solar-flux, --text-sunrise-sunset ou --graph-all.;
  • The filename parameter is used to indicate the path and the name of the image. The .png extension is mandatory. The first graphic takes this exact name of the parameter; the altitude graphic will be have the same name but with the characters "_alt" added before the extension name .png, the daily variation of daylight graphic will be have the same name but with the characters "_delta_t" added before the extension name .png and the solar flux graphic will be have the same name but with the characters "_sf" added before the extension name .png,;
  • The ctime parameter is used to determine for which year the values will be computed. Moreover, when only one place is showed, a dashed vertical line is drawn at the day corresponding to this date. The values at the intersections of this line and the differents curves, for each of the 4 graphics, are written.;
  • The background-color parameter should be in the X11 color list and should be written using lower case.;
  • The latitude and longitude parameters are real numbers. For example, we will represent 45°30' by 45.5;
  • The UTC parameter represents the difference of the time zone compared to the UTC time. For example, for New York this parameter is -5.0;
  • For more details on the tz parameter, please refer to file summer_time.py or the file TZrules.dat that comes with the kstars application. For the GNU/Linux system, this file is usually found at the path /usr/share/apps/kstars/ when kstars is installed.;
  • The language of title in the graphics are determined by the LANGUAGE environment variable..

Usage

python crepyscule.py --graph-all --filename montreal.png --ctime 1112121748 \
--background-color white --lat1 45.4667 --lon1 -73.75 --utc1 -5.0 --tz1 US
Create the graphics for the city of Montreal for march 29th 2005.
export LANGUAGE='en'; \
python crepyscule.py --graph-all --filename montreal.png --ctime 1112121748 \
--background-color white --lat1 45.4667 --lon1 -73.75 --utc1 -5.0 --tz1 US
Under a GNU/Linux system; as the precedent example but with the titles in french.
python crepyscule.py --graph-all --filename montreal_new_york.png --ctime 1112121748 \
--background-color white --lat1 45.4667 --lon1 -73.75 --utc1 -5.0 --tz1 US --lat2 40.75 --lon2 -73.99 --utc2 -5.0 --tz2 US
Creates the graphics comparing the cities of New York and of Montreal for march 29th 2005.

API

You can consult crepyscule's API.

Bugs

For any bug report, please contact soleil.miguel@ptaff.ca

Author

Miguel Tremblay

License

Copyright © 2005 Miguel Tremblay.

crepyscule is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.


crepyscule

Creation : August 14th, 2005
Villeray
N 45° 33′ W 73° 36′

crepyscule

Last update : May 23rd, 2014,
Villeray,
N 45° 33′ W 73° 36′