No description
This repository has been archived on 2026-07-18. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Python 95.9%
  • Dockerfile 3.6%
  • Tcl 0.5%
Find a file
Ryan Grippeling 3a0e85908b
Merge pull request #3 from webgrip/renovate/python
chore(deps): update python
2026-02-13 07:13:36 +01:00
.github/workflows Stop running action every day, ran out of captcha credits 2025-05-22 08:25:02 +02:00
images Messed up the quarters 2025-02-09 17:11:57 +01:00
spicey Merge pull request #3 from webgrip/renovate/python 2026-02-13 07:13:36 +01:00
.gitignore Built js action 2025-02-09 15:20:13 +01:00
calc_shadow.py Make it with spicey 2025-02-11 18:20:37 +01:00
docker-compose.yml Make it with spicey 2025-02-11 18:20:37 +01:00
Dockerfile chore(deps): update python docker tag to v3.14.3 2026-02-12 09:52:35 +00:00
get_phase.py Only label full moon when is_near_full 2025-02-11 10:45:02 +01:00
readme.md Added readme 2025-02-11 19:03:45 +01:00
renovate.json Add renovate.json 2026-02-09 03:58:21 +00:00
requirements.txt chore(deps): update python 2026-02-11 00:09:03 +00:00

Moon Phase Image Generator 🌕

This project is a Python-based Moon phase image generator that leverages NASA's SPICE toolkit (via SpiceyPy) to accurately compute the Moons ephemeris data, including its phase, illumination, and position relative to both the Earth and the Sun. The generated images include a white Moon with a realistic shadow overlay representing the terminator, all composed together to form the final Moon phase image.


Features

  • Accurate Ephemeris Calculations: Uses SPICE kernels to compute the Moons phase angle, illuminated fraction, distance, and more.
  • Realistic Illumination: Computes a pixel-by-pixel shadow overlay based on the Moons local geometry.
  • Image Compositing: Combines a clean white Moon image with a shadow layer for a visually appealing final result.
  • Enhanced Logging: Clear, human-friendly logging messages with emojis to guide you through each step of the process.

Prerequisites

Before running the script, make sure you have the following installed:

  • Python 3
  • Required Python Packages:
    • numpy
    • matplotlib
    • spiceypy
    • astropy
    • Pillow

You can install the required packages using pip:

pip install numpy matplotlib spiceypy astropy pillow

SPICE Kernels

This project requires a SPICE meta-kernel file named moon.tm in the same directory as the script. This meta-kernel should reference the necessary SPICE kernels (e.g., leapseconds, planetary ephemerides) to allow the computations.


Usage

  1. Prepare the Environment:

    • Ensure you have Python 3 installed.
    • Install the required Python packages.
    • Place the moon.tm file in the project directory.
  2. Customize (Optional):

    • Observation Time: Modify the time_str variable in the main() function to set your desired UTC observation time.
    • Observer Location: Change the observer location (e.g., new_zealand or nl_location) in the script if needed.
    • Resolution: Adjust the resolution variable to change the image output resolution.
  3. Run the Script:

    Make the script executable and run it:

    chmod +x your_script.py
    ./your_script.py
    

    Or run it directly with Python:

    python your_script.py
    
  4. Output:
    The script will create an output directory containing:

    • moon.png: A white Moon image (a white circle with a black border) on a transparent background.
    • shadow.png: A shadow overlay image computed from the Moons illumination.
    • final.png: The final composite image with the Moon and its terminator (shadow overlay).

Logging

The script utilizes Python's logging module with a custom, emoji-enhanced format to provide clear and fun output messages as it processes the data. This makes it easy to follow along with each step—from loading the SPICE kernels to generating and compositing the images.


Customization

  • Observation Time:
    Change the time_str in the main() function.
    Example:

    time_str = '2026-05-31T18:30:00'
    
  • Observer Location:
    Modify the location variable in the main() function. The example uses New Zealands coordinates.
    Example:

    location = new_zealand
    
  • Image Resolution & Moon Radius:
    Adjust the resolution and R (Moon radius in arbitrary units) variables as desired for higher quality or differently scaled images.


License

This project is open source. Feel free to modify, extend, and distribute it as needed.


Acknowledgments

  • NASA SPICE Toolkit: For providing precise planetary and spacecraft ephemeris data.
  • SpiceyPy: The Python wrapper for the SPICE toolkit.
  • Astropy: For time and coordinate transformations.
  • Matplotlib & Pillow: For image creation and processing.

Enjoy generating stunning Moon phase images and may your projects always shine as bright as the Moon! 🌕🚀