Modified:
/pycalcal.nw
=======================================
--- /pycalcal.nw Tue Jan 19 08:26:19 2010
+++ /pycalcal.nw Wed Jan 27 12:10:30 2010
@@ -3295,50 +3295,99 @@
######################
# Time and Astronomy #
######################
-def `ecliptical_from_equatorial(decl, ra, obli):
+def `ecliptical_from_equatorial(ra, declination, obliquity):
"""Convert equatorial coordinates to ecliptical ones.
- Decl is the declination, ra is the right ascension and
- obl is the obliquity of the ecliptic.
- NOTE: if 'apparent' right ascension and declination are
- used, then 'true' obliquity should be input.
+ 'declination' is the declination,
+ 'ra' is the right ascension and
+ 'obliquity' is the obliquity of the ecliptic.
+ NOTE: if 'apparent' right ascension and declination are used,
then 'true'
+ obliquity should be input.
"""
lon = degrees_from_radians(
- atan2(sin_degrees(ra)*cos_degrees(obli) +
- tan_degrees(decl)*sin_degrees(obli),
+ atan2(sin_degrees(ra)*cos_degrees(obliquity) +
+ tan_degrees(declination)*sin_degrees(obliquity),
cos_degrees(ra)))
- lat = arcsin_degrees(sin_degrees(decl)*cos_degrees(obli) -
-
cos_degrees(decl)*sin_degrees(obli)*sin_degrees(ra))
+ lat = arcsin_degrees(
+ sin_degrees(declination)*cos_degrees(obliquity) -
+
cos_degrees(declination)*sin_degrees(obliquity)*sin_degrees(ra))
return lon, lat
-def `equatorial_from_ecliptical(lam, beta, obli):
+
+
+# def ecl_to_equ(longitude, latitude, obliquity):
+# """Convert ecliptic to equitorial coordinates.
+
+# [Meeus-1998: equations 13.3, 13.4]
+
+# Parameters:
+# longitude : ecliptic longitude in radians
+# latitude : ecliptic latitude in radians
+# obliquity : obliquity of the ecliptic in radians
+
+# Returns:
+# Right accension in radians
+# Declination in radians
+
+# """
+# cose = cos(obliquity)
+# sine = sin(obliquity)
+# sinl = sin(longitude)
+# ra = modpi2(atan2(sinl * cose - tan(latitude) * sine,
cos(longitude)))
+# dec = asin(sin(latitude) * cose + cos(latitude) * sine * sinl)
+# return ra, dec
+
+
+def `equatorial_from_ecliptical(longitude, latitude, obliquity):
"""Convert ecliptical coordinates to equatorial ones.
- Lam is the ecliptical longitude, beta is ecliptical latitude and
- epsi is the obliquity of the ecliptic.
- NOTE: if 'apparent' right ascension and declination are to be
- used, then 'true' obliquity should be input.
- NOTE: beta is positive if north of ecliptic.
+ 'longitude' is the ecliptical longitude,
+ 'latitude' is thestarting ecliptical latitude and
+ 'obliquity' is the obliquity of the ecliptic.
+ NOTE: resuting ra and declination will be referred to the same equinox
+ as the one of input ecliptical longitude and latitude.
"""
ra = degrees_from_radians(
- atan2(sin_degrees(lam)*cos_degrees(obli) -
- tan_degrees(beta)*sin_degrees(obli),
- cos_degrees(lam)))
- dec = arcsin_degrees(sin_degrees(beta)*cos_degrees(obli) +
-
cos_degrees(beta)*sin_degrees(obli)*sin_degrees(lam))
+ atan2(sin_degrees(longitude)*cos_degrees(obliquity) -
+ tan_degrees(latitude)*sin_degrees(obliquity),
+ cos_degrees(longitude)))
+ dec = arcsin_degrees(
+ sin_degrees(latitude)*cos_degrees(obliquity) +
+
cos_degrees(latitude)*sin_degrees(obliquity)*sin_degrees(longitude))
return ra, dec
-def `horizontal_from_ecliptical(ra, dec, tee, location, nut=False):
+
+
+# def horizontal_from_equatorial(H, declination):
+# """Convert equitorial to horizontal coordinates.
+# NOTE: azimuth is measured westward from the South.
+# NOTE:
+# This is not a good formula for using near the poles.
+
+# Parameters:
+# H : hour angle in radians
+# decl : declination in radians
+
+# Returns:
+# azimuth in radians
+# altitude in radians
+
+# """
+# cosH = cos(H)
+# sinLat = sin(astrolabe.globals.latitude)
+# cosLat = cos(astrolabe.globals.latitude)
+# A = atan2(sin(H), cosH * sinLat - tan(decl) * cosLat)
+# h = asin(sinLat * sin(decl) + cosLat * cos(decl) * cosH)
+# return A, h
+
+
+
+def `horizontal_from_ecliptical(ra, dec, ha, location):
"""Convert equatorial coordinates to horizontal ones.
ra is the right ascension, decl is the declination,
- location is the geographical position of the observer,
- tee is a moment in universal time.
- NOTE: if ra is affected by nutation, then sideral time too
+ location is the observer's position on Earth,
+ hs is the local hour angle (ha=theta - ra; theta is local sidereal
time).
+ NOTE: if ra is affected by nutation, then sidereal time too
must be affected by it.
"""
- theta_0 = sidereal_from_moment(tee)
- if nut:
- theta_0 += nutation(tee)*cos_degrees(obliquity(tee))/15.0
- L = longitude(location)
- H = theta_0 - L - ra
phi = latitude(location)
az = degrees_from_radians(atan2(sin_degrees(H),
cos_degrees(H)*sin_degrees(phi) -