Issue with NOAA Template when trying to add additional fields

125 views
Skip to first unread message

Rahul Bedi

unread,
Jun 30, 2020, 8:32:23 AM6/30/20
to weewx-user
Hi,

I have been trying to update the NOAA template to incorporate the air quality data in the monthly report, but when I added the two entries (in red)  in the file  NOAA-YYYY-MM.txt.tmpl, I an error (attached at the end).
Interestingly the same two entries, in the hilo.inc file in the Seasons skin work fine.

Even more interestingly, the same two entries placed just before the "MONTHLY ..." line, work just fine.

Any idea about what am I doing wrong ?

Thanks.

- Rahul


#errorCatcher Echo
#set $YM="%Y %m"
#set $D=" %d"
#set $M=" %b"
#set $Time=" %H:%M"
#set $NODAY=" N/A"
#set $Temp="%6.1f"
#set $Wind="%6.1f"
#set $Dir="%6.0f"
#set $Count="%6d"
#set $NONE="   N/A"
#if $unit.unit_type_dict.group_rain == "mm"
#set $Rain="%6.1f"
#else
#set $Rain="%6.2f"
#end if


                   MONTHLY CLIMATOLOGICAL SUMMARY for $month_name $year_name


NAME: $station.location
ELEV: $station.altitude    LAT: $station.latitude[0]-$station.latitude[1] $station.latitude[2]    LONG: $station.longitude[0]-$station.longitude[1] $station.longitude[2]


                   TEMPERATURE ($unit.label.outTemp.strip()), RAIN ($unit.label.rain.strip()), WIND SPEED ($unit.label.windSpeed.strip())

                                         HEAT   COOL         AVG
      MEAN                               DEG    DEG          WIND                   DOM
DAY   TEMP   HIGH   TIME    LOW   TIME   DAYS   DAYS   RAIN  SPEED   HIGH   TIME    DIR
---------------------------------------------------------------------------------------
#for $day in $month.days
#if $day.barometer.count.raw
$day.dateTime.format($D) $day.outTemp.avg.nolabel($Temp,$NONE) $day.outTemp.max.nolabel($Temp,$NONE) $day.outTemp.maxtime.format($Time) $day.outTemp.min.nolabel($Temp,$NONE) $day.outTemp.mintime.format($Time) $day.heatdeg.sum.nolabel($Temp,$NONE) $day.cooldeg.sum.nolabel($Temp,$NONE) $day.rain.sum.nolabel($Rain,$NONE) $day.wind.avg.nolabel($Wind,$NONE) $day.wind.max.nolabel($Wind,$NONE) $day.wind.maxtime.format($Time) $day.wind.vecdir.nolabel($Dir,$NONE) $day('purpleair_binding').pm2_5_atm.maxtime.format($Time) $day('purpleair_binding').pm2_5_atm.max.nolabel($Count,$NONE)
#else
$day.dateTime.format($D)
#end if
#end for
---------------------------------------------------------------------------------------
    $month.outTemp.avg.nolabel($Temp,$NONE) $month.outTemp.max.nolabel($Temp,$NONE)    $month.outTemp.maxtime.format($D) $month.outTemp.min.nolabel($Temp,$NONE)    $month.outTemp.mintime.format($D) $month.heatdeg.sum.nolabel($Temp,$NONE) $month.cooldeg.sum.nolabel($Temp,$NONE) $month.rain.sum.nolabel($Rain,$NONE) $month.wind.avg.nolabel($Wind,$NONE) $month.wind.max.nolabel($Wind,$NONE)    $month.wind.maxtime.format($D) $month.wind.vecdir.nolabel($Dir)



Error log:

Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: Generate failed with exception '<type 'exceptions.TypeError'>'
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: **** Ignoring template /etc/weewx/skins/Seasons/NOAA/NOAA-YYYY-MM.txt.tmpl
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: **** Reason: 'TimespanBinder' object is not callable
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 322, in generate
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "cheetah__etc_weewx_skins_Seasons_NOAA_NOAA_YYYY_MM_txt_tmpl_1593519917_36_48096.py", line 525, in respond
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "cheetah__etc_weewx_skins_Seasons_NOAA_NOAA_YYYY_MM_txt_tmpl_1593519917_36_48096.py", line 336, in __errorCatcher39
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "<string>", line 1, in <module>
Jun 30 17:55:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****  TypeError: 'TimespanBinder' object is not callable
Jun 30 17:55:26 PrideWeatherStation weewx[23078] INFO weewx.reportengine: Copied 0 files to /var/www/html/weewx
Jun 30 17:55:27 PrideWeatherStation weewx[23078] INFO weewx.cheetahgenerator: Generated 1 files for report wxobs in 0.57 seconds
Jun 30 17:55:27 PrideWeatherStation weewx[23078] INFO weewx.reportengine: Copied 0 files to /var/www/html/weewx/wxobs
Jun 30 17:55:27 PrideWeatherStation weewx[23078] INFO user.stackedwindrose: Generated 2 images for StackedWindRose in 0.41 seconds



