<p>The page you refer to is about sunrise/sunset throughout the year, but what you really care about is differences in the geometry on one day. This is sometimes expressed as different observers <a href="https://en.wikibooks.org/wiki/Trigonometry/The_distance_and_dip_of_the_horizon" rel="noreferrer">seeing the horizon at different distances</a>, or sometimes as an angle, a <a href="https://aty.sdsu.edu/explain/atmos_refr/dip.html" rel="noreferrer">“dip” of the horizon</a> when seen from higher altitude.  Thinking about that geometry should get you started on working out the answer. </p>

CC BY-SA 4.0
2020-06-11T13:02:50.380Z
2020-06-11T13:02:50.380Z
Eric Jensen
<h1>Assumptions</h1>

<p>Let's assume your friend and yourself are at the exact same coordinates but at different altitudes (e.g. right at the edge of a cliff or in the same building but on different floors).</p>

<p>Both latitude and longitude influence the time of sunset, so if you and your friend are at different locations, you don't have enough information to answer the question.</p>

<h1>Python library</h1>

<p><a href="https://astral.readthedocs.io/en/stable/package.html" rel="nofollow noreferrer">Astral</a> seems like an interesting library for your task:</p>

<blockquote>
  <p>Astral is a python package for calculating the times of various
  aspects of the sun and phases of the moon.</p>
</blockquote>

<p>It takes <a href="https://astral.readthedocs.io/en/latest/index.html?highlight=elevation#effect-of-elevation" rel="nofollow noreferrer">observer's elevation</a> into account :</p>

<blockquote>
  <p>The times of the sun that you experience depend on what obscurs your
  view of it. It may either be obscured by the horizon or some other
  geographical feature (e.g. mountains)</p>
  
  <p>If what obscures you at ground level is the horizon and you are at a elevation above ground level then the times of the sun depends on
  how far further round the earth you can see due to your elevation (the
  sun rises earlier and sets later).</p>
</blockquote>

<p><a href="https://astral.readthedocs.io/en/latest/index.html?highlight=elevation#effect-of-elevation" rel="nofollow noreferrer"><img src="https://i.sstatic.net/w1YNT.png" alt="elevation_horizon"></a></p>

<h1>Code</h1>

<p>After installing the package (version 2.2.), it's an easy task to calculate sunrise time for a given location and date. I chose Barcelona because it's close to 40°N and at sea-level:</p>



<pre><code># pip install 'astral==2.2'
from astral import LocationInfo, sun
from astral.location import Location
loc = Location(LocationInfo('Barcelona','Spain', 'Europe/Madrid', 41.3851, 2.1734))
loc.sunset(observer_elevation=0)
#=&gt; datetime.datetime(2020, 6, 12, 21, 25, 6, 803485, tzinfo=&lt;DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST&gt;)
</code></pre>

<p>The last argument is the elevation. After playing with it for a while, it looks like an observer at 715m elevation will see the sunset 4 minutes later than an observer on the beach:</p>



<pre><code>loc.sunset(observer_elevation=715)
# =&gt; datetime.datetime(2020, 6, 12, 21, 29, 6, 987591, tzinfo=&lt;DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST&gt;)
</code></pre>

<p>The algorithm was buggy in previous versions and has been updated.</p>

<h1>Time offset vs elevation</h1>

<p>Here's a small diagram. I'm not sure why the curve looks like this:</p>

<p><a href="https://i.sstatic.net/l3pQk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/l3pQk.png" alt="enter image description here"></a></p>

<p>Corresponding code:</p>



<pre><code>import matplotlib.pyplot as plt
import numpy as np
elevations = np.linspace(0, 2000, 1000)
sunsets = [(loc.sunset(observer_elevation=z) - loc.sunset(observer_elevation=0)).seconds/60 for z in elevations]
ax = plt.subplot()
plt.plot(elevations, sunsets, label="Sunset time offset")
ax.set_title("Sunset in Barcelona")
ax.set_xlabel('Elevation [m]')
ax.set_ylabel('Offset [minutes]')
plt.show()
</code></pre>

CC BY-SA 4.0
2020-06-11T20:56:34.017Z
2020-06-11T22:30:45.140Z
2020-06-11T22:30:45.140Z
Eric Duminil
<p>Me and my friend were watching the sunset on the same location (at my country the latitude is approximately 40 degrees). I am at sea level and my friend is at an elevation. He observed the sunset with a difference of about 4 minutes than me. He is a physicist so he challenged me to find out his elevation. Any ideas on how to use these information and win the challenge? 
I found some information on Wikipedia <a href="https://en.wikipedia.org/wiki/Sunrise_equation" rel="nofollow noreferrer">here</a> but cannot understand a lot.
Any idea on how to solve this will be appreciated. Thanks in advance for your help.</p>

