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

Table of Contents

1. Introduction
1.1. References
1.2. Online files
2. jd: Convert date and time to Julian date
2.1. Prologue
2.2. Imports
2.3. main()
2.4. argCheck(): Check command line arguments
2.5. usage(): Print a usage message and stop
2.6. Epilogue
3. conjd: Convert Julian date to date and time
3.1. Prologue
3.2. Imports
3.3. main()
3.4. usage(): Write an error message and terminate
3.5. Epilogue
4. rdaa: Equatorial to horizon coordinates
4.1. Prologue
4.2. Imports
4.3. Constants
4.4. main()
4.5. checkArgs(): Process command-line arguments
4.6. usage(): Print a message and stop
4.7. checkRADec: Check equatorial coordinates
4.8. Epilogue
5. aard: Horizon to celestial coordinates
5.1. Prologue
5.2. Imports
5.3. Constants
5.4. main()
5.5. checkArgs(): Process command line arguments
5.6. usage(): Print a message and stop
5.7. checkAltAz(): Validate horizon coordinates
5.8. Epilogue
6. sidereal.py: Prologue
7. Imports
8. Manifest constants
8.1. FIRST_GREGORIAN_YEAR
8.2. TWO_PI
8.3. PI_OVER_12
8.4. JULIAN_BIAS
8.5. SIDEREAL_A: Sidereal time conversion factor
8.6. FLOAT_PAT: Regular expression for a floating-point number
8.7. D_PAT: Degrees code
8.8. M_PAT: Minutes code
8.9. S_PAT: Seconds code
8.10. H_PAT: Hours code
8.11. NS_PAT: Latitude suffix
8.12. EW_PAT: Longitude suffix
9. Exported functions
9.1. hoursToRadians(): Convert hours to radians
9.2. radiansToHours(): Convert hours to radians
9.3. hourAngleToRA(): Convert an hour angle to right ascension
9.4. raToHourAngle(): Convert a right ascension to an hour angle
9.5. dayNo(): Date to day number
9.6. parseDatetime(): Convert an external date-time string
9.7. parseDate(): Convert an external date string
9.8. parseTime(): Convert an external time string
9.9. parseZone(): Process a time zone suffix
9.10. parseFixedZone(): Parse fixed zone suffix
9.11. class FixedZone: Fixed-offset time zone
9.12. class USTimeZone: Time zone with daylight time
9.13. zoneCodeMap: Dictionary of time zones
9.14. parseAngle(): Convert an external angle string
9.15. parseFloatSuffix: Parse a number followed by a code
9.16. parseFloat(): Parse a floating-point number
9.17. parseRe(): Parse a regular expression
9.18. parseLat(): Convert an external latitude
9.19. parseLon(): Convert an external longitude
9.20. parseHours(): Convert an external quantity in hours
10. class MixedUnits: Operations on mixed-unit systems
10.1. MixedUnits.__init__(): Constructor
10.2. MixedUnits.mixToSingle(): Convert to a single value
10.3. MixedUnits.__pad(): Pad short coefficient lists to standard length
10.4. MixedUnits.singleToMix(): Convert to mixed units
10.5. MixedUnits.format(): Format mixed units
11. dmsUnits: Mixed-units converter
12. class LatLon: Observer latitude and longitude
12.1. LatLon.__init__(): Constructor
12.2. LatLon.__str__(): Convert to a string
13. class JulianDate: Julian calendar timestamp
13.1. JulianDate.__init__(): Constructor
13.2. JulianDate.__float__(): Convert to a float
13.3. JulianDate.datetime(): Convert to a datetime
13.4. JulianDate.offset(): Move a time by some number of days
13.5. JulianDate.__sub__(): Difference of two Julian dates
13.6. JulianDate.__cmp__(): Compare two Julian dates
13.7. JulianDate.fromDatetime(): Convert a datetime to a Julian date
14. class SiderealTime: Sidereal time
14.1. SiderealTime.__init__(): Constructor
14.2. SiderealTime.__str__(): Convert to string
14.3. SiderealTime.utc(): Find Universal Time
14.4. SiderealTime.factorB(): Compute sidereal time factor B (static method)
14.5. SiderealTime.gst(): Local to Greenwich sidereal
14.6. SiderealTime.lst(): Greenwich to local sidereal
14.7. SiderealTime.fromDatetime(): Convert UTC to GST (static method)
15. class AltAz: Horizon coordinates
15.1. AltAz.__init__(): Constructor
15.2. AltAz.raDec(): Horizon to equatorial coordinates
15.3. AltAz.__str__(): Convert to a string
16. coordRotate(): Rotation of spherical coordinates
17. class RADec: Equatorial coordinates
17.1. RADec.__init__(): Constructor
17.2. RADec.hourAngle(): Find the hour angle
17.3. RADec.altAz(): Equatorial to horizon coordinates
17.4. RADec.__str__(): Convert to a string
18. Regression tests
18.1. testmix: Test MixedUnits
18.2. test4-5: Converting to and from Julian day
18.3. test12-13: GMT to GST and back
18.4. test14-15: Converting between GST and LST
18.5. test24: Converting between right ascension and hour angle
18.6. test25-26: Equatorial to horizon coordinates and back

Abstract

sidereal.py is a Python module to perform certain astronomical calculations. This document contains and describes the implementation of the module.

This publication is available in Web form and also as a PDF document. Please forward any comments to tcc-doc@nmt.edu.

1. Introduction

This document contains the source code for the sidereal.py module. The technique of embedding the code in a document that explains its function is called literate programming; see the author's Lightweight Literate Programming page.

The reader is assumed to be familiar with the Python programming language, including object-oriented programming. Some familiarity with the problem domain—spherical astronomy—will also be useful.

1.1. References

The primary reference is Peter Duffett-Smith's Practical Astronomy with Your Calculator. For a full citation, see the specification.

Other useful online references:

1.2. Online files

Relevant online files: