Author Topic: NWS Forecast - Short Forecast  (Read 1028 times)

0 Members and 1 Guest are viewing this topic.

Offline daneast

  • Member
  • *
  • Posts: 48
NWS Forecast - Short Forecast
« on: November 26, 2018, 07:39:39 AM »
I'm migrating my code to NWS, away from Weather Underground. I've been slowly working on this for quite some time, because WU's 10 request per minute limit was already a problem for me.  However the WU end of service in a month is obviously a hard deadline.

The NWS's data seems to be getting better - I'm pretty sure they did not have hourly forecast data several years ago when I began my project, which is one of the main reasons I went with WU. Now NWS does have hourly data, so it should be able to handle all my needs.

One problem I have with the NWS daily / period forecast is the "short" forecast isn't so short. What I need is a 2-3 word maximum summary for each period.  For example, a current shortForecast value is: "Chance Rain Showers then Slight Chance Rain And Snow Showers".  What I need is more like "Chance Rain / Show".  To generate any "tv style" forecast visual requires some extremely brief summaries to fit in the graphics.

So the point of my post - is the data I'm looking for already available and I've overlooked it?  Or has anyone done any work towards parsing down or building a very short summary for forecast periods? If not I will probably proceed by building my own text from the forecast icon's path. The path seems to contain at most two conditions, so a "Sunny / Chance Rain" type string would be easy to generate.  Just wondered if anyone already had this all worked out before I spent time on it.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Forecast - Short Forecast
« Reply #1 on: November 26, 2018, 11:58:33 AM »
Which data source from the NWS are you using?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline daneast

  • Member
  • *
  • Posts: 48
Re: NWS Forecast - Short Forecast
« Reply #2 on: November 26, 2018, 12:20:09 PM »
What I presume is the latest API, forecast endpoint.  IE: https://api.weather.gov/gridpoints/RNK/32,48/forecast

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Forecast - Short Forecast
« Reply #3 on: November 26, 2018, 12:50:21 PM »
That is what my advforecast2.php V5 uses for the forecast.  It's not hourly, it's day/night periods.  Yes the shortForecast entry is shorter than the detailedForecast, but not as 'short' as it could be if they put their mind to it.  It can be > 4 words when there is a change in the weather between the two 6hr forecast periods in Day or Night forecasts.

Keep in mind that the api.weather.gov is still in (extremely protracted) "Beta" and is cranky at times.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline daneast

  • Member
  • *
  • Posts: 48
Re: NWS Forecast - Short Forecast
« Reply #4 on: November 26, 2018, 03:49:38 PM »
I found a PHP array you posted here that contained the NWS icon filenames, and trimmed that down to what I need (which are just short text descriptions for each).  The problem I see with the approach I'm taking is indicating the likelihood. For example:
Code: [Select]
"icon": "https:\/\/api.weather.gov\/icons\/land\/day\/snow\/rain_showers?size=medium",
"shortForecast": "Slight Chance Snow Showers then Slight Chance Rain Showers",

Going by just the icon it would be "Snow / Rain Showers". That doesn't indicate the "slight chance" part. I think ideally it would be "Chance Snow / Rain Showers".

Another example:
Code: [Select]
"icon": "https:\/\/api.weather.gov\/icons\/land\/night\/snow?size=medium",
"shortForecast": "Slight Chance Rain And Snow Showers",

By the icon it would simply be "Snow".  However the forecast says "Slight chance".  If a forecast was to say "Snow" I think it sounds pretty certain it would snow.  That "Slight Chance" is not encoded anywhere in that icon, so it seems I'm going to have to parse the forecast text itself for more information.

Offline CNYWeather

  • Forecaster
  • *****
  • Posts: 2297
    • CNYWeather
Re: NWS Forecast - Short Forecast
« Reply #5 on: November 26, 2018, 04:12:42 PM »
WU used to spit out what you're looking for. Curly wrote me a script for the Short Forecast.
I've since taken it down with the WU API going away. It was a nice addition on my site.

It's not formatted correctly since it's missing the style sheet he wrote also but you get the idea.

Tony




Offline daneast

  • Member
  • *
  • Posts: 48
Re: NWS Forecast - Short Forecast
« Reply #6 on: November 26, 2018, 04:19:47 PM »
Yes that's the kind of data I'm looking for, but from NWS where it is free and unlimited. lol

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Forecast - Short Forecast
« Reply #7 on: November 26, 2018, 05:12:25 PM »
I found a PHP array you posted here that contained the NWS icon filenames, and trimmed that down to what I need (which are just short text descriptions for each).  The problem I see with the approach I'm taking is indicating the likelihood. For example:
Code: [Select]
"icon": "https:\/\/api.weather.gov\/icons\/land\/day\/snow\/rain_showers?size=medium",
"shortForecast": "Slight Chance Snow Showers then Slight Chance Rain Showers",

Going by just the icon it would be "Snow / Rain Showers". That doesn't indicate the "slight chance" part. I think ideally it would be "Chance Snow / Rain Showers".

Another example:
Code: [Select]
"icon": "https:\/\/api.weather.gov\/icons\/land\/night\/snow?size=medium",
"shortForecast": "Slight Chance Rain And Snow Showers",

By the icon it would simply be "Snow".  However the forecast says "Slight chance".  If a forecast was to say "Snow" I think it sounds pretty certain it would snow.  That "Slight Chance" is not encoded anywhere in that icon, so it seems I'm going to have to parse the forecast text itself for more information.

The terms "Slight Chance", "Chance", "Likely"  are related to the PoP in the forecast (I think).
From the NWS FAQ: https://w1.weather.gov/glossary/index.php

Slight Chance
    In probability of precipitation statements, usually equivalent to a 20 percent chance.

Chance
    A National Weather Service precipitation descriptor for 30, 40, or 50 percent chance of measurable precipitation (0.01 inch). When the precipitation is convective in nature, the term scattered is used. See Precipitation Probability (PoP).

Likely
    (abbrev. LKLY) In probability of precipitation statements, the equivalent of a 60 or 70 percent chance.

So using the icon+PoP, you can add the appropriate words about the precipitation as you like.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline daneast

  • Member
  • *
  • Posts: 48
Re: NWS Forecast - Short Forecast
« Reply #8 on: November 26, 2018, 07:58:59 PM »
I think I've come up with something I like. I've tested against many area forecasts and will continue to do more testing to find other phrases to shorten.

Examples:
In:
Slight Chance Snow Showers then Slight Chance Rain Showers
Out:
Chance Snow
Chance Rain

In:
Slight Chance Snow Showers
Out:
Chance Snow

In:
Partly Sunny then Slight Chance Rain And Snow Showers
Out:
Partly Sunny
Chance Rain & Snow

In:
Partly Cloudy then Slight Chance Light Rain
Out:
Partly Cloudy
Chance Rain

In:
Chance Light Rain then Slight Chance Rain Showers
Out:
Chance Rain

In:
Chance Light Rain then Chance Rain Showers
Out:
Chance Rain