Author Topic: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available  (Read 4799 times)

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 156
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Saratoga templates use get-USNO-sunmoon.php to gather sun/moon data for display on the ajax-dashboard and wxastronomy.php pages (for all weather software except Weather-Display).

The US Naval Observatory has announced they will discontinue providing the data in the way used by V1.x of the script after July 31, 2015 and instead are offering a JSON feed of the data.  The V2.00 version of the script now uses the new JSON feed from them.

Template users: use the update tool with a query of (Base-*, Plugin-*, 29-Jul-2015) to get the updated script.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

wvdkuil

  • Strong Breeze
  • ***
  • Posts: 151
    • DW8113 (D8113)
    • IVLAAMSG47
    • Weatherstation Wilsele/Leuven/Belgium
  • Station Details: VantagePro2+ UV,Solar - Macbook/Mini
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #1 on: July 29, 2015, 04:40:24 PM »
Thanks Ken for bringing this to our attention.

As there is no other source for moon-data when using  WeatherrCat , there are different scripts using the now nearly obsolete post-script.

For users having their own scripts, the API can be found at:   http://aa.usno.navy.mil/data/docs/api.php

Wim
Support of Leuven-Template&Scripts: https://support.leuven-template.eu/
Support and demo for the PWS_Dashboard (also for WeatherCat)  https://pwsdashboard.com/ 
My PWS at home https://weer.sluispark.be/
And at my daughters house https://www.weerstation-herent.be/

wvdkuil

  • Strong Breeze
  • ***
  • Posts: 151
    • DW8113 (D8113)
    • IVLAAMSG47
    • Weatherstation Wilsele/Leuven/Belgium
  • Station Details: VantagePro2+ UV,Solar - Macbook/Mini
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #2 on: July 31, 2015, 06:12:31 PM »
For leuven-template weathercat users, a new version of the astronomy.php  script is on-line.
This script loads the moon-rise moon-set times for the dashboard and had to be changed by the introduction of the usno api.

Wim
Support of Leuven-Template&Scripts: https://support.leuven-template.eu/
Support and demo for the PWS_Dashboard (also for WeatherCat)  https://pwsdashboard.com/ 
My PWS at home https://weer.sluispark.be/
And at my daughters house https://www.weerstation-herent.be/

Alan Rowley

  • Strong Breeze
  • ***
  • Posts: 150
  • It is far better to wear out than to rust away.
    • D3696
    • INOTTING15
    • Selston Weather
  • Station Details: Weather station: Davis Vantage Pro2. Software: WeatherCat. Computer: Mac Mini, High Sierra OS
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #3 on: August 05, 2015, 06:31:02 AM »
Wim,

I installed the new version of astronomy.php yesterday and all was working correctly. This morning, I am getting the following error message:

Quote
Notice: Undefined index: moonrise in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 502

Notice: Undefined index: moonset in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 503

To get it working again, I had to delete the file 'sunMoondata.arr' from the cache. I did read that I had to use '&force=usno', where do I use this command?

ALAN.

wvdkuil

  • Strong Breeze
  • ***
  • Posts: 151
    • DW8113 (D8113)
    • IVLAAMSG47
    • Weatherstation Wilsele/Leuven/Belgium
  • Station Details: VantagePro2+ UV,Solar - Macbook/Mini
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #4 on: August 05, 2015, 08:00:08 AM »
Wim,

I installed the new version of astronomy.php yesterday and all was working correctly. This morning, I am getting the following error message:

Quote
Notice: Undefined index: moonrise in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 502

Notice: Undefined index: moonset in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 503

To get it working again, I had to delete the file 'sunMoondata.arr' from the cache. I did read that I had to use '&force=usno', where do I use this command?

ALAN.
If this is a page request  in the broser address-line
http://www.brackenhouse.net/weather27/index.php?p=10&lang=en
you add &force=xyz
http://www.brackenhouse.net/weather27/index.php?p=10&lang=en&force=xyz

If this is a page request in the browser address-line
http://www.brackenhouse.net/weather27/ 
you have to add ?force=xyz
http://www.brackenhouse.net/weather27/?force=xyz
 
So the first extra "command' starts with a  ? and all others with a  &

===

As with all forecasts  (except EWN)  the data retrieved from external sources  is valid for multiple hours.  For example there are only two new forecast / day for the met.no and yr.no forecasts. And the moon information needs to be refreshed only once/day, same with  the UV forecast and the almanac data from WU.

So when data is loaded from an external soource, that still valid data is cached. If there was an error in the data (extremely rare) or a new script version (not so rare) you can use a force=xxx to read a new data-set and refresh the cached information.

Wim
Support of Leuven-Template&Scripts: https://support.leuven-template.eu/
Support and demo for the PWS_Dashboard (also for WeatherCat)  https://pwsdashboard.com/ 
My PWS at home https://weer.sluispark.be/
And at my daughters house https://www.weerstation-herent.be/

Alan Rowley

  • Strong Breeze
  • ***
  • Posts: 150
  • It is far better to wear out than to rust away.
    • D3696
    • INOTTING15
    • Selston Weather
  • Station Details: Weather station: Davis Vantage Pro2. Software: WeatherCat. Computer: Mac Mini, High Sierra OS
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #5 on: August 05, 2015, 09:00:56 AM »
That's done Wim and all is working fine.

Do I need to use &force=usno overtime I use the astronomy.php page, or will it be ok until the script changes again?

ALAN.

wvdkuil

  • Strong Breeze
  • ***
  • Posts: 151
    • DW8113 (D8113)
    • IVLAAMSG47
    • Weatherstation Wilsele/Leuven/Belgium
  • Station Details: VantagePro2+ UV,Solar - Macbook/Mini
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #6 on: August 05, 2015, 09:08:39 AM »
That's done Wim and all is working fine.

Do I need to use &force=usno overtime I use the astronomy.php page, or will it be ok until the script changes again?

ALAN.
The force=xyz  is only used when there is a problem with the data.  The moonset/rise data will be automatically refreshed first run after midnight. Normaly you never use force=xyz for any script.

Wim
Support of Leuven-Template&Scripts: https://support.leuven-template.eu/
Support and demo for the PWS_Dashboard (also for WeatherCat)  https://pwsdashboard.com/ 
My PWS at home https://weer.sluispark.be/
And at my daughters house https://www.weerstation-herent.be/

Alan Rowley

  • Strong Breeze
  • ***
  • Posts: 150
  • It is far better to wear out than to rust away.
    • D3696
    • INOTTING15
    • Selston Weather
  • Station Details: Weather station: Davis Vantage Pro2. Software: WeatherCat. Computer: Mac Mini, High Sierra OS
Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
« Reply #7 on: August 05, 2015, 09:10:05 AM »
Thanks Wim. Got that.