Thanks for the help, I've got this running pretty well now, however I have
an issue with formatting a variable. The WXSim developer has told me the
expected rain value is an accumulator for the year. I created a $rainacc so
the template code looks like this:
#set $rainacc = $year.rain.sum.raw - $month.rain.sum.raw
#for $record in $month.records
#set $rainacc = $rainacc + $record.rain.raw
$record.dateTime.format("%d/%m/%Y
%H:%M"),$record.outTemp.format(add_label=False),$record.outHumidity.format(add_label=False),$record.dewpoint.format(add_label=False),$record.windSpeed.format(add_label=False),$record.windGust.format(add_label=False),$record.windDir.format(add_label=False),0,0,$record.barometer.format(add_label=False),$rainacc,0,0,0,0,0,0,$record.radiation.format(add_label=False),0
#end for
This works, however the output for rain is to 13 decimals:
1083.8000001314047. No matter what I do I can't seem to format it to 2
decimal places. I have tried $rainacc.round(2)and $rainacc.format(%.2f)
On Thursday, December 19, 2024 at 9:03:19 AM UTC Rory Gillies wrote:
> Thanks Gary, that did the trick! Doesn't take long on my RPi 5 for 19 days
> in December:
>
> 2024-12-19T08:55:33.656223+00:00 weewx5 weewxd[1317867]: INFO
> weewx.cheetahgenerator: Generated 1 files for report cumulus in 3.50 seconds
>
> Cheers,
>
> Rory
> On Thursday, December 19, 2024 at 3:57:23 AM UTC gjr80 wrote:
>
>> So you want to build a file with potentially 8928 rows (31 days per month
>> 288 records per day)?
>>
>> If so this should be able to be done solely in a Cheetah template using
>> just a few lines of code by iterating over the archive records in the
>> month. Something like (untested):
>>
>> #for $record in $month.records
>> $record.dateTime,$record.outTemp.format(add_label=False),.....
>> #end for
>>
>> Like I said untested and I haven't used record iterators for a long time
>> but at worst a little finessing should get you there. One thing to note,
>> report generation time will gradually increase as the month progresses
>> peaking on the last record of the last day of the month.
>>
>> Gary
>>
>> On Thursday, 19 December 2024 at 05:55:37 UTC+10 [email protected]
>> wrote:
>>
>>> Hi, at first I thought this would be quite easy but I'm struggling a
>>> bit. The background is I need a text file to import into WXSim using the
>>> Cumulus %Y%mlog.txt format. I created a simple skin that generates the
>>> %Y%mlog.txt each reporting cycle (5 minutes in my case), but is there a way
>>> to append the next cycle to the existing file as a new line rather than
>>> overwrite it?
>>>
>>> My skin.conf looks like this:
>>>
>>> [CheetahGenerator]
>>> encoding = utf8
>>>
>>> [[ToDate]]
>>> [[[text-data]]]
>>> template = %Y%mlog.txt.tmpl
>>>
>>> [CopyGenerator]
>>> copy_always = *.txt
>>>
>>> [Generators]
>>> generator_list = weewx.cheetahgenerator.CheetahGenerator,
>>> weewx.reportengine.CopyGenerator
>>>
>>> And the template:
>>>
>>> #encoding UTF-8
>>> #errorCatcher Echo
>>> ## +------------------------------------------------------+
>>> ## | Cumulus Monthly Output Template |
>>> ## +------------------------------------------------------+
>>> ## | Produces a YYYYmmlog.txt output for import to WXSim |
>>> ## +------------------------------------------------------+
>>>
>>>
>>>
>>> $current.dateTime,$current.outTemp.format(add_label=False),$current.outHumidity.format(add_label=False),$current.dewpoint.format(add_label=False),$current.windSpeed.format(add_label=False),$current.windGust.format(add_label=False),$current.windDir.format(add_label=False),,,$current.barometer.format(add_label=False),$day.rain.sum.format(add_label=False),,,,,,,$current.radiation.format(add_label=False),
>>>
>>> Which produces a text file called 202412log.txt:
>>>
>>> 18/12/24 19:40:00,6.3,82,3.4,10,37,266,,,982.8,15.4,,,,,,,0,
>>>
>>> WXSim can read this, however it only contains a single observation
>>> period. I would like to append the data to the file until the month is
>>> complete, then generate a new file for the next month. Any ideas? It will
>>> likely need some Python which is not my strongpoint, although I can get
>>> around it a bit...
>>>
>>> I'm running WeeWX 5.1 if it makes it easier. TIA
>>>
>>
--
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 visit
https://groups.google.com/d/msgid/weewx-user/9b766655-b90d-4a85-8d48-f1d4e9fb7e96n%40googlegroups.com.