5

I'm currently using this code to calculate the sunrise / sunset times. (To be more precise, I'm looking for civil dawn / civil dusk times which are defined as the time when the sun is between 0° and -6° altitude). As a next step, I'd like to compute the dawn beginning and dusk ending times. I believe the calculations must be very similar.

My idea is that if I want to calculate the dawn beginning (dusk ending) time for a place I just calculate the sunrise (sunset) times for a place 6° farther east (west).

Can somebody confirm this assumption, or am I thinking wrong?

Thanks for answers!

-- Ry

EDIT: Thought about it a little more and came to the conclusion that my assumption is wrong. Moving 6° East is wrong, moving 6° orthogonal to the light/shadow-border would be right. (It becomes obvious if you imagine the earth's axis not being tilted by 23.xx° but 90° - moving east wouldn't change anything).

ryyst
  • 9,563
  • 18
  • 70
  • 97
  • Here goes the solution http://stackoverflow.com/questions/7064531/sunrise-sunset-times-in-c/9425781#9425781 – Geetha Feb 24 '12 at 06:04

4 Answers4

3

The code that you link to uses a constant (90.833) in the calcHourAngle* methods. If you look at these definitions of sunrise/sunset, you will notice that same 90.833 constant under Technical Definitions and Computational Details. A little further down, under civil twilight, the similar constant of 96 is used. Perhaps changing that constant would get what you are looking for?

Scott W
  • 9,742
  • 2
  • 38
  • 53
2

i don't have a comment on your code, but you can use the following site to verify the output from your program: http://aa.usno.navy.mil/data/docs/RS_OneYear.php

yamspog
  • 18,173
  • 17
  • 63
  • 95
1

This works, but only if it's okay to assume that elevation is insignificant. Depending on how exact you need to be, someone on a high mountaintop will experience sunrise (or sunset) slightly before (or after) somebody at sea level. For instance, if you're standing on Mount Everest, sunrise and sunset are shifted apart by ~16 minutes, relative to sea level (source: back of the envelope math).

Note that the more extreme your latitude, the starker the contrasts between longer summer days and longer winter nights. Some places on Earth receive sunlight all 24 hours of the day during summer and are shrouded in darkness all 24 hours of the night. These places don't have a daily "dawn" or "dusk", although you could pick the times halfway in between when the sun is lowest and highest in the sky.

John Feminella
  • 303,634
  • 46
  • 339
  • 357
  • Well, the algorithms used to calculate the sun's position are very inaccurate in places above the arctic circle, anyway, so I exclude all those places in my program. Elevation is also not supported as of now. But you think the algorithm works for places like New York City (i.e. no extreme places)? – ryyst Apr 09 '10 at 17:41
  • 1
    Re: New York, it probably depends on what floor you're on.. ;-) – R.. GitHub STOP HELPING ICE Jun 27 '11 at 17:58
0

This doesn't work. An easy way to prove this to yourself is that at the poles, the elevation of the sun doesn't change as you rotate your body, so going east or west by 6 degrees won't affect your times.

If you're closer to the equator, this calculation will probably be more accurate, but I don't think it's ever perfect.

clahey
  • 4,795
  • 3
  • 27
  • 20
  • @clahey: I think your assertion is off. At the poles, there's a singularity. You can't move N degrees "east" from the North Pole, because there's nowhere else to go. We're also not talking about rotating in place, we're talking about moving an angular distance across a parallel, which is a different translation. – John Feminella Apr 09 '10 at 17:48
  • Okay, walk 10 steps away from the north pole. 6 degrees east of you is a step to the left. You'll note that the time of sunset has changed by a miniscule amount. However, beginning and end of civil dusk are still days (weeks, months?) apart from one another. – clahey Apr 09 '10 at 17:55