1
$\begingroup$

I've noticed that different reputable weather websites will give different times for sunrise/sunset for the exact same location. I've seen variation by 25 minutes or more, for sunset on the same date at the same location, from two different websites. Assuming that they are all using the astronomical definition of sunset, is there any reasonable explanation for this variation? (e.g. Are there multiple accepted methods of calculating sunrise/sunset?)

Edit: The example I'm currently looking at is the Openweathermap API sunset time and the time given by sunrise-sunset.org, as an example. Looking at both for St. Michael's, Maryland (and having double-checked that I'm indeed looking at the same location for both), openweathermap shows 7:45pm, and sunrise-sunset.org shows 8:09pm, for sunset today. This town does not have an extreme longitude, and it is topographically pretty flat so I doubt one website is trying to account for horizon differences.

$\endgroup$
9
  • 4
    $\begingroup$ A 25 minute difference is unexpected. Perhaps a minute or two depending on the calculation method.It would be helpful to know what websites and what location (latitude and longitude) you are checking. $\endgroup$
    – JohnHoltz
    May 13 at 1:35
  • 2
    $\begingroup$ My guess would be that some are listing the end of twilight, not sunset. But unless you mention the websites I think there could only be guesses. $\endgroup$
    – James K
    May 13 at 4:57
  • 1
    $\begingroup$ Another possibility is places with hills or mountains that some sites account for but others do not. $\endgroup$ May 13 at 11:21
  • $\begingroup$ WAG: you're checking two places with similar or identical names, such as Portland Oregon and Portland Maine. $\endgroup$ May 13 at 12:00
  • 3
    $\begingroup$ It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result. $\endgroup$ May 14 at 2:50

2 Answers 2

2
$\begingroup$

I can't replicate your issue.

Here is my process: I checked the sunset and sunrise times on your website: https://sunrise-sunset.org/search?location=Saint+Michaels%2C+MD

This gives me 5:50:51 AM

Then I obtained a free API key from openweather and used 'postman' to request weather data for the location at a latitude/longitude of 38.783611, -76.222222 (These values from Wikipedia for Saint Michaels MD)

https://api.openweathermap.org/data/2.5/weather?lat=38.783611&lon=-76.222222&appid=e4f5007a981cbb489d250d468352fe21

This returns the sunrise time as "sunrise": 1652608364

I converted this to a human readable date using the standard UNIX "date" program

$ TZ="America/New_York" date --date="@1652608364"
Sun 15 May 05:52:44 EDT 2022

For validation I also checked https://www.timeanddate.com/sun/@4368380. It gives sunrise as 05:52

There is a small discrepancy of less than a couple of minutes between these values. This is within the range that can be reasonably explained by differences in atmospheric models, different geolocations for "Saint Michaels", or adjustments for elevation.

I conclude that there must be some error in your conversion from a UNIX time to clock time.

$\endgroup$
2
$\begingroup$

They can't possibly be both correct, variations due to small differences in the center of the town's location or elevation will be seconds or a minute or so at most, so you need to go into debug mode.

The first step is to find out which number is wrong.

The 8:09 PM looks about right. I chose nearby Baltimore MD and used in-the-sky.org' planetarium for Baltimore for May 13, 2022 and at 8:04 PM the Sun is just touching the horizon.

We'd expect it to be a few minutes earlier than St. Michaels since it's a big further north.

I think you have several ways to approach debugging your use of the API

  1. wrong location (though you said you've checked that) moving north from Baltimore to Bangor Maine gets you to roughly 7:45 PM.
  2. wrong date; a few weeks, but not an exact month earlier can also get you to 7:45 PM
  3. bad API
  4. bad implementation
  5. something else

note: @GregMiller's comment:

It'd probably help to post the code, it is most likely you're either passing data in incorrectly, or misinterpreting the result.

screenshot of in-the-sky.org's planetarium feature for around sunset in Baltimore MD. USA on May 13, 2022

Gaisma.com gives 8:11 PM for Baltimore

screenshot of gaisma.com for Bangor ME. USA on May 13, 2022

But going north to Bangor Maine we can get to about 7:45 PM

screenshot of in-the-sky.org's planetarium feature for around sunset in Bangor ME. USA on May 13, 2022

$\endgroup$
4
  • 1
    $\begingroup$ Horizons agrees. I get sunset for that location is ~2022-May-13 00:08 UTC, local sundial time = 19.1124 = 19:07 $\endgroup$
    – PM 2Ring
    May 14 at 1:57
  • 1
    $\begingroup$ ssd.jpl.nasa.gov/api/… $\endgroup$
    – PM 2Ring
    May 14 at 2:07
  • 1
    $\begingroup$ I appreciate your help! I'm not directly using the API in my own code; it's used in my smartwatch's weather function. I'm guessing there's some issue with the app's code then. We'll, that's disappointing that the watch just doesn't do its job very well, I guess. $\endgroup$
    – ETL
    May 16 at 0:12
  • $\begingroup$ @ETL hmm... yes disappointing indeed! By the way, perhaps slightly related in Apple SE: I'd like to see the positions of the Moon and planets in the sky on my Apple watch. What are my options (if any)? $\endgroup$
    – uhoh
    May 16 at 0:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .