Author Topic: Help downloading data from Weather Underground  (Read 300 times)

0 Members and 1 Guest are viewing this topic.

Offline IgnesFatui

  • Member
  • *
  • Posts: 4
Help downloading data from Weather Underground
« on: July 24, 2021, 09:56:43 AM »
First of all, huge thanks to all of the contributors to this project for their excellent work. =D> I now have WeeWx running alongside Pi Hole on a Raspberry Pi and I'm very delighted with the functionality.

I have been uploading weather data to Weather Underground since mid-2015 from my Ambient Weather device. Now I would like to get that data back so that I can add it to the WeeWX database. Fortunately I am grandfathered in for 1500 per day/30 per minute API calls.

I came across the WU-History app (https://github.com/ktrue/WU-History) which works fine, but I can't find a way to tell it to download the daily (5 minute interval) observations for the past 6 years. However, I am able to download the data a day at a time.

It looks like I should be passing values to the script:

Code: [Select]
$da = $_REQUEST['day'];
$mo = $_REQUEST['month'];
$yr = $_REQUEST['year'];
$da2 = $_REQUEST['dayend'];
$mo2 = $_REQUEST['monthend'];
$yr2 = $_REQUEST['yearend'];
$units = $_REQUEST['units'];
$mode = $_REQUEST['mode'];

I tried https://mywebsite.com/WXDailyHistory.php?year=2021&month=1&day=1&dayend=31&mode=1&debug=y To get the data for January of this year, but it only returned data for January 1.

The other concern is that I think the current Weather Underground API is https://api.weather.com/v2/pws/history/all??stationId=KSSCCCCCN&format=json&units=m&date=YYYYMMDD&apiKey=xxxxxxxxxxx, but the script uses https://www.wunderground.com/weatherstation/WXDailyHistory.asp

I wonder if I should just run a JavaScript script from my browser to get this data? Any guidance would be greatly appreciated.

« Last Edit: July 25, 2021, 08:07:07 AM by IgnesFatui »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8617
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Help downloading data from Weather Underground
« Reply #1 on: July 24, 2021, 03:38:19 PM »
For getting the data, the only script you need to run from https://github.com/ktrue/WU-history is the WXDailyHistory.PHP script.  It will access the api.weather.gov JSON data, save it to a cache file, and create a .csv of the data just like the old WXDailyHistory.asp page used to on the WU site.

For a day's data, you should use (localhost)/WXDailyHistory.php?month=1&day=1&year=2021&format=1&graphspan=day
The day data request will only return one full day's data .. increment the &day= value for other dates within the month.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline IgnesFatui

  • Member
  • *
  • Posts: 4
Re: Help downloading data from Weather Underground
« Reply #2 on: July 25, 2021, 08:04:08 AM »
OK, I think I understand now. Thank you for the explanation. I'm sure I can kludge something together to programmatically retrieve all 1800+ records.

 

anything