<blockquote>
<p>Correct me if I am wrong, but if we count sunsets by the center of the Sun apparently crossing the horizon then the Sun is supposed to set every day at latitudes under the arctic circle.</p>
</blockquote>
<p>That is not how PyEphem defines sunrise and sunset. It defines sunrise as the time the top of the Sun would nominally first appear above an unobscured horizon (no mountains), and sunset as the time the top of the Sun would nominally first disappear below an unobscured horizon. The Sun has a non-zero angular radius, so that alone changes things.</p>
<p>Moreover, as notovny's answer explicitly addresses, the Earth's atmosphere typically makes the Sun appear to rise well before the top of the Sun would first appear to rise above the horizon if those atmospheric effects didn't exist, and appear to set well after the top of the Sun would disappear would disappear over the horizon if those atmospheric effects didn't exist.</p>
<p>PyEphem uses the U.S. Naval Observatory's values for the Sun's apparent angular radius (16 arc minutes) and for the typical atmosphere refraction (34 arc minutes), resulting in a total of 50 arc minutes. This makes the calculation of sunrise and sunset much easier for pyEphem: Sunrise occurs when the elevation angle of the &quot;real&quot; center of the Sun exceeds -50 arc minutes, and sunset occurs when the elevation angle of the &quot;real&quot; center of the Sun finally drops below -50 arc minutes.</p>
<p>As an aside, these definitions of sunrise and sunset are why daytime lasts longer than twelve hours at the equinoxes.</p>

CC BY-SA 4.0
2021-03-23T01:21:39.600Z
2021-03-24T14:11:48.330Z
2021-03-24T14:11:48.330Z
David Hammen
<p>Wikipedia's <a href="https://en.wikipedia.org/wiki/Arctic_Circle" rel="noreferrer">article on the Arctic Circle</a> provides the explanation. Firstly, it says:</p>
<blockquote>
<p>because the sun appears as a disk and not a point, part of the
midnight sun may be seen on the night of the northern summer solstice
up to about 50 minutes (′) (90 km (56 mi)) south of the Arctic Circle.</p>
</blockquote>
<p>As the Arctic Circle is currently at roughly 66°34′N, this means a portion of the Sun is still visible on that night at around 65°44′N - the very latitude of the city of Kemi.</p>
<p>Another factor to take into account is the elevation of the viewing point. Kemi is not very high - just <a href="https://en.wikipedia.org/wiki/Kemi" rel="noreferrer">4m above sea level</a> - but it's likely there are higher points of land within the city, and tall buildings too. Greater elevation brings more of the Sun's disc into view.</p>
<p>UPDATE: the question was edited since this answer was posted, and Kemi was replaced with Kuusamo, &quot;<em>a city at 65°58′N</em>&quot; – which is further north than Kemi, and therefore would be able to see the midnight Sun for even longer.</p>

CC BY-SA 4.0
2021-03-23T17:06:36.063Z
Also, Kuusamo is at about 250 m above sea level.
jamesqf
CC BY-SA 4.0
2021-03-22T23:50:39.747Z
2021-03-23T00:26:50.983Z
2021-03-23T00:26:50.983Z
Chappo Hasn't Forgotten
<p>From the <a href="https://rhodesmill.org/pyephem/quick.html" rel="noreferrer">PyEphem Quick Reference Guide</a>:</p>
<blockquote>
<p>Rising and setting are sensitive to atmospheric refraction at the
horizon, and therefore to the observer’s temp and pressure; set the
pressure to zero to turn off refraction.</p>
</blockquote>
<p>It seems likely that, if you're using the default settings, the result returned is including atmospheric refraction, giving the results you would expect to see at the location, where the sun is visible even though a direct line to the disc of the sun would put it below the horizon.</p>
<p><a href="https://i.sstatic.net/5CkgQ.png" rel="noreferrer"><img src="https://i.sstatic.net/5CkgQ.png" alt="Image showing atmospheric refraction from TimeandDate.com" /></a></p>
<p>Image is from &quot;<a href="https://www.timeanddate.com/astronomy/refraction.html" rel="noreferrer">What is Refraction of Light</a>&quot; by By Konstantin Bikos and Aparna Kher at <a href="https://www.timeanddate.com/" rel="noreferrer">timeanddate.com</a></p>

