Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This is a small python package that simply gets an image of a given date's moon phase. It uses numpy, opencv and Ernie Wright's moon visualizations from the Dial-a-Moon project at Nasa Visualization Studio.

This package doesn't do much other than download an image from a predefined source, but I hope it's useful for someone else out there.

At time of publishing, this package can access any of the moon visualizations from 2011-2019. I suppose the way it's set up now, it'll need an update when the end of 2019 grows closer, and perhaps I'll find a better way to set it up by then.


To install this package, just run

pip install moon


Currently, this package will return a numpy array representing the lunar phase, as well as some json of the lunar stats from the Dial-a-Moon Nasa site. This array is usable as an image using openCV, or can be saved to disk as a .jpg file.

You can test it out using terminal:

from moon.terminal_ui import TerminalUi

ui = TerminalUi()
ui.set_moon_image() #defaults to today's date

You can alternately test it out using Jupyter notebooks:

from moon.jupyter_ui import JupyterUi

ui = JupyterUi()
ui.set_moon_image() #defaults to today's date

To just use it in a project, you can use it like this:

from moon.dialamoon import Moon

moon = Moon()

and access the image array itself with


At the moment, there isn't any built in method for converting the numpy array to a Pillow image. I had this set up with Pillow originally, but it fell by the wayside when I moved over to playing around with openCV.


Please feel free to post bugs, suggestions and feature requests on this repo. Through some trial and error, I think I finally have the package as simple as possible, but I'm open to evolution. This will be my first time creating and maintaining a python package, and I am receptive to any tips or PRs as far as best-practices go.


moon ascii art courtesy of jsg

        _..._           _..._            _..._            _..._            _..._
      .:::::::.       .::::. `.        .::::  `.        .::'   `.        .'     `.
     :::::::::::     :::::::.  :      ::::::    :      :::       :      :         :  
     :::::::::::     ::::::::  :      ::::::    :      :::       :      :         :
     `:::::::::'     `::::::' .'      `:::::   .'      `::.     .'      `.       .'
       `':::''         `'::'-'         `'::.-'           `':..-'          `-...-'

        _..._           _..._           _..._            _..._            _..._
      .'     `.       .'   `::.       .'  ::::.        .' .::::.        .:::::::.
     :         :     :       :::     :    ::::::      :  ::::::::      ::::::::::: 
     :         :     :       :::     :    ::::::      :  ::::::::      :::::::::::
     `.       .'     `.     .::'     `.   :::::'      `. '::::::'      `:::::::::'
       `-...-'         `-..:''         `-.::''          `-.::''          `':::''
You can’t perform that action at this time.