Identifying Sun and Moon Transits


Senior Member
I wrote a python program for identifying potential sun or moon transits involving a certain observer location but an uncertain observing time and/or date. It searches a TLE file containing satellite orbits for transits of the sun or moon over a user-specified number of days at a given location and outputs the name of the satellite, the time of the transit, and the azimuth and altitude of the sun or moon at the time of the transit.

One limitation here is that it assumes that you are specifying precise coordinates for the observer; it will not find nearby transit corridors, only transits the user is actually able to observe at those coordinates. It can also miss edge cases where the satellite is clipping the edge of the sun or moon for < 1 second. Other than that it will search second by second through every satellite in the TLE file to compile a list of all transits that occurred over 1 or more days, provided the orbital elements are current to within a few days of the transit prediction (it skips any elements that are way out of date).

It uses Python and PyEphem. An installation tutorial for the dependencies can be found here, but you won't need OpenCV or ImUtils:


You execute the program from the command line by typing python latitude(North is positive) longitude(East is positive) elevation(meters) yyyy-mm-dd hh:mm:ss (of the start of the search) xxx.txt(TLE file containing satellite orbital elements) moon/sun(case insensitive) duration of search(whole number of days)

I tested it against CalSky and it seems to be accurate, but it's far more comprehensive than CalSky since you can load orbital elements for satellites that may not be in the CalSky database at the time. Enjoy.