mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-18 22:01:42 -04:00
Added culminate.py demo program.
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
each body's "hour angle" is 0.
|
||||
|
||||
Having an hour angle of 0 is another way of saying that the body is
|
||||
crossing the meridian, the imaginary semicircle in the sky that passes
|
||||
from due north on the horizon, through the zenith (straight up),
|
||||
toward due south on the horizon. At this moment the body appears to
|
||||
crossing the meridian, the imaginary semicircle in the sky that passes
|
||||
from due north on the horizon, through the zenith (straight up),
|
||||
toward due south on the horizon. At this moment the body appears to
|
||||
have an azimuth of either 180 degrees (due south) or 0 (due north).
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,7 @@ int PrintEvent(const char *name, astro_hour_angle_t evt)
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
static const astro_body_t bodies[] =
|
||||
static const astro_body_t bodies[] =
|
||||
{
|
||||
BODY_SUN, BODY_MOON, BODY_MERCURY, BODY_VENUS, BODY_MARS,
|
||||
BODY_JUPITER, BODY_SATURN, BODY_URANUS, BODY_NEPTUNE, BODY_PLUTO
|
||||
|
||||
@@ -5,7 +5,7 @@ Fail()
|
||||
exit 1
|
||||
}
|
||||
|
||||
rm -f moonphase positions
|
||||
rm -f moonphase positions riseset seasons culminate test/{moonphase,positions,riseset,seasons,culminate}.txt
|
||||
./build || Fail "Error building example programs."
|
||||
|
||||
echo "Testing example: moonphase.c"
|
||||
|
||||
34
demo/python/culminate.py
Executable file
34
demo/python/culminate.py
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# culminate.py - Don Cross - 2019-08-10
|
||||
#
|
||||
# Example program for Astronomy Engine:
|
||||
# https://github.com/cosinekitty/astronomy
|
||||
#
|
||||
# This example program shows how to calculate the time
|
||||
# the Sun, Moon, and planets will next reach their highest point in the sky
|
||||
# as seen by an observer at a given location on the Earth.
|
||||
# This is called culmination, and is found by finding when
|
||||
# each body's "hour angle" is 0.
|
||||
#
|
||||
# Having an hour angle of 0 is another way of saying that the body is
|
||||
# crossing the meridian, the imaginary semicircle in the sky that passes
|
||||
# from due north on the horizon, through the zenith (straight up),
|
||||
# toward due south on the horizon. At this moment the body appears to
|
||||
# have an azimuth of either 180 degrees (due south) or 0 (due north).
|
||||
|
||||
import sys
|
||||
from astronomy import Body, SearchHourAngle
|
||||
from astro_demo_common import ParseArgs
|
||||
|
||||
if __name__ == '__main__':
|
||||
observer, time = ParseArgs(sys.argv)
|
||||
body_list = [
|
||||
Body.Sun, Body.Moon, Body.Mercury, Body.Venus, Body.Mars,
|
||||
Body.Jupiter, Body.Saturn, Body.Uranus, Body.Neptune, Body.Pluto
|
||||
]
|
||||
print('search :', time)
|
||||
for body in body_list:
|
||||
evt = SearchHourAngle(body, observer, 0.0, time)
|
||||
print('{:<8s} : {} altitude={:6.2f} azimuth={:7.2f}'.format(body.name, evt.time, evt.hor.altitude, evt.hor.azimuth))
|
||||
sys.exit(0)
|
||||
@@ -1,11 +1,11 @@
|
||||
search : 2015-02-28T00:00:00.000Z
|
||||
Sun : 2015-02-28T18:12:32.330Z altitude= 52.13 azimuth= 180.00
|
||||
Moon : 2015-02-28T01:58:15.580Z altitude= 77.88 azimuth= 180.00
|
||||
Mercury : 2015-02-28T16:31:18.913Z altitude= 42.57 azimuth= 180.00
|
||||
Venus : 2015-02-28T20:03:56.863Z altitude= 63.24 azimuth= 180.00
|
||||
Mars : 2015-02-28T19:52:21.650Z altitude= 62.24 azimuth= 180.00
|
||||
Jupiter : 2015-02-28T04:40:04.004Z altitude= 77.29 azimuth= 180.00
|
||||
Saturn : 2015-02-28T11:40:53.866Z altitude= 40.96 azimuth= 180.00
|
||||
Uranus : 2015-02-28T20:20:51.250Z altitude= 65.12 azimuth= 180.00
|
||||
Neptune : 2015-02-28T18:04:23.941Z altitude= 50.53 azimuth= 180.00
|
||||
Pluto : 2015-02-28T14:31:39.410Z altitude= 39.51 azimuth= 180.00
|
||||
Mercury : 2015-02-28T16:31:18.914Z altitude= 42.57 azimuth= 180.00
|
||||
Venus : 2015-02-28T20:03:56.864Z altitude= 63.24 azimuth= 180.00
|
||||
Mars : 2015-02-28T19:52:21.651Z altitude= 62.24 azimuth= 180.00
|
||||
Jupiter : 2015-02-28T04:40:04.005Z altitude= 77.29 azimuth= 180.00
|
||||
Saturn : 2015-02-28T11:40:53.867Z altitude= 40.96 azimuth= 180.00
|
||||
Uranus : 2015-02-28T20:20:51.251Z altitude= 65.12 azimuth= 180.00
|
||||
Neptune : 2015-02-28T18:04:23.942Z altitude= 50.53 azimuth= 180.00
|
||||
Pluto : 2015-02-28T14:31:39.411Z altitude= 39.51 azimuth= 180.00
|
||||
|
||||
@@ -5,6 +5,8 @@ Fail()
|
||||
exit 1
|
||||
}
|
||||
|
||||
rm -f test/{moonphase,positions,riseset,seasons,culminate}.txt
|
||||
|
||||
echo "Testing example: moonphase.py"
|
||||
./moonphase.py 2019-06-15T09:15:32.987Z > test/moonphase.txt || Fail "Error running moonphase.py."
|
||||
diff test/moonphase.txt test/moonphase_correct.txt || Fail "Error comparing moonphase.py output."
|
||||
@@ -21,12 +23,9 @@ echo "Testing example: seasons.py"
|
||||
./seasons.py 2019 > test/seasons.txt || Fail "Error running seasons.py."
|
||||
diff test/seasons.txt test/seasons_correct.txt || Fail "Error comparing seasons.py output."
|
||||
|
||||
if false; then
|
||||
|
||||
echo "Testing example: culminate.py"
|
||||
./culminate +30 -90 2015-02-28T00:00Z > test/culminate.txt || Fail "Error running culminate.py."
|
||||
diff test/culminate.txt test/culminate_correct.txt || Fail "Error comparing culminate.py output."
|
||||
fi
|
||||
echo "Testing example: culminate.py"
|
||||
./culminate.py +30 -90 2015-02-28T00:00:00Z > test/culminate.txt || Fail "Error running culminate.py."
|
||||
diff test/culminate.txt test/culminate_correct.txt || Fail "Error comparing culminate.py output."
|
||||
|
||||
echo "PASS: Python examples"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user