-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add moon phase calculations #96
Open
djhoese
wants to merge
23
commits into
main
Choose a base branch
from
feature-moon-phase
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
89fe3f8
Some experimental code to derive the phase of the moon and positions …
adybbroe 38c563f
Adding some more test code
adybbroe e745a78
Merge branch 'pre-master' into feature-moon-phase
adybbroe 90bef60
Merge branch 'pre-master' into feature-moon-phase
adybbroe 2dcf71b
editorial
adybbroe 802e6cd
Adding copyright header
adybbroe 6f7068d
Add header to the two test programs for moon position and phase
7072c70
Add documentation and unit tests for moon calculations
76bc3ac
Rearrange scripts to compare against pyephem
24fbf05
Adding documentation of moon calculations
a185712
Remove dependency on sphinxtogithub
943ae46
Make Julian function handle arrays/sequences
b33021c
Merge branch 'develop' into feature-moon-phase
7fe89dd
Merge develop into feature-moon-phase
cea1489
Fix to be able to run tests
d446c86
Add documentation on accuracy and comparison to pyephem
2c69ecf
Add unit test for array arithmetics on moon position
1be1aa0
Structure the documentation pages
f4372e7
Fix typo
d22cb3f
Prepare for support for array arithmetics
7108093
Support for array arithmetics
6c0c308
Merge branch 'master' into feature-moon-phase
adybbroe 0613ad4
Fixing style errors.
stickler-ci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
API | ||
--- | ||
|
||
Orbital computations | ||
~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. automodule:: pyorbital.orbital | ||
:members: | ||
:undoc-members: | ||
|
||
TLE handling | ||
~~~~~~~~~~~~ | ||
|
||
.. automodule:: pyorbital.tlefile | ||
:members: | ||
:undoc-members: | ||
|
||
Astronomical computations | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. automodule:: pyorbital.astronomy | ||
:members: | ||
:undoc-members: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Computing astronomical parameters | ||
--------------------------------- | ||
The astronomy module enables computation of certain parameters of interest for | ||
satellite remote sensing for instance the Sun-zenith angle: | ||
|
||
>>> from pyorbital import astronomy | ||
>>> from datetime import datetime | ||
>>> utc_time = datetime(2012, 5, 15, 15, 45) | ||
>>> lon, lat = 12, 56 | ||
>>> astronomy.sun_zenith_angle(utc_time, lon, lat) | ||
62.685986438071602 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Moon phase and position with Pyorbital | ||
====================================== | ||
|
||
It is possible to calculate the phase and position of the moon at any given | ||
time in the past or future. This is done by an implementation of the | ||
astronimical methods described at Stjaernhimlen_. The calculations have been | ||
compared to the pyephem library, and deviations are small, see below. | ||
|
||
|
||
Computing the phase of the moon | ||
------------------------------- | ||
|
||
>>> from datetime import datetime | ||
>>> from pyorbital.moon_phase import moon_phase | ||
>>> time_t = datetime(2011, 12, 1, 12) | ||
>>> print moon_phase(time_t) | ||
0.409752921579 | ||
|
||
It works also with datetime sequences: | ||
|
||
>>> import numpy as np | ||
>>> from pyorbital.moon_phase import moon_phase | ||
>>> time_t = np.arange('2005-02', '2005-03', dtype='datetime64[D]') | ||
>>> print moon_phase(time_t) | ||
[ 6.36537786e-01 5.32201222e-01 4.23413367e-01 3.15141455e-01 | ||
2.13350898e-01 1.24769455e-01 5.62102473e-02 1.34598103e-02 | ||
4.68042562e-05 1.64235364e-02 5.99725484e-02 1.25824054e-01 | ||
2.08064456e-01 3.00824090e-01 3.98939205e-01 4.98161316e-01 | ||
5.95059508e-01 6.86787971e-01 7.70852355e-01 8.44942289e-01 | ||
9.06852663e-01 9.54487201e-01 9.85925226e-01 9.99530703e-01 | ||
9.94086558e-01 9.68941138e-01 9.24152715e-01 8.60612554e-01] | ||
|
||
|
||
Computing the position of the moon | ||
---------------------------------- | ||
|
||
>>> from datetime import datetime | ||
>>> from pyorbital import planets | ||
>>> time_t = datetime(2016, 7, 30, 0, 0) | ||
>>> moon = planets.Moon(time_t) | ||
>>> lon = 20.0 | ||
>>> lat = 65.0 | ||
>>> rasc, decl, alt, azi = moon.topocentric_position(lon, lat) | ||
>>> print alt, azi | ||
6.33389454706 61.6795817556 | ||
|
||
And for an array of longitudes and latitudes: | ||
|
||
>>> import numpy as np | ||
>>> lons = np.arange(100).reshape(10,10) | ||
>>> lats = np.arange(100).reshape(10,10) * 0.9 | ||
>>> rasc, decl, alt, azi = moon.topocentric_position(lons, lats) | ||
>>> print alt.shape | ||
(10, 10) | ||
>>> print alt[4,8] | ||
14.9564426346 | ||
|
||
|
||
Accuracy | ||
-------- | ||
|
||
In lack of an absolute truth or reference the moon calclations with Pyorbital | ||
have been compared to pyephem. There are indeed deviations, but for the moon | ||
phase they are in general rather small. See image below, where we compare the | ||
moon phase over 416 days starting from December 1st 2015. As seen from the | ||
figure the deviations are within 0.3 %. | ||
|
||
.. image:: _static/moonphase_compare.png | ||
|
||
For moon height and azimuth differences are larger, as seen from the figures | ||
below. We have calculated the position of the moon relative to the City of | ||
Norrköping, Sweden, over four months from March 7, 2012. The deviations are | ||
within 4 degrees for the height, and within 9 degrees for the azimuth. | ||
|
||
|
||
.. image:: _static/moonheight_compare.png | ||
.. image:: _static/moonazimuth_compare.png | ||
|
||
|
||
|
||
.. _`Stjaernhimlen`: http://www.stjarnhimlen.se/comp/ppcomp.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
Computing satellite postion | ||
--------------------------- | ||
The orbital module enables computation of satellite position and velocity at a | ||
specific time: | ||
|
||
>>> from pyorbital.orbital import Orbital | ||
>>> from datetime import datetime | ||
>>> orb = Orbital("noaa 18") | ||
>>> now = datetime.utcnow() | ||
>>> # Get normalized position and velocity of the satellite: | ||
>>> orb.get_position(now) | ||
([0.57529384846822862, 0.77384005228105424, 0.59301408257897559], | ||
[0.031846489698768146, 0.021287993461926374, -0.05854106186659274]) | ||
>>> # Get longitude, latitude and altitude of the satellite: | ||
>>> orb.get_lonlatalt(now) | ||
(-1.1625895579622014, 0.55402132517640568, 847.89381184656702) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
TLE files | ||
--------- | ||
Pyorbital has a module for parsing NORAD TLE-files | ||
|
||
>>> from pyorbital import tlefile | ||
>>> tle = tlefile.read('noaa 18', '/path/to/my/tle_file.txt') | ||
>>> tle.inclination | ||
99.043499999999995 | ||
|
||
If no path is given pyorbital tries to read the earth observation TLE-files | ||
from celestrak.com | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E265 block comment should start with '# '
E501 line too long (99 > 79 characters)