Skip to content
Snippets Groups Projects
Commit 4625cbd1 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-429: add lofar views to DB

parent 30567426
No related branches found
No related tags found
1 merge request!177Resolve L2SS-429 "Timescaledb container"
......@@ -5,4 +5,5 @@ COPY resources/01_admin.sql docker-entrypoint-initdb.d/002_admin.sql
COPY resources/02_hdb_schema.sql docker-entrypoint-initdb.d/003_hdb_schema.sql
COPY resources/03_hdb_roles.sql docker-entrypoint-initdb.d/004_hdb_roles.sql
COPY resources/04_hdb_ext_aggregates.sql docker-entrypoint-initdb.d/005_hdb_ext_aggregates.sql
COPY resources/05_cleanup.sql docker-entrypoint-initdb.d/006_cleanup.sql
COPY resources/05_lofar_views.sql docker-entrypoint-initdb.d/006_lofar_views.sql
COPY resources/06_cleanup.sql docker-entrypoint-initdb.d/007_cleanup.sql
-- LOFAR 2.0 CUSTOMIZED VIEWS
\c hdb
-- SDP FPGA Temperature
create or replace view "sdp_fpga_temp" as
select
ac.att_name as "attribute",
aad.data_time AS "time",
aad.value_r
FROM att_array_devdouble aad join att_conf ac
on aad.att_conf_id = ac.att_conf_id
where aad.value_R is not null
and ac."domain" ='stat' and ac."family" ='sdp' and ac."member" ='1'
ORDER BY aad.data_time;
-- SDP FPGA Mask
create or replace view "sdp_tr_fpga_mask" as
select
ac.att_name as "attribute",
aab.data_time AS "time",
aab.value_r
FROM att_array_devboolean aab join att_conf ac
on aab.att_conf_id = ac.att_conf_id
where aab.value_R is not null
and ac."domain" ='stat' and ac."family" ='sdp' and ac."member" ='1'
ORDER BY aab.data_time;
-- SDP Masked values (rounded to 1 second)
create or replace view "sdp_masked_temp_values" as
select time_bucket('1 second',t.time) as "temp_time",
time_bucket('1 second',m.time) as "mask_time",
t.value_r as "temperature",
m.value_r as "mask"
from sdp_fpga_temp as t
inner join sdp_tr_fpga_mask as m
on time_bucket('1 second',t.time) = time_bucket('1 second',m.time)
/* Replace if possible with SQL loop */
where m.value_r[1]=true and
m.value_r[2]=true and
m.value_r[3]=true and
m.value_r[4]=true and
m.value_r[5]=true and
m.value_r[6]=true and
m.value_r[7]=true and
m.value_r[8]=true and
m.value_r[9]=true and
m.value_r[10]=true and
m.value_r[11]=true and
m.value_r[12]=true and
m.value_r[13]=true and
m.value_r[14]=true and
m.value_r[15]=true and
m.value_r[16]=true
order by t."time" ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment