Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Sunrise - Sunset Calculator (Ruby)

Post any examples or modules that you want to share here

Sunrise - Sunset Calculator (Ruby)

Postby DaveyBoy » Mon Apr 03, 2017 11:56 am

So I found this Sunrise - Sunset formula on-line and thought it would be interesting to put it into Ruby, so I did, and it worked (eventually) :lol:

Here it is for anyone who's interested:

Sunset Algorithm with Altitude.fsm
(2.04 KiB) Downloaded 1090 times
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Sunrise - Sunset Calculator (Ruby)

Postby RJHollins » Mon Apr 03, 2017 6:19 pm

that is cool !
8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: Sunrise - Sunset Calculator (Ruby)

Postby DaveyBoy » Mon Apr 03, 2017 7:30 pm

Yeah I thought so too. It seems very accurate when compared to on-line calculators. Not too sure about the altitude though . . . I added that myself after a little googling, hope I got it right :oops:
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Sunrise Sunset Calculator Ruby

Postby PrDavid » Wed Apr 05, 2017 8:30 am

The calculated times for sunset/sunrise are 4 hours later than they actually are. I checked the longitude/latitude coordinates for my zip code and they are correct. Any ideas?
User avatar
PrDavid
 
Posts: 1
Joined: Mon Feb 20, 2017 3:03 am

Re: Sunrise - Sunset Calculator (Ruby)

Postby DaveyBoy » Wed Apr 05, 2017 9:04 am

Hi PrDavid

I think it may be something to do with this line here:

# 10. convert UT value to local time zone of latitude/longitude

# localT = UT + localOffset + dst

localtr = utr + 0 + dst
localts = uts + 0 + dst

I may be wrong but I think the local offset is the difference between your time zone and 0 deg longitude. this would be 1 hour for every 15 deg. Mine is set to 0 because I'm in the UK. I'll dig out the original formula I found when I get home from work and post it up. :)
User avatar
DaveyBoy
 
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK


Return to User Examples

Who is online

Users browsing this forum: Google [Bot] and 34 guests