jdemaeyer / brightsky

JSON API for DWD's open weather data.
https://brightsky.dev/
MIT License
287 stars 18 forks source link

Night forecast during the day #151

Closed spyderdsn closed 11 months ago

spyderdsn commented 1 year ago

Hi, I'm in Australia and when I request the weather at 9am, the forecast returns with the night readings.

Screenshot 2023-07-07 at 9 58 49 am
jdemaeyer commented 1 year ago

Hi @spyderdsn, thanks for pointing this out! I believe the weather parameters (the numerical values and the condition) are all correct, but there's a bug in determining the suffix for the icon field (-day/-night).

Note to self: Seems our daytime check currently does handle sunset being earlier than sunrise during the "UTC day" at a location. (Sydney's is UTC+10)

jdemaeyer commented 1 year ago

acaef8b

Icons should be fixed now :)

(side note @spyderdsn you can get timestamps in local time by adding &tz=Australia/Sydney to the end of your request URL)

spyderdsn commented 1 year ago
Screenshot 2023-08-18 at 9 20 21 am

Hi @jdemaeyer,

The icons still return night readings early in the morning, now I have mix reading from the day or night.

jdemaeyer commented 1 year ago

Hm, not good, thanks for feedback! Could you maybe give me the URL of the request you're sending?

spyderdsn commented 1 year ago

I've been using:

https://api.brightsky.dev/weather?lat=-33.867779&lon=151.207047&date=2023-08-18

since the one below returns 404

https://api.brightsky.dev/current_weather?lat=-33.867779&lon=151.207047

than I tried to filter out occurrences, I think than main problem is, the weather forecast for the day also includes loads of night.

Not sure why one endpoint works for given lat/long, other don't.

jdemaeyer commented 1 year ago

Maybe there is an issue with how you are converting the UTC timestamps to your local time? I unfortunately can't check the data from 2023-08-18 as that's too far in the past, but for tomorrow the records for 9:00 and 10:00 in Sydney (23:00 and 0:00 UTC) have the expected "day" icons:

    {
      "timestamp": "2023-08-18T23:00:00+00:00",
      "source_id": 925,
      "precipitation": 0,
      "pressure_msl": 1016.6,
      "sunshine": null,
      "temperature": 11.8,
      "wind_direction": 268,
      "wind_speed": 27.8,
      "cloud_cover": 14,
      "dew_point": 0.8,
      "relative_humidity": null,
      "visibility": 34700,
      "wind_gust_direction": null,
      "wind_gust_speed": null,
      "condition": "dry",
      "precipitation_probability": null,
      "precipitation_probability_6h": null,
      "solar": null,
      "icon": "clear-day"
    },
    {
      "timestamp": "2023-08-19T00:00:00+00:00",
      "source_id": 925,
      "precipitation": 0,
      "pressure_msl": 1016.9,
      "sunshine": null,
      "temperature": 13.2,
      "wind_direction": 264,
      "wind_speed": 27.8,
      "cloud_cover": 15,
      "dew_point": 0.7,
      "relative_humidity": null,
      "visibility": 33900,
      "wind_gust_direction": null,
      "wind_gust_speed": null,
      "condition": "dry",
      "precipitation_probability": null,
      "precipitation_probability_6h": null,
      "solar": null,
      "icon": "clear-day"
    }

You can also let Bright Sky convert the timestamps for you by adding &tz=Australia/Sydney to the end of the URL.

Not sure why one endpoint works for given lat/long, other don't.

Bright Sky is built around data from Germany's meteorological service (DWD), which only publishes actual measurements from weather stations in Germany. The /current_weather endpoint only uses actual measurements, hence why it gives you "no sources". The DWD's forecast model, which is included in the /weather endpoint, contains world-wide data, though, so that one works for Sydney (but not into the past, and what you retrieve are not actual measurements but recent, one hour before-ish, forecasts).

Australia's Bureau of Meteorology publishes actual measurements on their homepage if you wanna check that out. If you click on a specific station there's a link to a JSON file at the bottom.

jdemaeyer commented 11 months ago

Closing but feel free to re-open. If the issue persists I'd be glad if you could post a request and the response :)