JNRowe

Rise and fall

Accuracy of sunrise and sunset

Rise and fall

Important

This page is intended for use by people with no Python experience, as such it aims to be readable by non-programmers. It is not clean Python by any stretch of the imagination and doesn’t aim to be. If you’re not used to Python, and still find it unreadable drop me a mail and I’ll try to clear up any problems.

Return to the Comet McNaught page.

The astute among you will have realised by now that the scripts fail to take in to account the actual light level in any real form. I did give it some consideration, but there is no date or time for me to view the comet in astronomical darkness(Sun -18° below the horizon). The best I could achieve was either before sunrise or after sunset, so I’m just totally discounting the actual point of darkness in my own usage.

If you wished to calculate occurrences in darkness you would just have to change a few details. To start with you must reset your date to the rise time of the comet:

home.date = McNaught.rise_time
Sun.compute(home)

Note

The reason you need to reset home.date is the script assumes calculation at midnight, which works because we only ask for the next rise and set times. If you don’t reset the value of home.date calls to sun.alt would be calculated against 00:00 UTC for the given date.

Then you would test that the Sun altitude is less than -18° below the horizon, before displaying the information. Remembering again that PyEphem uses radians for angular measurements, you could use a snippet similar to the following:

if sun.alt < math.radians(-18):
    print "Comet McNaught rises in astronomical darkness."
elif sun.alt < 0:
    print "Comet McNaught rises before sunrise."
else:
    print "Comet McNaught rises after sunrise."

You could instead test that Sun.alt is less than -0.314159265359 radians, if you would prefer to work in radians. -18° could also be expressed in a more workable form as math.pi/10 radians.

A similar method would need to be followed for calculating occurrences of darkness after sunset.

Return to the Comet McNaught page.

Return to Top