Re: [weewx-user] New forecasting service using NDFD

2019-11-09 Thread T Reid
No luck.  The Databases section has a single entry for all forecast data.  
So nothing to add there.

On Saturday, November 9, 2019 at 3:58:18 PM UTC-8, T Reid wrote:
>
> I did add it to the Forecast section in weewx.conf, and to the Services 
> list, but haven't tried the Databases section.  I will try that and report 
> back.
>
> On Saturday, November 9, 2019 at 3:07:10 PM UTC-8, p q wrote:
>>
>>
>> Configuration
>>
>>To enable forecasting, add a [Forecast] section to weewx.conf, add a
>>section to [Databases] to indicate where forecast data should be 
>> stored,
>>then append user.forecast.XXXForecast to the service list for each
>>forecasting method that should be enabled.
>>
>> Have you tried this?
>>
>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/2ebf8d2f-1d59-4183-a120-004a26d6147f%40googlegroups.com.


Re: [weewx-user] New forecasting service using NDFD

2019-11-09 Thread T Reid
I did add it to the Forecast section in weewx.conf, and to the Services 
list, but haven't tried the Databases section.  I will try that and report 
back.

On Saturday, November 9, 2019 at 3:07:10 PM UTC-8, p q wrote:
>
>
> Configuration
>
>To enable forecasting, add a [Forecast] section to weewx.conf, add a
>section to [Databases] to indicate where forecast data should be stored,
>then append user.forecast.XXXForecast to the service list for each
>forecasting method that should be enabled.
>
> Have you tried this?
>
>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/19707692-ff95-4725-b445-e0f4c0c5c4ce%40googlegroups.com.


Re: [weewx-user] New forecasting service using NDFD

2019-11-09 Thread p q
Oh, and did you notice this line:

[Engine]
[[Services]]
# append only the forecasting service(s) that you need
archive_services = ... , user.forecast.XTideForecast,
user.forecast.ZambrettiForecast, user.forecast.NWSForecast,
user.forecast.WUForecast, user.forecast.OWMForecast,
user.forecast.UKMOForecast, user.forecast.AerisForecast,
user.forecast.WWOForecast, user.forecast.DSForecast

You might add user.forecast.NDFDforecast to it



On Sat, Nov 9, 2019 at 3:06 PM p q  wrote:

