Giter Club home page Giter Club logo

daylight-calendar's Introduction

Daylight maps (XKCD 2542)

Daylight calendar

© Randall Monroe, 2021

Daylight calendar, where every 12 hours of sun gives you a freshly minted day! These are maps showing the whole world how the whole world experiences the calamity of variable day lengths, with arbitrary date and location entry and a "clock mode" that updates slowly over the course of the day to put on your smart-fridge or something.

Try it out on day.lam.io

Sunrise/sunset lookup tables were made with astral which itself uses a calculator published by NOAA by Jean Meeus. On the live site, 60 years of data are precalculated starting at the Unix Epoch (Jan 1 1970, 00:00:00 UTC) and optimized for fast query in Postgres. Relevant queries include:

  • True time since last "tick" of the 12-hour sunlight day
  • Hours of sunlight since the last "tick"
  • Days since the epoch
  • Variation with longitude

The exact definition of "sunrise" and "sundown" are the biggest source of error in these calculations. astral accounts for atmospheric refraction and is purely geometric, calculating when the sun itself disappears below a featureless horizon. The calculator by NOAA states that times are accurate to within 1 minute for non-polar latitudes. Meanwhile, this app assumes that the sunrise/sunset times are perfect and queries astral for the entire 60 years worth of data without trying to exploit any symmetries and such, assuming the worst for orbital nonidealities. The datetimes and deltas are carefully managed so that the integration error shouldn't be more than a few seconds over this period of time.

A time system with a yearly epoch (i.e. all times resynced every Jan 1 00:00 UTC) is also calculated under year_cumsum.

To install:

  1. Push the schemas into postgres: psql x2542 < schemas.sql;
  2. Generate table of sunrise/sunset times across latitudes in proc/generate.py;
  3. Postprocess and generate final lookup tables in Postgres: psql x2542 < postprocess.sql
  4. Build the places table according to acrylic-origami/reaction-maps
  5. Create credentials file for server: echo 'creds = "user=<pg user> password=<pg pass>"' > x2542/creds.py
  6. Start up flask dev server: FLASK_APP=x2542/server.py FLASK_ENV=development flask run
  7. Hit at localhost:5000/static/index.html
  8. Deploy to Apache + mod_wsgi by:
    • Specifying the missing paths in x2542.conf and moving it to sites-enabled
    • Installing the server into the environment via pip install .
    • Hitting the Apache server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.