Formula for sunset/rise, moonrise/set times and lunar phases

In summary: It is the rate of change of daylength that follows a sine function, not daylength itself. In summary, The conversation is about a project involving a website that will display the time for sunrise and sunset as well as moonrise and moonset for the current day, along with the current lunar phase. The person is looking for a formula or algorithm to calculate these times and phases, but wants to avoid simply copying and pasting code from the internet. They suggest that the times may change by a fixed amount each day, but others point out that it is actually more of a sine function with more rapid changes near the solstices. The conversation also discusses the timing of the seasons and how they are not accurately timed with the solst
  • #1
Goats Dont Shave
3
0
Hello Everyone,

I put this message on the astronomy forum but didn't really get the answear I was looking for.

I am currently designing project where part of it will involve a website and amoungst things, on the site I would like present the time for sunrise and set for the current day and the same for moonrise and set as well as the current lunar phase. This is for a college project and I would prefer if someone could give me a formula/algorithm for any of them. I know there is code out there on the net but I can't just copy and paste this. I would feel comfortable writing the code to carry out any of the formulas you might have.

I think the formulas are probably quite difficult but would it not be true that the sunrise and sunset time will change by a fixed amount each day. for example if i know the sunrise time for my location on 1 august 2004 is it just a matter of adding on a certain amount of minutes and seconds each day until a certain date when the it will begin to rise earlier? this is probably a bit too good to be true?

Could the same apply for moonrise/set times?

Would the same type of method apply for the lunar phases? We know that the moon orbits Earth every 29.6 days so is it just a matter of working out when the last full moon was, let's say it was 1 august we now know that next one will be 29.6 days later. so if someone comes along on august 15 the program could then work out the percentage of the moon showing and give a good estimate of the phase. similarily if someone comes along in december then the program could start from 1 august and then calculate the phase and % for that day. Does anybody think this would work or is there an accurate formula out there?

I am not really a big maths person so please try and keep your answears as simple as you can.

If anybody thinks that I have posted this message in the wrong place please say.

Thanks for any help anybody might have.
 
Mathematics news on Phys.org
  • #2
"googling" on "sunrise sunset formula" give several sites, one of which is this:
http://star-www.st-and.ac.uk/~fv/webnotes/chapt12.htm
 
  • #3
Sunrise and sunset aren't changed by fixed amounts every day. It's more of a sine function, less of a daily change near each equinox, and more rapid changes in daylight hours nearer the solstices. When I need sunrise/sunset times, I just go to the US Naval Observatory website for information (they also include more detailed information than most sites about twilights, which is important for me to know as well). Sorry I can't help you more than that.
 
  • #4
Moonbear,
You are correct it is nearly sinusoidal, but. Sorry to nit pick. Day length change rate is greatest at the equinox's and least at the solstice. Right now (end of Aug) we have started the ramp leading to short days. By mid Nov. day length will be near the minimum and will stay near the same till mid Jan.

IMHO, The seasons are not correctly timed. Winter and Spring are the season of ever increasing day length, summer and Fall Decreasing day length. I think Summer ought to be days of maximum length and little change, May, Jun & Jul, Fall is the season of diminishing day length Aug, Sept, &Oct. Winter is the season of short days Oct, Nov, & Jan. Spring the season of growing day length, Feb, Mar, & Apr.

Note that your local sunrise sunset times will also be determined by your local horizon. I have been in valleys were even in summer the sun did not get above the horizon until 10-11am, and sat by 2-3pm. Any computations will tell you the time the sun crosses the perfect horizon.
 
  • #5
Integral said:
Moonbear,
You are correct it is nearly sinusoidal, but. Sorry to nit pick. Day length change rate is greatest at the equinox's and least at the solstice.

Oops...I knew that, just wrote it backward. Hope it didn't confuse anyone! I got myself preoccupied trying to figure out the correct plural of equinox (equinoxes, equinoces?) and then wrote the wrong thing.
 

1. What is the formula for calculating the time of sunset or sunrise?

The formula for calculating the time of sunset or sunrise is based on the position of the sun in relation to the horizon and the curvature of the earth. It is calculated using the following formula: tan(t) = tan(φ) * tan(δ), where "t" represents the time of sunset or sunrise, "φ" represents the observer's latitude, and "δ" represents the declination of the sun. This formula takes into account the changing declination of the sun throughout the year and the observer's position on the earth.

2. How can I calculate the moonrise and moonset times?

The moonrise and moonset times can be calculated using a similar formula to the one used for sunset and sunrise. The formula is: tan(t) = tan(φ) * tan(δ), where "t" represents the time of moonrise or moonset, "φ" represents the observer's latitude, and "δ" represents the declination of the moon. However, this formula only provides an estimate and may not be accurate for all locations and times.

3. How do lunar phases affect the time of sunset and sunrise?

Lunar phases do not directly affect the time of sunset and sunrise. However, the moon's position in the sky can have an impact on the amount of light during sunset and sunrise. For example, during a full moon, the moon will rise at the same time the sun sets, creating a brighter and longer sunset. During a new moon, the moon will not be visible, resulting in a darker and shorter sunset. This is due to the moon's gravitational pull on the earth's tides, which can cause changes in the height of the horizon.

4. Can I use the same formula to calculate sunset and sunrise for any location?

The formula for calculating sunset and sunrise can be used for any location on earth. However, some adjustments may need to be made for extreme latitudes or locations near the equator. Additionally, this formula assumes a flat horizon, so locations with mountains or other obstructions may require further adjustments.

5. How accurate are the calculated times for sunset, sunrise, moonrise, and moonset?

The calculated times for sunset, sunrise, moonrise, and moonset are estimates and may not be 100% accurate. Factors such as atmospheric conditions and obstructions on the horizon can affect the actual times. However, the formulas used to calculate these times have been refined and are generally accurate within a few minutes for most locations.

Similar threads

  • Astronomy and Astrophysics
Replies
1
Views
1K
  • Astronomy and Astrophysics
Replies
6
Views
1K
  • Earth Sciences
Replies
25
Views
2K
Replies
2
Views
598
  • Special and General Relativity
Replies
31
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
514
Replies
19
Views
5K
  • Electrical Engineering
Replies
17
Views
2K
Replies
5
Views
997
  • Electrical Engineering
Replies
7
Views
3K
Back
Top