> Hi,
>
> I've implemented the NWS and WU forecasts for my site, but otherwise
> haven't really looked into the guts of the forecast module. With WU being
> no longer useful, I'm interested in getting this to work. I'll install it
> on my dev VM and see what I can figure out. It will be a day or two before
> I can get to it.
>
> In the meantime, I've just been reading the comments in forecast.py -
>
> Configuration
>
>To enable forecasting, add a [Forecast] section to weewx.conf, add a
>section to [Databases] to indicate where forecast data should be stored,
>then append user.forecast.XXXForecast to the service list for each
>forecasting method that should be enabled.
>
> Have you tried this?
>
> On Sat, Nov 9, 2019 at 2:36 PM T Reid  wrote:
>
>> I need help implementing a new forecasting service on weewx using the
>> NWS National Digital Forecast Database (
>> https://graphical.weather.gov/xml/).  This should allow for much more
>> precise local forecasting than the existing NWS forecast module in weewx.
>> I wrote the attached class and pasted it into forecast.py.  But cannot
>> figure out how to get forecast.py to actually run forecasts using this
>> class.  Any suggestions?  Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to weewx-user+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/weewx-user/c924906c-9acd-4e0a-a49c-767a9c514e1b%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Peter Quinn
> (415)794-2264
>


-- 
Peter Quinn
(415)794-2264

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAA1SM22mz1HJPRf9ebCfxnrho-R0x7LdYMAruvDOCmQvaP2jog%40mail.gmail.com.


Re: [weewx-user] New forecasting service using NDFD

2019-11-09 Thread p q
Hi,

I've implemented the NWS and WU forecasts for my site, but otherwise
haven't really looked into the guts of the forecast module. With WU being
no longer useful, I'm interested in getting this to work. I'll install it
on my dev VM and see what I can figure out. It will be a day or two before
I can get to it.

In the meantime, I've just been reading the comments in forecast.py -

Configuration

   To enable forecasting, add a [Forecast] section to weewx.conf, add a
   section to [Databases] to indicate where forecast data should be stored,
   then append user.forecast.XXXForecast to the service list for each
   forecasting method that should be enabled.

Have you tried this?

On Sat, Nov 9, 2019 at 2:36 PM T Reid  wrote:

> I need help implementing a new forecasting service on weewx using the
> NWS National Digital Forecast Database (https://graphical.weather.gov/xml/).
> This should allow for much more precise local forecasting than the existing
> NWS forecast module in weewx.  I wrote the attached class and pasted it
> into forecast.py.  But cannot figure out how to get forecast.py to actually
> run forecasts using this class.  Any suggestions?  Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/c924906c-9acd-4e0a-a49c-767a9c514e1b%40googlegroups.com
> 
> .
>


-- 
Peter Quinn
(415)794-2264

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAA1SM21UGBA2u8XH7vZqagXZxsufLLh7x4ZO%2B-UpAUYdBDSqLA%40mail.gmail.com.


[weewx-user] New forecasting service using NDFD

2019-11-09 Thread T Reid
I need help implementing a new forecasting service on weewx using the 
NWS National Digital Forecast Database 
(https://graphical.weather.gov/xml/).  This should allow for much more 
precise local forecasting than the existing NWS forecast module in weewx.  
I wrote the attached class and pasted it into forecast.py.  But cannot 
figure out how to get forecast.py to actually run forecasts using this 
class.  Any suggestions?  Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/c924906c-9acd-4e0a-a49c-767a9c514e1b%40googlegroups.com.
import xml.etree.ElementTree as ET

# -
# National Digital Forecast Database
#
# Forecasts from the National Digital Forecast Database. Returns xml data.
#
# For documentation, see:
#   https://graphical.weather.gov/xml/
#
# 12-hour:
# pop12 - likelihood of measurable precipitation (1/100 inch)
# maxt - temperature in degrees F
# mint - temperature in degrees F
#
# 6-hour:
# qpf - quantitative precipitation forecast; amount or range in inches
# wgust - only displayed if gusts exceed windspd by 10 mph
#
# 3-hour:
# temp - degrees F
# dew - degrees F
# rh - relative humidity %
# wdir - 8 compass points
# wspd - miles per hour
# sky - sky coverage
# icons - url for weather condition icon
# -

NDFD_KEY = 'NDFD'
NDFD_DEFAULT_URL = 'https://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?whichClient='

class NDFDForecast(Forecast):

def __init__(self, engine, config_dict):
super(NDFDForecast, self).__init__(engine, config_dict, NDFD_KEY, interval=10800)
d = config_dict.get('Forecast', {}).get(NDFD_KEY, {})
self.url = d.get('url', NDFD_DEFAULT_URL)
self.max_tries = int(d.get('max_tries', 3))
self.location = d.get('location', None)
self.units = d.get('units', 'e')

errmsg = []
if self.location is None:
errmsg.append('location is not specified')
if errmsg:
for e in errmsg:
logerr("%s: %s" % (NDFD_KEY, e))
logerr('%s: forecast will not be run' % NDFD_KEY)
return

loginf('%s: interval=%s max_age=%s location=%s' % (NDFD_KEY, self.interval, self.max_age, self.location))
self._bind()

def get_forecast(self, dummy_event):
"""Return a parsed forecast."""

text = self.download(location=self.location, url=self.url, units=self.units, max_tries=self.max_tries)
if text is None:
logerr('%s: no forecast data for %s from %s' % (NDFD_KEY, self.location, self.url))
return None
if self.save_raw:
self.save_raw_forecast(text, basename='ndfd-raw')
records, msgs = self.parse(text, location=self.location)
if self.save_failed and len(msgs) > 0:
self.save_failed_forecast(text, basename='ndfd-fail', msgs=msgs)
loginf('%s: got %d forecast records' % (NDFD_KEY, len(records)))
return records

@staticmethod
def download(location, url=NDFD_DEFAULT_URL, units='e', max_tries=3):
"""Download a forecast from the National Digital Forecast Database 

location - location for which the forecast is required, either as
   a five-digit zipcode or in the format lat,lon.

url - URL to the forecast service.  if anything other than the
  default is specified, that entire URL is used.  if the default
  is specified, it is used as the base and other items are added
  to it.

units - units to be used in the forecast, either 'e' for US or 'm' for metric.

max_tries - how many times to try before giving up
"""

if url == NDFD_DEFAULT_URL:
begDate = datetime.datetime.utcnow()
begStr = begDate.strftime("%Y-%m-%dT00%%3A00%%3A00")
endDate = begDate.replace(year=begDate.year+1)
endStr = endDate.strftime("%Y-%m-%dT00%%3A00%%3A00")
optString = '=time-series=' + begStr + '=' endStr + '=' + units +'=maxt=mint=temp=qpf=pop12=dew=wspd=wdir=sky=icons=rh=wgust=Submit'
locPoint = None
locZip = re.match(r'^\d{5}$', location.strip())
if locZip is not None:
u = url + 'LatLonListZipCode=' + str(locZip) + '=Submit'
request = urllib2.Request(u)
loginf("%s: downloading latitude and longitude for zipcode %s" % (NDFD_KEY, locZip))
for count in range(max_tries):
try:
response = urllib2.urlopen(request)
tree = ET.parse(response)