Skip to content

tpaschalis/sunlight.live

Repository files navigation

sunlight.live

TODO : Remove dev cruft from requirements.txt
only 3 or 4 lines should actually be there, everything else is remnants from development tests

Feel free to raise Issues, create Pull Requests, or send comments! The advice.md file contains, well, advice and feedback I've gathered from other people, that I'm thinking of implementing.

What's this?

I recently wanted to make a pixel worldmap, and dusted my undergrad astronomy books to create this illustration. The base inspiration was the pixel worldmap that exists on many Android phones "Clock" application.

sunlight.live is a live-updating representation the Sun's terminator, the line which divides "day" and "night" on earth.

Mote detailed information about the development can be found on this blog post. The project has been submitted on Reddit and HackerNews, reaching the front-page.

All suggestions, insights, and astronomy-related tidbits are welcome!

Deployment

The website runs on a $5 DigitalOcean droplet, with a near-default Apache and Let'sEncrypt, as this was all an excuse to spend a weekend studying astronomy, not an exercise in DevOps.

The image is updated every 10 minutes using cron, Python3, a single line of NumPy plus some celestial mechanics formulas, and should have an accuracy of ±1 degree.

The goal was to create a minimal, fast and aesthetically pleasing result. I'm not much of a designer, but I'm pretty happy with the first version of this site, and its small-ish size.

All plotting happens using Matplotlib. Most Matplotlib code and tutorials can be very confusing, but I think the source can serve as a guide to readable and maintainable plotting.

The world data is obtained from the wonderful Natural Earth datasets, and handled using GeoPandas

Project Files

There are four main components

  • The parse-data.py script, which parses the geographical dataset, to provide pairs of points in a 360x180 grid representation of earth.
  • The land-points file, which is the aforementioned pairs of points representing earth land.
  • The plot-data.py script which runs every 10 minutes, to build the updated illustration.
  • The public/ folder, which contains all websitey files.

Roadmap

Once I have some time, I want to :

  • Learn more about the accuracy of astronomical formulas
  • Offer some more astronomical data through this page and an API
  • Provide some more illustrations about the solar system