Author Topic: Progress made on interface to NWS NDFD/SOAP service  (Read 1909 times)

0 Members and 1 Guest are viewing this topic.

Offline JPB

  • Member
  • *
  • Posts: 28
Progress made on interface to NWS NDFD/SOAP service
« on: December 02, 2012, 03:37:50 PM »
Hi everyone -

I wrote a week or so ago that I was working on some PHP code to interface to this service. As far as I can see, the NDFD (National Digital Forecast Database) is a fairly stable service, and it seems to work nationwide (vs. some that worked in some NOAA regions only, or others, or that seemed to extract from this very lower-level SOAP service.)

I'm using the NuSOAP PHP package located at http://sourceforge.net/projects/nusoap/.

I'm also using a modified XML PHP package located at https://github.com/rmccue/XMLize/wiki, and calls that package in a way that comes from the pxweather package at http://pxweather.abbett.org/, although the interface used in my package is completely different from this one.

My package calls two different services, and combines the result together. First, it calls the NDFDgenByDay service, to get basic elements of a forecast array, 12 hours apart, including names for the elements of the forecast array, man/min temperatures, and basic weather conditions. Second, it then calls the NDFDgen service to obtain details, which then are mapped into those 12 hour blocks in various ways. I then do work changing the icons to use precipitation percentage icons more often than the default NWS does (which started this), and also create text snippets to build a basic 'forecast line' from the data. The result is an array of 13 nodes, an example of one of these nodes follows. Calling it, you just give a lat/long. It caches the NDFD information, and will only allow refreshes of it every 60 minutes, to avoid hitting the NWS servers too much. (Of course, calling with different lat/long produces different cache files.)

I'm hoping this service stays stable. If it does, it will allow me a way to pull together elements of a forecast that allow me to avoid worrying about scraping together text from web pages.

My next task is to build the typical 'row of forecast icons + forecasts' HTML from this array, and then compare them over time to the NWS forecast summaries, to make sure I've done this reasonably well.

After that, I want to add information from the NWS CAP/ATOM feeds for alerts, warnings, etc.

My final goal is to not use the NDFDgenByDay service at all, and build everything from just the 'detailed' call. That probably will begin during the end of year holiday break.