gjr80

unread,
Jun 30, 2020, 8:40:07 AM6/30/20
to weewx-user
Hi,

Try using:

$day($data_binding='purpleair_binding').pm2_5_atm.maxtime.format($Time) $day($data_binding='purpleair_binding').pm2_5_atm.max.nolabel($Count,$NONE)

Gary

Rahul Bedi

unread,
Jun 30, 2020, 9:16:31 AM6/30/20
to weewx...@googlegroups.com
Tried. I get a similar error:

Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: Generate failed with exception '<type 'exceptions.TypeError'>'
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: **** Ignoring template /etc/weewx/skins/Seasons/NOAA/NOAA-YYYY-MM.txt.tmpl
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: **** Reason: 'TimespanBinder' object is not callable
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 322, in generate
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "cheetah__etc_weewx_skins_Seasons_NOAA_NOAA_YYYY_MM_txt_tmpl_1593522919_43_84946.py", line 479, in respond
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "cheetah__etc_weewx_skins_Seasons_NOAA_NOAA_YYYY_MM_txt_tmpl_1593522919_43_84946.py", line 252, in __errorCatcher27
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****    File "<string>", line 1, in <module>
Jun 30 18:45:19 PrideWeatherStation weewx[23078] ERROR weewx.cheetahgenerator: ****  TypeError: 'TimespanBinder' object is not callable

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/W_qTltCw7SU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/95c7ee24-4b93-4d4b-907c-42df04562fa4o%40googlegroups.com.

gjr80

unread,
Jun 30, 2020, 9:42:54 AM6/30/20
to weewx-user
I think I see what is going on. Normally you can pass a $data_binding to a $day tag to pull an aggregate from another database. However, in this case the $day tag is not a normal $day tag but rather it comes from iterating over all of the days in the month (for $day in $month.days) and you can't pass a $data_binding to that $day (I suspect you can pass it to $month but that is going to apply the same data binding to all $day tags). So I can't see how it can be done (short of putting you air quality data in the same database). Might be worth waiting till Tom looks at this, he may have some cunning magic he can perform.

Gary

Tom Keffer

unread,
Jun 30, 2020, 9:44:12 AM6/30/20
to weewx-user
Yes, this is a limitation in the iterators: they cannot use a data binding. There's probably a workaround, but I'd have to think about it a bit.

In the meantime, I've put up issue #580 to track.

Probably related to issue #384 as well.

-tk

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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAJCGUpqgM%3D_cQ911ksWdib3N6hgP_Jj%2Ba%2BZS9-OJJtdHZXXKyA%40mail.gmail.com.

Rahul Bedi

unread,
Jun 30, 2020, 9:59:05 AM6/30/20
to weewx...@googlegroups.com
Thanks Tom and Gary. The only other way I can think of is to do the kludgy way of removing the loop altogether and doing it 31 times for the month :(. Not pretty but had to do that in hilo.inc

- Rahul

Rahul Bedi

unread,
Jun 30, 2020, 11:07:04 AM6/30/20
to weewx...@googlegroups.com
BTW if I was to manually replace $day with a variable that is, say, the first day of the month ? How would I do that ?

I am trying to remove the loop and replace that with 31 lines that will be one for each possible date.

Thx.

- Rahul

gjr80

unread,
Jun 30, 2020, 6:20:51 PM6/30/20
to weewx-user
There is nothing that will directly give you the first of the month. The closest you can do is $days_ago:

$day($data_binding=‘some binding’, $days_ago=20).outTemp.maxtime

But of course as we move through the month the actual day provided will change. You could use a little in-line python in your template to calculate an offset based on the current day of month to use with the number of days ago and then use that in the tag, eg (untested):

#set $offset = (some calculation)
$day($data_binding=‘some binding’, $days_ago=$offset).outTemp.maxtime
$day($data_binding=‘some binding’, $days_ago=$offset+1).outTemp.maxtime

Not sure how well that will work (not sure if in-line calculation is supported in $day() tags) and it’s starting to get complex and messy.

For info detail on aggregate tag usage can be found in the Customization Guide (http://weewx.com/docs/customizing.htm#general_aggregation_periods).

Gary

Tom Keffer

unread,
Sep 16, 2020, 11:58:04 AM9/16/20
to weewx-user
Turned out allowing iterators to use data bindings was an easier problem than I thought. Fixed in commit b50fe45

Now you can do something like 

#for $day in $month.days
$day($data_binding='purpleair_binding').pm2_5_atm.max
#end for
-tk

Reply all
Reply to author
Forward
0 new messages