mawinkler / astroweather

Asynchronous Astro Weather Forecast for Home Assistant
GNU General Public License v3.0
69 stars 9 forks source link

Moon rise/set not correct #37

Closed ancjsd closed 10 months ago

ancjsd commented 10 months ago

The next moon rise/set calculations don't seem to be correct--at least not for Anchorage, Alaska. I've confirmed the long/lat and have uninistalled and reinstalled the integration, but the calculations don't jive with those shown at online resources.

mawinkler commented 10 months ago

Hi to Alaska, so, after checking my code, the calculations seem correct in the library. I compared my calculations with the United States Naval Observatory

Sun next Rising: 2023-10-21 08:12:20.235611-08:00, Nautical: 2023-10-21 07:22:03.827773-08:00, Astronomical: 2023-10-21 06:31:52.259103-08:00, Astronomical Previous: 2023-10-20 06:29:23.150075-08:00
Sun next Setting: 2023-10-21 19:13:32.885798-08:00, Nautical: 2023-10-21 20:03:40.510739-08:00, Astronomical: 2023-10-21 20:53:39.364195-08:00, Astronomical Previous: 2023-10-20 20:56:26.623536-08:00
Moon next Rising: 2023-10-21 18:10:47.961016-08:00, Moon next Setting: 2023-10-21 22:11:28.824187-08:00, Moon next new Moon: 2023-11-13 00:27:22.323325-09:00

What might be confusing, when thinking about it, these datetimes will be converted to the timezone which is set in Home Assistant. I thought this would be a good idea for remote observatory scenarios. Let me know what you think.

mawinkler commented 10 months ago

My Backyard scope is 10hs ahead your time

image

So I can easily see, that when I have 18:12 it's civil twilight in Anchorage.

ancjsd commented 10 months ago

Screenshot_20231021_090728_Home Assistant

ancjsd commented 10 months ago

Thnanks for the respose! Just posted screenshot of what my sensor is returning for next moon rising on 10/21: 6:26pm instead of 6:10pm. Doesnt seem to be a timezone issue. Am I reading something incorrectly?

ancjsd commented 10 months ago

And here's a shot of the sensor state

Screenshot_20231021_092028_Home Assistant

mawinkler commented 10 months ago

So you mean the 16 min difference? Try to change the pyastroweatherio version in your manifest to 0.40.0. Should be more accurate

ancjsd commented 10 months ago

The difference changes from day to day. Yesterday it was 42 minutes off. But I'll give that a try. Thanks.

ancjsd commented 10 months ago

Just installed .40 -- Unfortunately it didn't help.

mawinkler commented 10 months ago

Honestly I have no idea what's wrong.

If I compare the calculations with the calculations of the Naval Observatory Risings and Settings I do get a perfect match for multiple tested locations, including Anchorage:

    astroweather = AstroWeather(
        latitude=61.212,
        longitude=-149.737,
        elevation=115,
        timezone_info="America/Anchorage",
        cloudcover_weight=3,
        seeing_weight=2,
        transparency_weight=1,
        uptonight_path="."
    )

results:

Sun next Rising: 2023-10-22 08:14:49.408726-08:00, Nautical: 2023-10-22 07:24:28.537382-08:00, Astronomical: 2023-10-22 06:34:20.245163-08:00, Astronomical Previous: 2023-10-21 06:31:52.315204-08:00
Sun next Setting: 2023-10-22 19:10:46.310892-08:00, Nautical: 2023-10-22 20:00:58.562102-08:00, Astronomical: 2023-10-22 20:50:54.576962-08:00, Astronomical Previous: 2023-10-21 20:53:39.375619-08:00
Moon next Rising: 2023-10-22 18:09:41.285471-08:00, Moon next Setting: 2023-10-21 22:11:28.787071-08:00, Moon next new Moon: 2023-11-13 00:27:22.323301-09:00
image image

Are you far away from this location?

ancjsd commented 10 months ago

I'm very close to that location. As a test, I plugged in the exact same coordinates you used, and my setup returned different values than the National Observatory. For Octoxber 23, Moon rise was off by 9 minutes, and moon set was off by 12. I uninstalled and reinstalled and the values were still incorrect--but by different amounts. Very strange.

ancjsd commented 10 months ago

A friend is having the same issue with his moon rise and set that I am. We're getting identical incorrect values. Both of us are running HA in VMWare. Could that be the issue somehow?

mawinkler commented 10 months ago

I'm currently in the process of bugfixing and enhancing the astronomical calculations. There's no new release yet, still, but you can try to install the integration and card from main. Here's the Changelog so far:

Fixes

I spent hours on testing all the calculations for multiple geographic locations (Anchorage, Sydney, London and my location (nearby Munich)). All show a deviation of less than a couple of seconds compared to United States Naval Observatory. Please report any issues.

Changes

mawinkler commented 10 months ago

This is my current dashboard for testing :-) (UTC+1)

image
ancjsd commented 10 months ago

Very happy to report that the update appears to be returning correct values for me now. Thanks for a great integration!