Night to Day: Twilight

Date: 2020-10-10
Last Updated: 2021-09-01
#Ephemeris #Twilight #Physics #Python

I have always been intriuged by the speed at which day turns to night, and the change in the length of the day over the course of the year. It is often said that Irish people are obsessed with the weather and as such the length of the day too. As we would say:

There’s a grand stretch in the evenings

We are at least partially vindicated in our obsession because if one has never experienced standing outside at 10 PM on a summer night in what feels like early evening light, then that person can never understand the strange feeling it brings. The converse is not so fun when in the winter it gets pitch dark by 4 PM.

Recently (in early May this year) I found myself awake very late and interestingly I had left my bedroom blind open. I had woken up around 04:30 and saw a light in the sky outside my window. This light was Jupiter, and the slightly dimmer beside it was Saturn, these orbs caught my attention and I got up to look at them. It was at this point that I looked out into the garden and realised I could actually see outside, it was “bright”1.

I also (somewhere) had heard about the various twilights, namely Astronomical, Nautical, and Civil. But I didn’t know the definitions of each or if they were even different from each other. So this nocturnal experience of mine prompted me to do some research and calculations.


Twilight is the illumination of the lower atmosphere by the Sun while it is below the horizon. The angular distance that the Sun is below the horizon defines the kind of twilight.

Categories of twlight, from timeanddate.com

Categories of twlight, from timeanddate.com

What you don’t see from the above illustration is that the ratio of the three twilights to one and other changes with respect to time. Another thing that one misses from the diagram is that these effects are of different magnitudes depending on the observer’s latitude, as well as the time of the year.

Visualisation & Code

I decided to do a little bit of visualisation work on this, I first needed a library or set of equations that would allow me to calculate the position in the sky of the Sun at a given time and location on Earth. I found that PySolar fitted the bill for me quite nicely. I then devised two plots one using a somewhat conventional Pandas and Matplotlib approach (though I did switch to Plotly in lieu of Matplotlib in the end), and the other using an ASCII plotter which I wrote for the task.

I have linked below (twilight-clon.txt) the full ASCII plot for Clonakilty, Ireland for the months May to August 2020, below is an excerpt from that file which represents the month of May.

The plot can be interpreted as follows:

  • a - Astronomical Twilight (Sun 18º to 12º below the horizon)
  • n - Nautical Twilight (Sun 12º to 6º below the horizon)
  • c - Civil Twilight (Sun < 6º below the horizon)
  • Blank space to the left of an a - Night
  • Blank space to the right of a c - Day
Date       |---00:00---|---01:00---|---02:00---|---03:00---|---04:00---|---05:00---|---06:00---||
2020-05-01 |                                            aaaaaaaaaaaannnnnnnnnncccccccc          |
2020-05-02 |                                           aaaaaaaaaaaaannnnnnnnnncccccccc          |
2020-05-03 |                                          aaaaaaaaaaaaannnnnnnnnncccccccc           |
2020-05-04 |                                         aaaaaaaaaaaaaannnnnnnnnncccccccc           |
2020-05-05 |                                         aaaaaaaaaaaaannnnnnnnnnccccccccc           |
2020-05-06 |                                        aaaaaaaaaaaaaannnnnnnnnncccccccc            |
2020-05-07 |                                       aaaaaaaaaaaaaannnnnnnnnnncccccccc            |
2020-05-08 |                                      aaaaaaaaaaaaaaannnnnnnnnnccccccccc            |
2020-05-09 |                                      aaaaaaaaaaaaaannnnnnnnnnncccccccc             |
2020-05-10 |a                                    aaaaaaaaaaaaaaannnnnnnnnnccccccccc             |
2020-05-11 |aa                                  aaaaaaaaaaaaaaannnnnnnnnnnccccccccc             |
2020-05-12 |aaa                                aaaaaaaaaaaaaaaannnnnnnnnnncccccccc              |
2020-05-13 |aaaa                              aaaaaaaaaaaaaaaannnnnnnnnnnccccccccc              |
2020-05-14 |aaaaa                            aaaaaaaaaaaaaaaaannnnnnnnnnnccccccccc              |
2020-05-15 |aaaaaa                          aaaaaaaaaaaaaaaaannnnnnnnnnnncccccccc               |
2020-05-16 |aaaaaaa                        aaaaaaaaaaaaaaaaaannnnnnnnnnnccccccccc               |
2020-05-17 |aaaaaaaa                      aaaaaaaaaaaaaaaaaannnnnnnnnnnnccccccccc               |
2020-05-18 |aaaaaaaaa                   aaaaaaaaaaaaaaaaaaaannnnnnnnnnnnccccccccc               |
2020-05-19 |aaaaaaaaaaa                aaaaaaaaaaaaaaaaaaaannnnnnnnnnnnccccccccc                |
2020-05-20 |aaaaaaaaaaaa             aaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnccccccccc                |
2020-05-21 |aaaaaaaaaaaaaaa        aaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnccccccccc                |
2020-05-22 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnncccccccccc                |
2020-05-23 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnccccccccc                 |
2020-05-24 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnccccccccc                 |
2020-05-25 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnccccccccc                 |
2020-05-26 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnncccccccccc                 |
2020-05-27 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnccccccccc                  |
2020-05-28 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnccccccccc                  |
2020-05-29 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnccccccccc                  |
2020-05-30 |aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnncccccccccc                  |

What this plot tells us is that between the 21st of May 2020 and the 21st of July 2020, it was not night in Clonakilty.

I will update this post in the future with a link to the Jupyter Notebook that I used to produce this plot, once I have cleaned up the notebook.




  1. A prime specimen of typical Irish exaggeration. ↩︎