How to calculate, process and store a derived variable

Visto 42 veces
Saltar al primer mensaje no leído

Maarten van der Hoeven

no leída,
22 may 2020, 10:13:4022/5/20
a weewx-user
Hi group,

Running weewx 4, Python 3, Mysql-database, Vantage Pro 2 with solar, UV.

Within Weewx, I want to calculate a derived value from two existing values that's provided by my weather station. To be more specific, in the Netherlands, the shortage of precipitation is calculated by the amount of rainfall minus the amount of evapotransipration (sum of max ET-values every day). During the period of april till september, it;'s a drought indicator.

My SQL-query to do show is, where 'tekort'  (Dutch) stands for 'shortage'.

select abs(round(sum(archive_day_rain.sum)-sum(archive_day_ET.sum),0)) as tekort from archive_day_ET,archive_day_rain where from_unixtime(archive_day_rain.datetime,'%Y')=year(curdate()) and month(from_unixtime(archive_day_rain.datetime)) >= 4 and month(from_unixtime(archive_day_rain.datetime)) <= 9 and archive_day_rain.datetime=archive_day_ET.datetime;

What I am doing right now, is running a crontab job, and start my PHP-script every minute to calculate the outcome of the SQL-script above and writes the outcome to a plan txt-file. Next step is to grab this value from the txt-file and show it (javascript) on my website. See http://www.weerinwelsum.nl, below the webcam. It says ' Doorlopend neerslagtekort', [amount of millimeters]. This is the value I am talking about.

What I really want to achieve, is that I calculate this derived valu by WeeWX itself, and make this derived value available for everything that's wants to use is. For example, store this derived value in a database-field I am not using (for example, soilTemp4) and make this derived value available for whatever skin (in my case, Belchertown). In other words, Weewx calculates this new value and makes it available for the complete WeeWX-ecosystem (if you understand what I mean).

Am I clear in what I want to achieve? And is this possible, and what are the pointers to do so?

Tom Keffer

no leída,
22 may 2020, 20:52:3922/5/20
a weewx-user
Sounds like a perfect job for the xtypes system. See this wiki article: WeeWX V4 user defined types (xtypes). See if it answers your question.

If you define a derived variable using xtypes, it becomes a first-class type and can be used in plots, or tagged expressions. If it appears in your database schema, it will also be put in the database.

-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/d48cfc39-5e17-4795-a75f-ac4c266e73b0%40googlegroups.com.

Maarten van der Hoeven

no leída,
23 may 2020, 12:00:4423/5/20
a weewx-user
Thanks Tom for the pointer. Already busy implementing

Op zaterdag 23 mei 2020 02:52:39 UTC+2 schreef Tom Keffer:
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos