DegreeDays accessible by a third-party application

49 views
Skip to first unread message

PC

unread,
May 18, 2022, 11:47:57 AM5/18/22
to weewx-user
Hello,

It seems to me that DegreeDays are not stored in the table (MySQL) archive.
Are they elsewhere? How can I get it through a third-party application?

Thank you !

Tom Keffer

unread,
May 18, 2022, 12:01:45 PM5/18/22
to weewx-user
Degree-days are calculated on the fly as an xtype variable. 

Where do you need them? For example, for a template, the total degree-days for a month could be calculated as $month.heatdeg.sum. 

If you need access from an outside application, then you'd have to use the xtype's Python interface.

--
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/2bb706a9-dcb5-4773-8f15-80df8fceafccn%40googlegroups.com.

PC

unread,
May 18, 2022, 12:11:34 PM5/18/22
to weewx-user
Okay,

I don't know this "xtype", I'm going to watch.
I already have the difficulty of "binding" 2 tables (see my previous post)
One more challenge, it's pleasant!

PC

unread,
May 18, 2022, 12:29:08 PM5/18/22
to weewx-user
Yes,
I just looked at, it's really too complicated to implement for what I want to do.
It would even be easier to calculate him himself!
Besides, in French, we say "why make it simple when you can make it complicated!?"
It is not complicated to calculate it once a day and store it in a small table.

Tom Keffer

unread,
May 18, 2022, 12:39:32 PM5/18/22
to weewx-user
You haven't said what your use case is. It might be quite simple. 

For example, here is how you would calculate total heating degree-days for this month in Python, using xtype. Most of the complexity is in calculating the starting and stopping times:

import time
import weewx.manager
import weewx.xtypes
import weeutil.weeutil

archive_sqlite = {
    'database_name': '/home/weewx/archive/weewx.sdb',
    'driver': 'weedb.sqlite'
}

start_tt = (2022, 5, 1, 0, 0, 0, 0, 0, -1)
end_tt = (2022, 6, 1, 0, 0, 0, 0, 0, -1)
start_ts = time.mktime(start_tt)
end_ts = time.mktime(end_tt)
timespan = weeutil.weeutil.TimeSpan(start_ts, end_ts)

with weewx.manager.DaySummaryManager.open(archive_sqlite) as db_manager:
    result = weewx.xtypes.get_aggregate('heatdeg', timespan, 'sum', db_manager)

print(result)


PC

unread,
May 18, 2022, 1:11:27 PM5/18/22
to weewx-user

" You haven't said what your use case is. It might be quite simple."
You are right.
My goal is to make statistical comparisons since the start of my surveys (from 2011 with a "View View" and which will be placed in another table).
Previously, under Windows 7, I was doing these statistics in VBA ms-access ...
It is already a challenge for me (former computer trainer mainly exclusively in Windows, Excel, Access & Cie) and now pensioner to go to Linux!

There are also and especially comparisons to seasonal norms
Just that is a big job that I was doing in several steps.
And then, that is done, they are written in a table in HTML format.

Tom Keffer

unread,
May 18, 2022, 1:26:40 PM5/18/22
to weewx-user
Well, it would be easy enough to create a CSV file using a WeeWX template. It could then be imported into Excel. Something like...

#for $month in $year.months
#if $month.outTemp.has_data
$month.dateTime.format($YM), $month.heatdeg.sum.format($Temp,$NONE,add_label=False), $month.cooldeg.sum.format($Temp,$NONE,add_label=False)
#end if
#end for

would produce something like this, where the columns are year month, heating degrees, cooling degrees

2022 01,  986.2,    0.0
2022 02,  713.5,    0.0
2022 03,  579.6,    0.0
2022 04,  625.1,    0.0
2022 05,   75.0,    0.0



PC

unread,
May 18, 2022, 2:52:29 PM5/18/22
to weewx-user
Yes,
but I need these values day after day.
What my old program was doing.
It therefore seems to me that the best solution is to create a specific table.
I would create it with my old data, then I would read the Archive table of the MySQL base of Wewx, to add the new value daily.

Tom Keffer

unread,
May 18, 2022, 3:33:34 PM5/18/22
to weewx-user
Whatever works best for you...

Chuck Rhode

unread,
May 18, 2022, 4:10:30 PM5/18/22
to weewx...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 18 May 2022 09:29:08 -0700 (PDT)
PC <blaise....@gmail.com> wrote:

> Why make it simple when you can make it complicated!?

Well, you could probably lift degree-days (DD) from the so-called NOAA
Summary Reports, which are *.txt files under $HTML_ROOT/NOAA. See the
"Customization Guide."

If you want to make it really complicated, you could install the
Phenology WeeWX Extension:

o http://lacusveris.com/Phenology/models.shtml#3.3.4.2

This extension produces an
$HTML_ROOT/phenology/cumulative_growing_degree_days.html file that you
could scrape.

- - --
.. Be Seeing You,
.. Chuck Rhode, Sheboygan, WI, USA
.. Weather: http://LacusVeris.com/WX
.. 58° — Wind E 10 mph — Sky overcast.
-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQT+MY/5I/LMPSswTbVg2/xipKOWUgUCYoVSrgAKCRBg2/xipKOW
UhHdAJ95EiFi4DQt68xgXXRdu6Uoaz7PZQCeOKeYD3ZQvO/k0WindGdj4GHTMkg=
=8tNh
-----END PGP SIGNATURE-----

PC

unread,
May 18, 2022, 4:17:05 PM5/18/22
to weewx-user
It's not my priority at the moment, but I'll come back to you with my solution
Thank you all for your kindness
Reply all
Reply to author
Forward
0 new messages