Hi,
I originally sent this to the author but posting here as well. I am trying
to use the $daylight tag to display the daylight average of UV and
Radiation values. It works fine in the current day and yesterday templates,
but generates an error when I try to use accumulator code for the week,
month and year templates, and the month and year report templates. I am
using the NeowWX-Material skin with WeeWX 4.8 on a RPi 4B 4GB running
Bullseye.
Code:
#from weewx.units import ValueTuple, ValueHelper
#for $dd in $week.days
#set $light=$daylight(timestamp=$dd)
#set $dayradiation=$dd.$light.radiation.sum.raw <-- this is where it fails
#set $dayradiationacc=$dayradiationacc.raw+$dayradiation.raw
#end for
#set $dayradiationavg=$dayradiationacc.raw/$week.days
#set
$dayradiation_vh=ValueHelper(ValueTuple($dayradiationavg,$unit.unit_type.radiation,'group_radiation'),formatter=$station.formatter)
...
<div class="row">
<div class="col-3 text-muted font-small">
$dayradiation_vh <br>
$Extras.Translations[$Extras.language].avg
</div>
<div class="col-6">
<h4 class='h2-responsive
'>$week.radiation.energy_integral.kilowatt_hour_per_meter_squared</h4>
</div>
<div class="col-3 text-muted font-small hi-text">
$week.radiation.max <br>
($week.radiation.maxtime.format($Extras.Formatting.datetime))
</div>
</div>
Error:
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator:
Evaluation of template /etc/weewx/skins/neowx-material/week.html.tmpl
failed with exception '<class 'TypeError'>'
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
Ignoring template /etc/weewx/skins/neowx-material/week.html.tmpl
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
Reason: 'ObservationBinder' object is not callable
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
Traceback (most recent call last):
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
File "/usr/share/weewx/weewx/cheetahgenerator.py", line 348, in generate
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
unicode_string = compiled_template.respond()
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
File
"cheetah__etc_weewx_skins_neowx_material_week_html_tmpl_1674650728_0954206_64383.py",
line 574, in respond
Jan 25 12:45:28 weather weewx[625144] ERROR weewx.cheetahgenerator: ****
TypeError: 'ObservationBinder' object is not callable
Any help, pointers or neater code would be appreciated!
On Saturday, November 5, 2022 at 1:00:05 PM UTC [email protected] wrote:
> I updated the $daylight tag. The whole tag is
>
> $daylight(timestamp=None, data_binding=None, days_ago=0, horizon=None,
> use_center=False).observation.aggregation
>
> Using the option timestamp the $daylight timespan can be used for every
> day, not only the actual day.This makes it possible to do things like that:
> #for $dd in month.days
> <p>
> $dd.dateTime
> day average: $dd.outTemp.avg,
> average during light day: $daylight(timestamp=$dd).outTemp.avg
> </p>
> #end for
>
> While `$almanac.sunrise` and `$almanac.sunset` calculate sunrise and
> sunset using the actual temperature and barometer of the calculation time, `
> $daylight` now observes temperature and barometer of the time, the
> daylight timespan is calculated for if there are database records
> available. It first calculates approximate sunrise and sunset times for the
> ICAO standard atmosphere at 15°C and 1013.25 mbar. Then it looks up the
> real temperature and barometer for both those times. After that it
> calculates sunrise and sunset again, using the respective temperature and
> barometer.
>
> That's why `$daylight(timestamp=$X).start` provides a slightly more
> accurate time for sunrise than `$almanac(timestamp=$X).sunrise` if `$X`
> is a timestamp somewhere in the past and database records are available for
> that time. The same applies to `$daylight(timestamp=$X).end` instead of `
> $almanac(almanac_time=$X).sunset` for sunset and `
> $daylight(timestamp=$X).length` instead of `
> $almanac(almanac_time=$X).sun.visible` for the daylight duration.
>
> But please note that the real purpose of the $daylight tag is not sunrise
> and sunset but aggregation.
>
> https://github.com/roe-dl/weewx-GTS
>
>>
>>>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/4e678828-0575-403b-8e1a-38741a3bcc65n%40googlegroups.com.