CC BY-SA 4.0
2021-03-23T00:05:30.860Z
This was it. I never expected to have this turned on out of the box. Thanks!
mr_tuna
CC BY-SA 4.0
2021-03-22T23:48:28.563Z
2021-03-22T23:48:28.563Z
notovny
<p>Correct me if I am wrong, but if we count sunsets by the center of the Sun apparently crossing the horizon then the Sun is supposed to set every day at latitudes under the arctic circle. (Yes if you count in the disc then adjust by 0.27 degrees.)</p>
<p>I was playing around with PyEphem (a python library that claims an approximately 1 arcsecond accuracy), and found that according to it the sun stays up for a couple of days even under it (<span class="math-container">$66.2&lt;90-23.4$</span>). Can someone explain what is going on?</p>
<p>I created this simple plot to illustrate the issue. The left panel shows the whole period while the right panel shows that the problem is not that the data is under sampled. The plot goes from
<code>2021-06-13 00:12:58.085383+00:00</code> to <code>2021-06-28 23:54:05.880661+00:00</code>.</p>
<p><a href="https://i.sstatic.net/X4Pit.png" rel="noreferrer"><img src="https://i.sstatic.net/X4Pit.png" alt="enter image description here" /></a></p>
<p>And one more example: Kuusamo is a city at 65°58′N 29°11′E and apparently it also has a few days when the sun doesn't set: <a href="https://www.timeanddate.com/sun/finland/kuusamo" rel="noreferrer">LINK1</a> <a href="https://www.gaisma.com/en/location/kuusamo.html" rel="noreferrer">LINK2</a></p>

