Gets moon visualizations courtesy of SVS, NASA, Ernie Wright
Project description
_..._ _..._ _..._ _..._ _..._
.:::::::. .::::. `. .:::: `. .::' `. .' `.
::::::::::: :::::::. : :::::: : ::: : : :
::::::::::: :::::::: : :::::: : ::: : : :
`:::::::::' `::::::' .' `::::: .' `::. .' `. .'
`':::'' `'::'-' `'::.-' `':..-' `-...-'
_..._ _..._ _..._ _..._ _..._
.' `. .' `::. .' ::::. .' .::::. .:::::::.
: : : ::: : :::::: : :::::::: :::::::::::
: : : ::: : :::::: : :::::::: :::::::::::
`. .' `. .::' `. :::::' `. '::::::' `:::::::::'
`-...-' `-..:'' `-.::'' `-.::'' `':::''
moon
This is a Python package that 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's Scientific Visualization Studio.
At time of last release, this package can access any of the moon visualizations from 2011-2022. In November of each calendar year, the data for the next year's moon becomes available on SVS, so for best performance, the new version of this package should be installed at the end of each year.
Installation
To install this package, just run
pip install moon
Usage
Currently, this package can get a NumPy.ndarray 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_phase() #defaults to today's date
print(ui.moon_datetime_info)
ui.show()
You can alternately test it out using Jupyter notebooks:
from moon.jupyter_ui import JupyterUi
ui = JupyterUi()
ui.set_moon_phase() #defaults to today's date
print(ui.moon_datetime_info)
ui.show()
To just use it in a project, you can use it like this:
from moon.dialamoon import Moon
moon = Moon()
moon.set_moon_phase()
and access the image array itself with
moon.image
You can save the current image to disk with the method moon.save_to_disk('filename')
or ui.save_to_disk('filename')
, which would save a filename.jpg
in your current directory.
Updates
Please feel free to post bugs, suggestions and feature requests on this repo. This will be my first time creating and maintaining a python package, and I am receptive to any recommendations or PRs.
1.1.2 2021-01-24
- can include
hour
parameter inMoon.set_moon_phase()
1.1.3 2021-05-01
- update numpy and opencv-python versions
- fix lru_cache decorator to fix issue #4
1.1.5 2021-12-30
- put constants in a
.json
file instead of a.py
file - add SVS ID for 2022
- if a SVS ID for a year isn't available, check whether it's available on in
res/constants.json
on the GitHub repo and then remind the user to update the package for next time
todo
- check whether there are edge cases where json mooninfo or date attributes might not match the currently requested moon phase
- make a clearer method for loading previously downloaded images/json as the current moon phase and data
Resources:
moon ascii art courtesy of jsg
_..._ _..._ _..._ _..._ _..._
.:::::::. .::::. `. .:::: `. .::' `. .' `.
::::::::::: :::::::. : :::::: : ::: : : :
::::::::::: :::::::: : :::::: : ::: : : :
`:::::::::' `::::::' .' `::::: .' `::. .' `. .'
`':::'' `'::'-' `'::.-' `':..-' `-...-'
_..._ _..._ _..._ _..._ _..._
.' `. .' `::. .' ::::. .' .::::. .:::::::.
: : : ::: : :::::: : :::::::: :::::::::::
: : : ::: : :::::: : :::::::: :::::::::::
`. .' `. .::' `. :::::' `. '::::::' `:::::::::'
`-...-' `-..:'' `-.::'' `-.::'' `':::''
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file moon-1.1.9.tar.gz
.
File metadata
- Download URL: moon-1.1.9.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d246aab5925f127a7758b06c957003a8b8ba91939bf14d9343d839785b9ee4ea |
|
MD5 | 62eb2872fd1eea41612d6e8af6c6a21f |
|
BLAKE2b-256 | 1ecb1368644cafbed0cdd4deb4a9572bcc269289b2dd078961fc448a754dcb70 |