I have a need (for an illumination purpose; nothing to do with weather!) for an program algorithm to calculate the time of sunrise and sunset at my location (within 5-10 minutes is sufficient). I Googled for it and found many sites with different equations, but they mostly required the input of 'local noon' (or 'solar noon') - the local time at which the sun is actually 'overhead', usually not 12noon). So then I went looking for a local noon algorithm, and that was just as confusing!
I know it's not going to be 'easy', but I'm wondering if anyone can steer me to an 'all-in-one' algorithm that (roughly) calculates sunset time per my local clock, based (of course) on my lat and long and time zone. Maybe the one Steve uses in Cumulus (which seems pretty accurate!)?
Any help greatly appreciated!
Welcome to the Cumulus Support forum.
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
Sunrise/set calculation algorithm (cadge!)
- DanielF
- Posts: 184
- Joined: Tue 30 Dec 2008 12:53 pm
- Weather Station: Davis Vantage Vue, serial logger
- Operating System: Win10Pro64
- Location: Gerroa, NSW, Australia
Re: Sunrise/set calculation algorithm (cadge!)
It's OK! After much more searching I eventually found SUNRISET.C, which looks like it will do what I want.
Sorry to have bothered you!
Sorry to have bothered you!
-
AllyCat
- Posts: 1132
- Joined: Sat 26 Feb 2011 1:58 pm
- Weather Station: Fine Offset 1080/1 & 3080
- Operating System: Windows XP SP3
- Location: SE London
Re: Sunrise/set calculation algorithm (cadge!)
Hi Daniel,
Yes the "movement" of noon (and of course sunrise/sunset) is called the "Equation Of Time" and amounts to just over +/- 15 minutes through two cycles (not simple sine waves) each year. It's due to the elliptical orbit of the Earth around the Sun so the maths is quite complicated. Most calculations/spreadsheets seem to trace back to some routines published by NOAA.
You haven't said on what platform/language you want to do the calculation, but for only +/- 5 minutes accuracy, interpolating between values from the addition of two lookup tables (for daily SR/SS and EOT) may be the simplest. It is possible to calculate even using integer maths in Basic, however not recommended (I know I've done it, but the code is not "finalised" yet).
Cheers, Alan.
Yes the "movement" of noon (and of course sunrise/sunset) is called the "Equation Of Time" and amounts to just over +/- 15 minutes through two cycles (not simple sine waves) each year. It's due to the elliptical orbit of the Earth around the Sun so the maths is quite complicated. Most calculations/spreadsheets seem to trace back to some routines published by NOAA.
You haven't said on what platform/language you want to do the calculation, but for only +/- 5 minutes accuracy, interpolating between values from the addition of two lookup tables (for daily SR/SS and EOT) may be the simplest. It is possible to calculate even using integer maths in Basic, however not recommended (I know I've done it, but the code is not "finalised" yet).
Cheers, Alan.
- DanielF
- Posts: 184
- Joined: Tue 30 Dec 2008 12:53 pm
- Weather Station: Davis Vantage Vue, serial logger
- Operating System: Win10Pro64
- Location: Gerroa, NSW, Australia
Re: Sunrise/set calculation algorithm (cadge!)
Alan,AllyCat wrote:You haven't said on what platform/language you want to do the calculation, but for only +/- 5 minutes accuracy, interpolating between values from the addition of two lookup tables (for daily SR/SS and EOT) may be the simplest.
Thanks for your comments. As you can see, I've already found a solution in the C language. I would have looked at an algorithm in almost any language, but C or assembler are ideal.
Just for your interest, this is going into a touch-screen 'industrial' PC running MS-DOS 6.22, which provides the user interface for my hi-fi controller, and I programmed in C and assembler. The 'real' control is done by a 'Switch-Box' that I designed and programmed, also in C. That box has a 2-line backlit LCD for control info display. I want to dim the LCD backlight according to day/night (also active/idle), which is why I want to calculate sunrise/set times.
The touch-PC will (when I've incorporated SUNRISET.C) send a command to the Switch-Box to tell it whether it's 'day' or 'night', so the LCD backlight can be dimmed accordingly (it's just below my TV, so I don't want it distractingly bright!
- beteljuice
- Posts: 3292
- Joined: Tue 09 Dec 2008 1:37 pm
- Weather Station: None !
- Operating System: W10 - Threadripper 16core, etc
- Location: Dudley, West Midlands, UK
Re: Sunrise/set calculation algorithm (cadge!)
Just because it's sunrise (or midday) doesn't mean it is bright, why not a simple sensor ?I want to dim the LCD backlight according to day/night (also active/idle), which is why I want to calculate sunrise/set times.
......................Imagine, what you will KNOW tomorrow !
- DanielF
- Posts: 184
- Joined: Tue 30 Dec 2008 12:53 pm
- Weather Station: Davis Vantage Vue, serial logger
- Operating System: Win10Pro64
- Location: Gerroa, NSW, Australia
Re: Sunrise/set calculation algorithm (cadge!)
Good suggestion. And yes, I had previously thought about a sensor (when designing the Switch-Box), but it's not quite 'simple'!beteljuice wrote:Just because it's sunrise (or midday) doesn't mean it is bright, why not a simple sensor ?
It's never darker than night in the middle of the day (this is Australia, mate, not gloomy London!