--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/99ddc189-5354-4c2f-88d0-27e0df50db5d%40googlegroups.com.
Yes, it's certainly possible, but you would have to write a Python script to do it. You could start with the transfer_db.py script, located in the examples subdirectory.
On Tue, Oct 15, 2019 at 3:10 PM Pat <p...@obrienphoto.net> wrote:
Back when I started with weewx in 2015 I had a 1 minute archive interval. I kept it that way for a few months until I realized more in how the archive interval works.--I am performing some wee_import functions to get calc_missing on some records. wee_import warns about the mismatch in the intervals, which got me thinking:Is it possible to consolidate all my "1" interval to match the rest of my database at 5 minute intervals?
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-de...@googlegroups.com.
create temporary table cons5min as
select max(dateTime) as dateTime,
usUnits, 5 as interval,
avg(barometer) as barometer,
avg(inTemp) as inTemp,
<all the other data>
from archive
where interval = 1
group by (dateTime-60) / 300 ;
insert into archive select * from cons5min;--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/8fc3a53f-8aab-4663-a375-2ae308fd99e2%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/003757b5-bf5b-45d1-b218-a21e81db650f%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-de...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/65ecf732-75a7-4852-88bb-225b10cb2949%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/65ecf732-75a7-4852-88bb-225b10cb2949%40googlegroups.com.
Is there any reason you could not just use sqlite's own consolidation functions...
create temporary table cons5min as
select max(dateTime) as dateTime,
usUnits,
5 as interval,
avg(barometer) as barometer,
avg(pressure) as pressure,
avg(altimeter) as altimeter,
avg(inTemp) as inTemp,
avg(outTemp) as outTemp,
avg(inHumidity) as inHumidity,
avg(outHumidity) as outHumidity,
avg(windSpeed) as windSpeed,
max(windDir) as windDir,
max(windGust) as windGust,
avg(windGustDir) as windGustDir,
avg(rainRate) as rainRate,
avg(rain) as rain,
avg(dewpoint) as dewpoint,
avg(windchill) as windchill,
avg(heatindex) as heatindex,
avg(ET) as ET,
avg(radiation) as radiation,
avg(UV) as UV,
avg(extraTemp1) as extraTemp1,
avg(extraTemp2) as extraTemp2,
avg(extraTemp3) as extraTemp3,
avg(soilTemp1) as soilTemp1,
avg(soilTemp2) as soilTemp2,
avg(soilTemp3) as soilTemp3,
avg(soilTemp4) as soilTemp4,
avg(leafTemp1) as leafTemp1,
avg(leafTemp2) as leafTemp2,
avg(extraHumid1) as extraHumid1,
avg(extraHumid2) as extraHumid2,
avg(soilMoist1) as soilMoist1,
avg(soilMoist2) as soilMoist2,
avg(soilMoist3) as soilMoist3,
avg(soilMoist4) as soilMoist4,
avg(leafWet1) as leafWet1,
avg(leafWet2) as leafWet2,
avg(rxCheckPercent) as rxCheckPercent,
avg(txBatteryStatus) as txBatteryStatus,
avg(consBatteryVoltage) as consBatteryVoltage,
avg(hail) as hail,
avg(hailRate) as hailRate,
avg(heatingTemp) as heatingTemp,
avg(heatingVoltage) as heatingVoltage,
avg(supplyVoltage) as supplyVoltage,
avg(referenceVoltage) as referenceVoltage,
avg(windBatteryStatus) as windBatteryStatus,
avg(rainBatteryStatus) as rainBatteryStatus,
avg(outTempBatteryStatus) as outTempBatteryStatus,
avg(inTempBatteryStatus) as inTempBatteryStatus
FROM archive WHERE interval = 1
GROUP BY (dateTime-60) / 300;
--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/12d539d3-ef47-425b-ae92-c9850b85031c%40googlegroups.com.
...
Was a bit more painful than necessary, but...There are now 3 temporary tables and intermediate calculations.It might be possible to do it more concisely, but this way gives you intermediate steps to check if something goes wrong.I spent most time because I figured it should not need the full direction rotation, reversal and then back again. Eventually swapping X and Y does that.I wasn't helped by excel swapping the order of arguments to atan2().The sqlite maths extension also provides the degrees() and radians() functions.-- create first temporary table for wind vector averaging
-- It would be easier in table c5 except that sqlite3 cannot drop columns later.
create temporary table wind as
select max(dateTime) as dateTime,
1 as windDir,
avg(windSpeed * cos(radians(windDir))) as yvec,
avg(windSpeed * sin(radians(windDir))) as xvec
FROM archive WHERE interval = 1
GROUP BY FLOOR((dateTime-30) / 300);
-- create the temp table containing the newly consolidated results
-- the column names here should match the original database archive table,
-- for ease of re-inserting into archive
create temporary table c5 as
select max(dateTime) as dateTime,
usUnits,
5 as interval,
avg(barometer) as barometer,
avg(pressure) as pressure,
avg(altimeter) as altimeter,
avg(inTemp) as inTemp,
avg(outTemp) as outTemp,
avg(inHumidity) as inHumidity,
avg(outHumidity) as outHumidity,
avg(windSpeed) as windSpeed,
1 as windDir,
max(windGust) as windGust,
1 as windGustDir,
avg(rainRate) as rainRate,
sum(rain) as rain,
avg(dewpoint) as dewpoint,
avg(windchill) as windchill,
avg(heatindex) as heatindex,
sum(ET) as ET,
avg(radiation) as radiation,
avg(UV) as UV,
avg(extraTemp1) as extraTemp1,
avg(extraTemp2) as extraTemp2,
avg(extraTemp3) as extraTemp3,
avg(soilTemp1) as soilTemp1,
avg(soilTemp2) as soilTemp2,
avg(soilTemp3) as soilTemp3,
avg(soilTemp4) as soilTemp4,
avg(leafTemp1) as leafTemp1,
avg(leafTemp2) as leafTemp2,
avg(extraHumid1) as extraHumid1,
avg(extraHumid2) as extraHumid2,
avg(soilMoist1) as soilMoist1,
avg(soilMoist2) as soilMoist2,
avg(soilMoist3) as soilMoist3,
avg(soilMoist4) as soilMoist4,
avg(leafWet1) as leafWet1,
avg(leafWet2) as leafWet2,
avg(rxCheckPercent) as rxCheckPercent,
avg(txBatteryStatus) as txBatteryStatus,
avg(consBatteryVoltage) as consBatteryVoltage,
sum(hail) as hail,
avg(hailRate) as hailRate,
avg(heatingTemp) as heatingTemp,
avg(heatingVoltage) as heatingVoltage,
avg(supplyVoltage) as supplyVoltage,
avg(referenceVoltage) as referenceVoltage,
avg(windBatteryStatus) as windBatteryStatus,
avg(rainBatteryStatus) as rainBatteryStatus,
avg(outTempBatteryStatus) as outTempBatteryStatus,
avg(inTempBatteryStatus) as inTempBatteryStatus
FROM archive WHERE interval = 1
GROUP BY FLOOR((dateTime-30) / 300);
-- now do the vector averaging
update wind
set windDir = degrees(atan2(xvec, yvec) );
update wind
set windDir = windDir + 360.0 where windDir < 0.0;
update c5
SET windDir = (
select wind.windDir
from wind
where c5.dateTime = wind.dateTime
);
-- wind gust averaging is not done, since the gust is
-- the maximum ovre the consolidation period. This
-- extracts the direction at which the maximum was observed.
create temporary table gusts as
select
c5.dateTime as dateTime,
archive.dateTime as arcdt, -- just for checking
archive.windGustDir as windGustDir,
archive.windGust as windGust -- just for checking
from archive join c5
on archive.windGust = c5.windGust and FLOOR((archive.dateTime-30) / 300) = FLOOR((c5.dateTime-30)/300)
order by dateTime;
update c5
SET windGustDir = (
select gusts.windGustDir
from gusts
where c5.dateTime = gusts.dateTime
);
--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/6983dd6e-2f18-4f5d-a08c-8bf163f9f10e%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/8c46083f-e681-4160-aaf8-414c72947f00%40googlegroups.com.