I have to be honest and say this is all more than a bit of a pain, especially because the time-intervals given for different items in NDFDgen do not always match up, requiring working through that.



           
  • => Array

                (
                    [period-name] => Today
                    [weather-summary] => Rain
                    [conditions-text] => Moderate rain certain.
                    [temperature-text] => High of 63.
                    [high-temperature] => 63
                    [temperature-units] =>
                    [low-temperature] =>
                    [probability-of-precipitation-percent] => 100
                    [rain-amount] => 0.45
                    [rain-units] => inches
                    [snow-amount] => 0
                    [snow-units] => inches
                    [precipitation-text] => Expecting approximately 0.45 inches of rain.
                    [cloud-low] => 70
                    [cloud-high] => 93
                    [cloud-text] => Cloud coverage 70-93% of forecast area.
                    [conditions-icon] => weather_parser/icons/ra100.jpg
                    [humidity-low] => 70
                    [humidity-high] => 78
                    [humidity-text] => Humidity 70-78%
                    [wind-sustained-low] => 7
                    [wind-sustained-high] => 9
                    [wind-speed-units] => mph
                    [wind-gust-low] => 9
                    [wind-gust-high] => 13
                    [wind-text] => Sustained winds W-NW at 7 to 9 mph; gusting winds at 9 to 13 mph.

« Last Edit: December 02, 2014, 01:30:07 PM by JPB »
Davis Pro 2, Meteohub

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1308
  • BismarckWeather.net
    • BismarckWeather.net
Re: Progress made on interface to NWS NDFD/SOAP service
« Reply #1 on: December 11, 2012, 10:16:17 AM »
I'd be willing to test anything on a test page for my site.  I'm not a PHP programmer though.  So my knowledge to help you would be limited.

BTW, I'm using GoDaddy hosting and PHP.  So I'm not sure if they have all the requirements installed for me or not.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline JPB

  • Member
  • *
  • Posts: 28
Re: Progress made on interface to NWS NDFD/SOAP service
« Reply #2 on: December 13, 2012, 10:03:30 PM »
Thanks, 92 merc!  :grin:  I appreciate the offer - but I have a PHP enabled site where I can run the scripts.

I've added alert/warning info to this now. Here's an example of it where I 'cheat' and make the 'alert zone' be a location that doesn't match the other parameters, simply to grab from a place with more than one active alert, to test multi-alert handling. This script is now pretty much 'done' for its original purpose: Grab information from the NWS and put it in one handy PHP array. This allows me to completely divorce the collection of NWS information from its display, allowing for variant 'display scripts' to be written on top of it. For example, something suitable for mobile displays vs. computer could use this same 'parser' to get the same information, while doing vastly different things to it.

Is there any other information people would want to see in a 'NWS Weather ForecastGrabber' script?

Code: [Select]


FORECAST_RESULT: Array
(
    [0] => OK
    [forecast-parameters] => Array
        (
            [placename] => Minneapolis, MN
            [latitude] => 45.263
            [longitude] => -93.003
            [nws_zone] => AZZ512
            [timezone] => America/Chicago
            [generated-on] => 2012-12-14T02:19:30Z
            [programmer-disclaimer-text] => The user and/or reader assumes the entire risk related to its use of this data. This code is providing this data "as is," and the author of the code, or the hoster of this script, disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose. In no event will the programmer of this code, or the website hosting it, be liable to you or to any third party for any direct, indirect, incidental, consequential, special or exemplary damages or lost profit resulting from any use or misuse of this data. This service is provided as a hobby in programming; it could very well contain completely inaccurate data. It is suggested you view it as a results of a hobby, and not base any decisions on its results.
            [nws-disclaimer-url] => http://www.nws.noaa.gov/disclaimer.html
            [nws-more-info-url] => http://forecast.weather.gov/MapClick.php?textField1=45.26&textField2=-93.00
        )

    [forecast-details] => Array
        (
            [0] => Array
                (
                    [period-name] => Tonight
                    [weather-summary] => Areas Fog
                    [conditions-text] => Areas of none fog.
                    [temperature-text] => Low of 13.
                    [low-temperature] => 13
                    [temperature-units] => Fahrenheit
                    [high-temperature] =>
                    [probability-of-precipitation-percent] => 2
                    [rain-amount] => 0
                    [rain-units] => inches
                    [snow-amount] => 0
                    [snow-units] => inches
                    [precipitation-text] =>
                    [cloud-low] => 41
                    [cloud-high] => 63
                    [cloud-text] => Cloud coverage 41-63% of forecast area.
                    [conditions-icon] => weather/extras/weather_parser/icons/nbknfg.jpg
                    [humidity-low] => 96
                    [humidity-high] => 100
                    [humidity-text] => Humidity 96-100%
                    [wind-direction-units] => degrees true
                    [wind-direction-raw-first] => 320
                    [wind-direction-raw-second] => 70
                    [wind-direction-first] => NW
                    [wind-direction-second] => ENE
                    [wind-sustained-low] => 2
                    [wind-sustained-high] => 3
                    [wind-speed-units] => mph
                    [wind-gust-low] => 2
                    [wind-gust-high] => 3
                    [wind-text] => Sustained winds NW-ENE at 2 to 3 mph; gusting winds at 2 to 3 mph.
                )

            [1] => Array
                (
                    [period-name] => Tomorrow
                    [weather-summary] => Mostly Cloudy
                    [conditions-text] =>
                    [temperature-text] => High of 35.
                    [high-temperature] => 35
                    [temperature-units] => Fahrenheit
                    [low-temperature] =>
                    [probability-of-precipitation-percent] => 2
                    [rain-amount] => 0
                    [rain-units] => inches
                    [snow-amount] => 0
                    [snow-units] => inches
                    [precipitation-text] =>
                    [cloud-low] => 54
                    [cloud-high] => 65
                    [cloud-text] => Cloud coverage 54-65% of forecast area.
                    [conditions-icon] => weather/extras/weather_parser/icons/bkn.jpg
                    [humidity-low] => 72
                    [humidity-high] => 100
                    [humidity-text] => Humidity 72-100%
                    [wind-direction-units] => degrees true
                    [wind-direction-raw-first] => 110
                    [wind-direction-raw-second] => 130
                    [wind-direction-first] => ESE
                    [wind-direction-second] => SE
                    [wind-sustained-low] => 3
                    [wind-sustained-high] => 10
                    [wind-speed-units] => mph
                    [wind-gust-low] => 3
                    [wind-gust-high] => 13
                    [wind-text] => Sustained winds ESE-SE at 3 to 10 mph; gusting winds at 3 to 13 mph.
                )

            [2] => Array
                (
                    [period-name] => Tomorrow Night
                    [weather-summary] => Chance Wintry Mix
                    [conditions-text] => Chance of light freezing rain.
                    [temperature-text] => Low of 30.
                    [low-temperature] => 30
                    [temperature-units] => Fahrenheit
                    [high-temperature] =>
                    [probability-of-precipitation-percent] => 51
                    [rain-amount] => 0.08
                    [rain-units] => inches
                    [snow-amount] => 0
                    [snow-units] => inches
                    [precipitation-text] => Expecting approximately 0.08 inches of rain.
                    [cloud-low] => 44
                    [cloud-high] => 99
                    [cloud-text] => Cloud coverage 44-99% of forecast area.
                    [conditions-icon] => weather/extras/weather_parser/icons/mix.jpg
                    [humidity-low] => 89
                    [humidity-high] => 100
                    [humidity-text] => Humidity 89-100%
                    [wind-direction-units] => degrees true
                    [wind-direction-raw-first] => 120
                    [wind-direction-raw-second] => 130
                    [wind-direction-first] => ESE
                    [wind-direction-second] => SE
                    [wind-sustained-low] => 13
                    [wind-sustained-high] => 15
                    [wind-speed-units] => mph
                    [wind-gust-low] => 16
                    [wind-gust-high] => 21
                    [wind-text] => Sustained winds ESE-SE at 13 to 15 mph; gusting winds at 16 to 21 mph.
                )

... and continuing...

            [13] => Array
                (
                    [period-name] => Thursday
                    [weather-summary] => -N/A-
                    [temperature-text] => High of .
                    [high-temperature] =>
                    [temperature-units] => Fahrenheit
                    [low-temperature] =>
                    [probability-of-precipitation-percent] =>
                    [rain-amount] => 0
                    [rain-units] => inches
                    [snow-amount] => 0
                    [snow-units] => inches
                    [precipitation-text] =>
                    [cloud-low] => 76
                    [cloud-high] => 96
                    [cloud-text] => Cloud coverage 76-96% of forecast area.
                    [conditions-icon] =>
                    [humidity-low] => 68
                    [humidity-high] => 100
                    [humidity-text] => Humidity 68-100%
                    [wind-direction-units] => degrees true
                    [wind-direction-raw-first] => 290
                    [wind-direction-raw-second] => 300
                    [wind-direction-first] => WNW
                    [wind-direction-second] => WNW
                    [wind-sustained-low] => 12
                    [wind-sustained-high] => 15
                    [wind-speed-units] => mph
                    [wind-gust-low] => 0
                    [wind-gust-high] => 0
                    [wind-text] => Sustained winds WNW at 12 to 15 mph.
                )

        )

    [alerts] => Array
        (
            [0] => OK
            [1] => Array
                (
                    [0] => Array
                        (
                            [title] => Wind Advisory issued December 13 at 2:18PM MST until December 14 at 8:00AM MST by NWS
                            [link] => http://alerts.weather.gov/cap/wwacapget.php?x=AZ124CD5C41498.WindAdvisory.124CD5D1F040AZ.TWCNPWTWC.62d874336f34c1bb5e8ba9143163db72
                            [event] => Wind Advisory
                            [start-valid-time] => 2012-12-13T14:18:00-07:00
                            [end-valid-time] => 2012-12-14T05:00:00-07:00
                            [status] => Actual
                            [msgType] => Alert
                            [category] => Met
                            [urgency] => Expected
                            [severity] => Minor
                            [certainty] => Likely
                            [area-desc] => Chiricahua Mountains including Chiricahua National Monument; Dragoon, Mule, Huachuca and Santa Rita Mountains including Bisbee, Canelo Hills, Madera Canyon; Eastern Cochise County Below 5000 Feet including Douglas, Willcox; Upper San Pedro River Valley including Sierra Vista, Benson
                            [summary-text] => ...WIND ADVISORY NOW IN EFFECT UNTIL 8 AM MST FRIDAY... THE WIND ADVISORY IS NOW IN EFFECT UNTIL 8 AM MST FRIDAY. * TIMING...GUSTY WINDS THAT HAVE DEVELOPED THIS AFTERNOON WILL CONTINUE TO INCREASE THIS EVENING AHEAD OF AN APPROACHING COLD FRONT. WINDS WILL DIMINISH FRIDAY MORNING AFTER PASSAGE OF THE COLD FRONT.
                        )

                    [1] => Array
                        (
                            [title] => Winter Weather Advisory issued December 13 at 2:12PM MST until December 14 at 5:00PM MST by NWS
                            [link] => http://alerts.weather.gov/cap/wwacapget.php?x=AZ124CD5C41240.WinterWeatherAdvisory.124CD5D1F040AZ.TWCWSWTWC.885e73a44b0a8ba00291a80d172cf579
                            [event] => Winter Weather Advisory
                            [start-valid-time] => 2012-12-13T14:12:00-07:00
                            [end-valid-time] => 2012-12-14T05:00:00-07:00
                            [status] => Actual
                            [msgType] => Alert
                            [category] => Met
                            [urgency] => Expected
                            [severity] => Minor
                            [certainty] => Likely
                            [area-desc] => Chiricahua Mountains including Chiricahua National Monument; Dragoon, Mule, Huachuca and Santa Rita Mountains including Bisbee, Canelo Hills, Madera Canyon
                            [summary-text] => ...WINTER WEATHER ADVISORY REMAINS IN EFFECT FROM 11 PM THIS EVENING TO 5 PM MST FRIDAY... A WINTER WEATHER ADVISORY REMAINS IN EFFECT FROM 11 PM THIS EVENING TO 5 PM MST FRIDAY. * TIMING...SNOW WILL DEVELOP LATE THIS EVENING AND IS EXPECTED TO BECOME HEAVY AT TIMES INTO FRIDAY MORNING. PERIODS OF SNOW WILL
                        )

                )

        )

)

« Last Edit: December 13, 2012, 10:05:33 PM by JPB »
Davis Pro 2, Meteohub

 

anything