CC BY-SA 4.0
2020-06-11T12:38:24.280Z
You need to be a bit more precise in where your problem is - especially as you already point to an explanation. We cannot write here an entire book on the issue, guessing where your actual problem in understanding the issue lies.
planetmaker
CC BY-SA 4.0
2020-06-12T14:48:44.270Z
@uhoh yes, that was my assumption too. As a matter of fact, burj khalifa would be high enough for a 4 min delay.
Eric Duminil
CC BY-SA 4.0
2020-06-12T15:04:15.443Z
@uhoh okay. I removed the comment since I explain the assumptions in my answer. It would still be nice to have some more information from OP
Eric Duminil
CC BY-SA 4.0
2020-06-12T15:06:46.247Z
@EricDuminil hopefully they will, although they are "just a guest" perhaps they'll stop by again and clarify this and ask another! :-)
uhoh
<the-sun><observational-astronomy><coordinate>
Different times of sunset at the same location due to elevation
justaguest
# Different times of sunset at the same location due to elevation

(Asked by: username_0 on 2020-06-11)

Me and my friend were watching the sunset on the same location (at my country the latitude is approximately 40 degrees). I am at sea level and my friend is at an elevation. He observed the sunset with a difference of about 4 minutes than me. He is a physicist so he challenged me to find out his elevation. Any ideas on how to use these information and win the challenge?
I found some information on Wikipedia [here](https://en.wikipedia.org/wiki/Sunrise_equation) but cannot understand a lot.
Any idea on how to solve this will be appreciated. Thanks in advance for your help.

**Tags:** the-sun, observational-astronomy, coordinate

> **Comments:**
> **username_1**: You need to be a bit more precise in where your problem is - especially as you already point to an explanation. We cannot write here an entire book on the issue, guessing where your actual problem in understanding the issue lies.  
> **username_2**: @username_3 yes, that was my assumption too. As a matter of fact, burj khalifa would be high enough for a 4 min delay.  
> **username_2**: @username_3 okay. I removed the comment since I explain the assumptions in my answer. It would still be nice to have some more information from OP  
> **username_3**: @username_2 hopefully they will, although they are "just a guest" perhaps they'll stop by again and clarify this and ask another! :-)  

---

## 2 answers

### Answer by username_4 on 2020-06-11. Score: 5

The page you refer to is about sunrise/sunset throughout the year, but what you really care about is differences in the geometry on one day. This is sometimes expressed as different observers [seeing the horizon at different distances](https://en.wikibooks.org/wiki/Trigonometry/The_distance_and_dip_of_the_horizon), or sometimes as an angle, a [“dip” of the horizon](https://aty.sdsu.edu/explain/atmos_refr/dip.html) when seen from higher altitude. Thinking about that geometry should get you started on working out the answer.


---

### Answer by username_2 on 2020-06-11. Score: 2

# Assumptions

Let's assume your friend and yourself are at the exact same coordinates but at different altitudes (e.g. right at the edge of a cliff or in the same building but on different floors).

Both latitude and longitude influence the time of sunset, so if you and your friend are at different locations, you don't have enough information to answer the question.

# Python library

[Astral](https://astral.readthedocs.io/en/stable/package.html) seems like an interesting library for your task:

> Astral is a python package for calculating the times of various
> aspects of the sun and phases of the moon.

It takes [observer's elevation](https://astral.readthedocs.io/en/latest/index.html?highlight=elevation#effect-of-elevation) into account :

> The times of the sun that you experience depend on what obscurs your
> view of it. It may either be obscured by the horizon or some other
> geographical feature (e.g. mountains)
>
> If what obscures you at ground level is the horizon and you are at a elevation above ground level then the times of the sun depends on
> how far further round the earth you can see due to your elevation (the
> sun rises earlier and sets later).

[![elevation_horizon](https://i.sstatic.net/w1YNT.png)](https://astral.readthedocs.io/en/latest/index.html?highlight=elevation#effect-of-elevation)

# Code

After installing the package (version 2.2.), it's an easy task to calculate sunrise time for a given location and date. I chose Barcelona because it's close to 40°N and at sea-level:

```
# pip install 'astral==2.2'
from astral import LocationInfo, sun
from astral.location import Location
loc = Location(LocationInfo('Barcelona','Spain', 'Europe/Madrid', 41.3851, 2.1734))
loc.sunset(observer_elevation=0)
#=> datetime.datetime(2020, 6, 12, 21, 25, 6, 803485, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>)

```

The last argument is the elevation. After playing with it for a while, it looks like an observer at 715m elevation will see the sunset 4 minutes later than an observer on the beach:

```
loc.sunset(observer_elevation=715)
# => datetime.datetime(2020, 6, 12, 21, 29, 6, 987591, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>)

```

The algorithm was buggy in previous versions and has been updated.

# Time offset vs elevation

Here's a small diagram. I'm not sure why the curve looks like this:

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

Corresponding code:

```
import matplotlib.pyplot as plt
import numpy as np
elevations = np.linspace(0, 2000, 1000)
sunsets = [(loc.sunset(observer_elevation=z) - loc.sunset(observer_elevation=0)).seconds/60 for z in elevations]
ax = plt.subplot()
plt.plot(elevations, sunsets, label="Sunset time offset")
ax.set_title("Sunset in Barcelona")
ax.set_xlabel('Elevation [m]')
ax.set_ylabel('Offset [minutes]')
plt.show()

```


---

