Next / Previous / Contents / TCC Help System / NM Tech homepage

18.6. test25-26: Equatorial to horizon coordinates and back

This script exercises Section 15.2, “AltAz.raDec(): Horizon to equatorial coordinates” and Section 17.3, “RADec.altAz(): Equatorial to horizon coordinates”, sections 25 and 26 of Duffett-Smith. Here is the problem statement for the forward conversion; the book's answer is a=19° 20′ 02″, A=283° 16′ 18″.

What are the altitude and azimuth of a star whose hour-angle is 05h 51m 44s and declination is 23° 13′ 10″? The observer's latitude is 52° N.

test25-26
#!/usr/bin/env python
#================================================================
# test25-26:  Test equatorial <-> horizon coordinates.
#   For documentation, see:
#     http://www.nmt.edu/tcc/help/lang/python/examples/sidereal/ims/
#----------------------------------------------------------------

import math
import datetime
import sidereal

First we set up a MixedUnits instance to do mixed-unit conversion and formatting. Then we set up the inputs: the equatorial coordinates, the hour angle, and the observer's latitude.

test25-26
#--
# Converter for mixed units
#--
dmsUnits = sidereal.MixedUnits ( (60, 60) )

#--
# Set up inputs
#--

dec  =  math.radians ( dmsUnits.mixToSingle ( (23, 13, 10) ) )
raDec = sidereal.RADec ( 0.0, dec )
hHours  =  dmsUnits.mixToSingle ( (5, 51, 44) )
hRadians  =  sidereal.hoursToRadians ( hHours )
lat = math.radians ( 52.0 )
latLon = sidereal.LatLon ( lat, 0.0 )

The result returned by RADec.altAz is an AltAz instance, which we then display.

test25-26
#--
# Convert to horizon coordinates
#--
altAz  =  raDec.altAz ( hRadians, lat )
print "Horizon coordinates:", altAz

Finally we do the back-conversion.

test25-26
#--
# Convert back to an hour angle.
#--
gst = sidereal.SiderealTime ( dmsUnits.mixToSingle ( (0, 24, 05) ) )
check = altAz.raDec ( gst, latLon )
print "Check RA/Dec:", check