CC BY-SA 4.0
2021-03-22T23:22:11.753Z
You've defined the problem in a way that necessarily produces the very anomaly you're asking about. Almost everyone regards a sunset as meaning the Sun has *entirely disappeared below the horizon*, rather than only half of it having "set". Are you allowing for part of the solar disc remaining above the horizon at the time of the northern summer solstice even at latitudes below (but close to) the Arctic Circle?
Chappo Hasn't Forgotten
CC BY-SA 4.0
2021-03-22T23:27:21.593Z
Yes, i did the half disc thing consistently. Notice that even 66.2 < 90-23.4-0.27 so I don't think you are right. I also added a an example to the bottom that is surely correctly computed and is even more to the south.
mr_tuna
CC BY-SA 4.0
2021-03-23T15:51:39.470Z
Normally, you should wait at least a week before accepting an answer. This will allow you to get more answers and look for feedback on existing answers.
slowerthanstopped
CC BY-SA 4.0
2021-03-24T09:18:24.970Z
Relevant: https://what-if.xkcd.com/42/
Tim
CC BY-SA 4.0
2021-03-24T13:19:38.457Z
@slowerthanstopped: Sometimes a question has a simple factual answer.  There's no reason to delay accepting when someone posts it, in a case like this.  You should still keep an eye on your question in case of comments on the answer pointing out that it's not that simple, but if you're pretty sure an answer *fully* answers the question, you should accept it.  That doesn't close the question or stop anyone else from answering, and you can even change your accept vote if an even better answer comes in.  (You don't want to long-term leave a less good answer pinned to the top, even if sufficient.)
Peter Cordes
<solar-system><python><celestial-mechanics><ephemeris>
Why won't the Sun set for days at N66.2 which is below the arctic circle?
mr_tuna
# Why won't the Sun set for days at N66.2 which is below the arctic circle?

(Asked by: username_0 on 2021-03-22)

Correct me if I am wrong, but if we count sunsets by the center of the Sun apparently crossing the horizon then the Sun is supposed to set every day at latitudes under the arctic circle. (Yes if you count in the disc then adjust by 0.27 degrees.)

I was playing around with PyEphem (a python library that claims an approximately 1 arcsecond accuracy), and found that according to it the sun stays up for a couple of days even under it ($66.2<90-23.4$). Can someone explain what is going on?

I created this simple plot to illustrate the issue. The left panel shows the whole period while the right panel shows that the problem is not that the data is under sampled. The plot goes from
`2021-06-13 00:12:58.085383+00:00` to `2021-06-28 23:54:05.880661+00:00`.

[![enter image description here](https://i.sstatic.net/X4Pit.png)](https://i.sstatic.net/X4Pit.png)

And one more example: Kuusamo is a city at 65°58′N 29°11′E and apparently it also has a few days when the sun doesn't set: [LINK1](https://www.timeanddate.com/sun/finland/kuusamo) [LINK2](https://www.gaisma.com/en/location/kuusamo.html)

**Tags:** solar-system, python, celestial-mechanics, ephemeris

> **Comments:**
> **username_1**: You've defined the problem in a way that necessarily produces the very anomaly you're asking about. Almost everyone regards a sunset as meaning the Sun has *entirely disappeared below the horizon*, rather than only half of it having "set". Are you allowing for part of the solar disc remaining above the horizon at the time of the northern summer solstice even at latitudes below (but close to) the Arctic Circle?  
> **username_0**: Yes, i did the half disc thing consistently. Notice that even 66.2 < 90-23.4-0.27 so I don't think you are right. I also added a an example to the bottom that is surely correctly computed and is even more to the south.  
> **username_2**: Normally, you should wait at least a week before accepting an answer. This will allow you to get more answers and look for feedback on existing answers.  
> **username_3**: Relevant: https://what-if.xkcd.com/42/  
> **username_4**: @username_2: Sometimes a question has a simple factual answer.  There's no reason to delay accepting when someone posts it, in a case like this.  You should still keep an eye on your question in case of comments on the answer pointing out that it's not that simple, but if you're pretty sure an answer *fully* answers the question, you should accept it.  That doesn't close the question or stop anyone else from answering, and you can even change your accept vote if an even better answer comes in.  (You don't want to long-term leave a less good answer pinned to the top, even if sufficient.)  

---

## 3 answers

### Answer by username_7 on 2021-03-22. Score: 51 | Accepted answer

From the [PyEphem Quick Reference Guide](https://rhodesmill.org/pyephem/quick.html):

> Rising and setting are sensitive to atmospheric refraction at the
> horizon, and therefore to the observer’s temp and pressure; set the
> pressure to zero to turn off refraction.

It seems likely that, if you're using the default settings, the result returned is including atmospheric refraction, giving the results you would expect to see at the location, where the sun is visible even though a direct line to the disc of the sun would put it below the horizon.

[![Image showing atmospheric refraction from username_3eandDate.com](https://i.sstatic.net/5CkgQ.png)](https://i.sstatic.net/5CkgQ.png)

Image is from "[What is Refraction of Light](https://www.timeanddate.com/astronomy/refraction.html)" by By Konstantin Bikos and Aparna Kher at [timeanddate.com](https://www.timeanddate.com/)

> **Comments:**
> **username_0**: This was it. I never expected to have this turned on out of the box. Thanks!  

---

### Answer by username_5 on 2021-03-23. Score: 22

> Correct me if I am wrong, but if we count sunsets by the center of the Sun apparently crossing the horizon then the Sun is supposed to set every day at latitudes under the arctic circle.

That is not how PyEphem defines sunrise and sunset. It defines sunrise as the time the top of the Sun would nominally first appear above an unobscured horizon (no mountains), and sunset as the time the top of the Sun would nominally first disappear below an unobscured horizon. The Sun has a non-zero angular radius, so that alone changes things.

Moreover, as username_7's answer explicitly addresses, the Earth's atmosphere typically makes the Sun appear to rise well before the top of the Sun would first appear to rise above the horizon if those atmospheric effects didn't exist, and appear to set well after the top of the Sun would disappear would disappear over the horizon if those atmospheric effects didn't exist.

PyEphem uses the U.S. Naval Observatory's values for the Sun's apparent angular radius (16 arc minutes) and for the typical atmosphere refraction (34 arc minutes), resulting in a total of 50 arc minutes. This makes the calculation of sunrise and sunset much easier for pyEphem: Sunrise occurs when the elevation angle of the "real" center of the Sun exceeds -50 arc minutes, and sunset occurs when the elevation angle of the "real" center of the Sun finally drops below -50 arc minutes.

As an aside, these definitions of sunrise and sunset are why daytime lasts longer than twelve hours at the equinoxes.


---

### Answer by username_1 on 2021-03-22. Score: 9

Wikipedia's [article on the Arctic Circle](https://en.wikipedia.org/wiki/Arctic_Circle) provides the explanation. Firstly, it says:

> because the sun appears as a disk and not a point, part of the
> midnight sun may be seen on the night of the northern summer solstice
> up to about 50 minutes (′) (90 km (56 mi)) south of the Arctic Circle.

As the Arctic Circle is currently at roughly 66°34′N, this means a portion of the Sun is still visible on that night at around 65°44′N - the very latitude of the city of Kemi.

Another factor to take into account is the elevation of the viewing point. Kemi is not very high - just [4m above sea level](https://en.wikipedia.org/wiki/Kemi) - but it's likely there are higher points of land within the city, and tall buildings too. Greater elevation brings more of the Sun's disc into view.

UPDATE: the question was edited since this answer was posted, and Kemi was replaced with Kuusamo, "*a city at 65°58′N*" – which is further north than Kemi, and therefore would be able to see the midnight Sun for even longer.

> **Comments:**
> **username_6**: Also, Kuusamo is at about 250 m above sea level.  

---

