[pycalcal] push by enrico.spinielli - added observed_lunar_altitude and moonrise. To be tested. on 2009-11-22 17:38 GMT

1 view
Skip to first unread message

pyca...@googlecode.com

unread,
Nov 22, 2009, 12:38:56 PM11/22/09
to pyca...@googlegroups.com
Revision: 52caec808b
Author: Enrico Spinielli <enrico.s...@gmail.com>
Date: Sun Nov 22 09:38:14 2009
Log: added observed_lunar_altitude and moonrise. To be tested.
http://code.google.com/p/pycalcal/source/detail?r=52caec808b

Modified:
/calendrica-3.0.errata.cl
/pycalcal.nw

=======================================
--- /calendrica-3.0.errata.cl Sat Nov 21 10:11:20 2009
+++ /calendrica-3.0.errata.cl Sun Nov 22 09:38:14 2009
@@ -451,8 +451,31 @@
(+ (angle 0 50 0) dip (* (secs 19) (sqrt h)))))

;; new (Errata '12:58pm, November 19, 2009')
-(observed-lunar-altitude ()
-())
+(defun observed-lunar-altitude (tee location)
+ ;; TYPE (moment location) -> angle
+ ;; Observed altitude of moon at $tee$ at $location$
+ ;; taking refraction into account.
+ (+ (topocentric-lunar-altitude tee location) (refraction tee location)))
+
+;; new (Errata '12:58pm, November 19, 2009')
+(defun moonrise (date location)
+ ;; TYPE (fixed-date location) -> moment
+ ;; Standard time of moonrise on fixed $date$ at
+ ;; $locale$.
+ (let* ((t (universal-from-standard date location))
+ (waning (> (lunar-phase t) (deg 180)))
+ (alt (observed-lunar-altitude t location))
+ (offset (/ alt 360))
+ (approx (cond ((and waning (> offset 0)) (1+ t -offset))
+ (waning (- t offset))
+ (t (+ t (/ 1 2) offset))))
+ (rise (binary-search
+ l (- approx (hr 3))
+ u (+ approx (hr 3))
+ x (> (observed-lunar-altitude x location) (deg 0))
+ (< (- u l) (hr (/ 1 60))))))
+ (if (< rise (1+ t)) (standard-from-universal rise location) bogus)))
+
;;;============================= History
=======================================
;; 2009/11/19 Enrico Spinielli
;; Extracted changes/enhancements from
=======================================
--- /pycalcal.nw Sat Nov 21 10:11:20 2009
+++ /pycalcal.nw Sun Nov 22 09:38:14 2009
@@ -3584,6 +3584,33 @@
alpha = refraction(date, location)
return dusk(date, location, alpha)

+# see lines 453-458 in calendrica-3.0.errata.cl
+def observed_lunar_altitude(tee, location):
+ """Return the observed altitude of moon at moment, tee, and
+ at location, location, taking refraction into account."""
+ return topocentric_lunar_altitude(tee, location) + refraction(tee,
location)
+
+# see lines 460-467 in calendrica-3.0.errata.cl
+def `moonrise(date, location):
+ """Return the standard time of moonrise on fixed, date,
+ and location, location."""
+ t = universal_from_standard(date, location)
+ waning = (lunar_phase(t) > deg(180))
+ alt = observed_lunar_altitude(t, location)
+ offset = alt / 360
+ if (waning and (offset > 0)):
+ approx = t + 1 - offset
+ elif waning:
+ approx = t - offset
+ else:
+ approx = t + (1 / 2) + offset
+ rise = binary_search(approx - hr(3),
+ approx + hr(3),
+ lambda u, l: ((u - l) < hr(1 / 60)),
+ lambda x: observed_lunar_altitude(x, location) >
deg(0))
+ return standard_from_universal(rise, location) if (rise < (t + 1))
else BOGUS
+
+
def `urbana_sunset(gdate):
"""Return sunset time in Urbana, Ill, on Gregorian date 'gdate'."""
return time_from_moment(sunset(fixed_from_gregorian(gdate), URBANA))
@@ -5532,9 +5559,9 @@
hindu_lunar_phase(tee) *
HINDU_SYNODIC_MONTH)
return binary_search(tau - 1, min(tee, tau + 1),
- lambda l, u: ((hindu_zodiac(l) ==
(hindu_zodiac(u)) or
- ((u - l) < varepsilon))),
- lambda x: (hindu_lunar_phase(x) < deg(180)))
+ lambda l, u: ((hindu_zodiac(l) ==
hindu_zodiac(u)) or
+ ((u - l) < varepsilon)),
+ lambda x: hindu_lunar_phase(x) < deg(180))


# see lines 4975-4988 in calendrica-3.0.cl
Reply all
Reply to author
Forward
0 new messages