Upgrading Old extension - archivedb.getSqlVectorsExtended

75 views
Skip to first unread message

Brent Dowell

unread,
Jan 25, 2020, 2:20:42 PM1/25/20
to weewx-user
So, I'm upgrading my old windrose imageGenerator and I've been able to force it to actually generate images, but I'm not sure what to look at on how to get the data for it.

It looks like there are 3 functions that I need to really update to how things are done now, but I'm not sure where to look?

Basically what I'm looking for is something that gives the the 2 arrays like the getSqlVectorsExtended used to return.

1)     archivedb = self._getArchive(plot_options['archive_database'])
2)     plotgen_ts = archivedb.lastGoodStamp()
3)     (time_vec_t_ws,  data_windSpeed)   = archivedb.getSqlVectorsExtended('windSpeed',   minstamp, maxstamp, aggregate_interval, 'windSpeed')

If someone can point me to what I should be looking for in the new code, that would be great! 

Thanks!

Brent

gjr80

unread,
Jan 25, 2020, 3:53:25 PM1/25/20
to weewx-user
Hi,

Wow, that is old code, 2.x vintage. Things have moved on somewhat, you code will have had an archive database name as archive_database in your skin config (recall 2.x and earlier had two databases; an archive database and a stats database. 3.x and later has a singe database). The accepted way know to specify a source of archive data is to provide a binding name (as defined in weewx.conf [DataBindings], wx_binding is the default and most likely what you want. If your image generator class has derived itself from imagegenerator.ImageGenerator then your generator will have everything it needs to know to access that binding, if not then you really need to change that or you will likely run into a number of other 2.x/3.x issues/differences. lastGoodStamp is unchanged as long as you have a db manager from your binding there is no change needed there.

getSqlVectorsExtended has disappeared, there is not just getSqlVectors though it should work just fine for you though with a slightly different signature and returning two time vectors.

I would try something like this (untested of course):

binding = plot_options.get('binding', 'wx_binding')
archivedb
= self.db_binder.get_manager(binding)
plotgen_ts
= archivedb.lastGoodStamp()
plot_tspan
= weeutil.weeutil.TimeSpan(minstamp, maxstamp)
(time_vec_t_ws,  time_stop_vec_t_ws, data_windSpeed)   = archivedb.getSqlVectors(plot_tspan, 'windSpeed', aggregate_interval=aggregate_interval)

Note the above relies on you now using a config option 'binding' in your skin config file to specify the binding to be used (or you an leave it out to default to wx_binding):

binding = some_binding_name

You will find much of what you need code wise in bin/weewx/manager.py and bin/weewx/imagegenerator.py.

Gary

Brent Dowell

unread,
Jan 25, 2020, 4:02:26 PM1/25/20
to weewx-user
Yeah, It was very old.  But everything kept chugging right along.

Thanks so much for your help. I actually think I have it running!

Pretty psyched now.  I've got it all switched over to running on a raspberry pi 4 with everything running on an external ssd.

All I need to do now is print up a decent enclosure for the whole shebang and plug in my vantage vue and I should be good to go.

That wasn't that bad at all.

Thomas Keffer

unread,
Jan 25, 2020, 6:32:22 PM1/25/20
to weewx-user
Brent, 

Are you porting to V3.x? Or, 4.x? The interface to 4.x has changed yet again, although there are backwards compatibility hooks. It's oriented less around the database, more around types. 

See the Wiki article WeeWX V4 user-defined types, in particular the section Using the extensions.

--
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/df142723-2f9c-43f2-8896-050f4d060514%40googlegroups.com.

Brent Dowell

unread,
Jan 26, 2020, 10:38:12 AM1/26/20
to weewx-user
4.x. Cool, I'll check that out.

Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Brent Dowell

unread,
Jan 26, 2020, 3:39:43 PM1/26/20
to weewx-user
Just wanted to say thanks again to everyone for their help.

I've got my weather site back up and running on a raspberry pi 4 with version 4 of weewx.

http://www.palominovalleyweather.com/index.html

And now I can retire the old pc that kept hanging up on me every couple of days.
Reply all
Reply to author
Forward
0 new messages