Pirate-Weather / pirateweather

Code and documentation for the Pirate Weather API
Apache License 2.0
670 stars 29 forks source link

struggling to get data with timemachine #18

Closed bzigterman closed 1 year ago

bzigterman commented 1 year ago

I'm having trouble getting data from the timemachine API, and I'm not sure what I'm doing wrong.

Here's my API request: https://timemachine.pirateweather.net/forecast/<API_Key>/40,-88,-86400 to get the weather results for the past day. And here's the response: "Data for this date is not yet available, please try an earlier or later date"

I've also tried various unix timestamps from the past week and few months, but I continue to get the same result.

Right now, I'm just trying this out in my web browser, but I would like to eventually use this with R in RStudio. There I'm getting a 500 error code and the same message.

Am I misunderstanding what the timemachine API is for or what timeframes should be available?

Any help or suggestions would be appreciated!

alexander0042 commented 1 year ago

Really sorry it took me so long to reply to this. With all the press (which is great!) , it's been a super busy week.

I definitely need to clarify need to clarify the timemachine setup in the docs. Your first request (-86400), isn't actually a time machine request, but rather to the main api endpoint. So the request should be along the lines of:

https://api.pirateweather.net/forecast/<API_Key>/40,-88,-86400

Because it's treated as a forecast request, the response syntax is somewhat different than for timemachine, but using the first daily data block should give you essentially the same data.

In terms of bounds, the api endpoint has a ~5 day archive, so you should be able to go back that far using that endpoint. Since I'm relying on the AWS ERA-5 archive (https://registry.opendata.aws/ecmwf-era5/) for timemachine, it's continuously updating from 1979 onward, with about a 1-month delay. Currently, it looks like everything up until December 31, 2022 has been uploaded, so that's the endpoint. Eventually I hope to get a large enough archive to merge these two datasets, but the amount of data makes it cost prohibitive at the moment.

bzigterman commented 1 year ago

Ah, that all makes sense. I guess I just needed to be more patient for the timemachine documentation. Thanks!

bizzinho commented 1 year ago

How does one query the timemachine end point? Probably it's just my ignorance, but I haven't been able to get anything but "Data for this date is not yet available, please try an earlier or later date" regardless of the location and time deltas I've tried.

bzigterman commented 1 year ago

I was able to get it to work like this, using a UNIX timestamp from the period @alexander0042 said is available:

https://timemachine.pirateweather.net/forecast/<api_key>/40,-88,1666427146

Ker-ple commented 1 year ago

It seems that timemachine is having problems - any date more recent than June 30th, 2022 returns "Data for this date is not yet available, please try an earlier or later date."

alexander0042 commented 1 year ago

Thanks for alerting me to this, and apologies for the slow response on my part! It seems to be a bug with how the datetime gets filtered, so I'll investigate and report back

cloneofghosts commented 1 year ago

@alexander0042 When you query with a UNIX timestamp it also allows you to do queries for times in the future as long as there is data available for that timestamp you are using. Not sure if that's intended or known behaviour so not sure if that's something you need to fix. EDIT: Seems like DarkSky allows this behaviour but it seems weird that the API allows that. Since DarkSky allowed it then it should be left in for compatibility reasons.

Since this topic is related to the TimeMachine I noticed a few issues that need cleaning up:

time is a float value summary is using the same text as the icon field ie using clear-night instead of Clear Numbers aren't rounded to 2 decimal points as mentioned in https://github.com/alexander0042/alexander0042.github.io/issues/4#issuecomment-1000550760 and #4 dewpoint on currently seems broken "dewPoint": 100626.40625,

alexander0042 commented 1 year ago

Ok, dug into this on the weekend and I think I have everything working:

cloneofghosts commented 1 year ago

@alexander0042 Can confirm that February is returning data. There's a few spots you missed in your last round of fixes:

longitude and moonPhase aren't rounded (maybe latitude as well but it shows to 2 decimal points in my query) and the summary on currently was missed as well.

alexander0042 commented 1 year ago

Great catches- should all be in there now!

cloneofghosts commented 1 year ago

@alexander0042 The icon and summary are switched in the currently block. icon is showing the summary and summary is showing the icon

alexander0042 commented 1 year ago

I saw that right after I posted☔ Just waiting for the update to propagate, but should be fixed shortly

cloneofghosts commented 1 year ago

Just checked and everything is working correctly now.

cloneofghosts commented 1 year ago

Closing this one for cleanup. If you come across this issue in the future feel free to re-open or create another issue.