Git Product home page Git Product logo

moon_cal's Introduction

moon_cal

Code to make lunar phase calendars

snippet

The above image shows the overall idea. Click here for the 2023 calendar as a PDF, or here for the 2024 calendar, or here for the 2025 calendar (haven't gotten past 2025 yet, but will as that approaches). You can just grab a desired calendar and print it out; you need only read the following if you'd like to tweak the calendar, generate calendars for other years, or read about why I went to the trouble of doing this.

Building/running the code

On most non-Microsoft systems, build by running

make

I assume you can run something like cl -W4 -Ox moon_cal.c on Microsoft® Windows™ and it'll work, but I've not tried it on anything but GNU/Linux. The code is very generic, has no dependencies except for the math library, and would presumably compile/run on *BSD, OS/X, etc.

To generate a chart for a given year, run it as, e.g., ./moon_cal 2023. The result will be written to z.ps. You can either view/print that, or run ps2pdf z.ps 2023.pdf to make the PDF linked to above.

By default, new and full moons, solstices and equinoxes, and a variety of holidays are shown. These are listed in date2023.txt, date2024.txt, etc. You can edit those files to change what date(s) are shown.

Once printed on two US letter or A4 pages, a bit of scissors work and transparent tape will assemble the calendar.

Rationale

I do a fair bit of work writing software for asteroid observers ("planetary defense", the folks looking for rocks that might hit the earth). There's usually about a week or so around each full moon where we can't observe much, and a few days before/after that where moonlight interferes to an annoying extent.

Some Christmases back, my sister gave me a printed calendar vaguely resembling the ones shown here. It was useful, and had better artwork than what I'm providing here. It wasn't particularly oriented to what a working astronomer might actually need (it was a bit "New Age"-ish), but it made me think about what I'd actually want to have.

The column of days of the month was on the left edge, which made it a little tricky to find the day of the month you wanted by the time you got to the end of the year. Putting it in the middle helped.

I added the 'Su Mo Tu..." to make it still easier to find the desired day, and made it possible to note other days.

The lunar month names are the traditional ones from the Maine Farmer's Almanac (I'm from Maine). The rationale is described in fullmoon.txt.

Possible improvements

I could imagine indicating lunar and solar eclipses with some modification of the new moon/full moon symbol. Possibly even taking a chunk out of the symbol to indicate the maximum extent of the eclipse.

I made no use of color, since my printer is a black-and-white laser. I could imagine different colors indicating... well.. something or other.

Somewhere or other, I've seen a chart resembling this sort, but in 'landscape' mode (days of the month run horizontally, so you have 31 columns and 12 rows instead of 12 columns and 31 rows.) That might make a nice alternative.

I may put together an on-line service on my Web site where you would enter the desired year, then be presented with an edit box containing the default dateYYYY.txt file for that year. Edit as desired to remove stuff you don't want and to label your pet's birthday or other date(s) of interest, click 'Make Calendar', and you'd get your customized calendar without having to download and compile and run this code.

moon_cal's People

Contributors

bill-gray avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

moon_cal's Issues

FWIW: Compact lunar phase algorithm to 0.3% from 1970 - 2149

https://github.com/deirdreobyrne/LunarPhase

#include <math.h>

/**
 * @arg sec the number of seconds since 1970 Jan 1 00:00:00 UTC
 * @arg is_waxing if not null, then will contain true if the moon
 *                is waxing
 * @return the illuminated fraction of the moon's disk as seen from earth,
 *         accurate to 0.3% during the entire period 1970 - 2149
 *
 * @author github.com/deirdreobyrne
 */
double getPhase(double sec, int *is_waxing) {

  double d = fmod(4.847408287988257 + sec/406074.7465115577, 2.0*M_PI);
  double m = fmod(6.245333801867877 + sec/5022682.784840698, 2.0*M_PI);
  double l = fmod(4.456038755040014 + sec/378902.2499653011, 2.0*M_PI);
  double i = fmod(d
          +1.089809730923715e-01 * sin(l)
          -3.614132757006379e-02 * sin(m)
          +2.228248661252023e-02 * sin(2.0*d-l)
          +1.353592753655652e-02 * sin(2.0*d)
          +4.238560208195022e-03 * sin(2.0*l)
          +1.961408105275610e-03 * sin(d)
          ,2.0*M_PI);

  if (is_waxing) {
    *is_waxing = (i <= M_PI);
  }
  return (1.0 - cos(i))/2.0;
}

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.