Skip to content
Snippets Groups Projects
Commit 57beb621 authored by Melissa Frei's avatar Melissa Frei
Browse files

file for clustering

parent 09c1b4d1
No related branches found
No related tags found
No related merge requests found
-- PRAGMA temp_store_directory = '/tmp';
SELECT
"Number of coincs before clustering: " || count(*)
FROM
coinc_event;
--
-- create a look-up table of info required for clustering
--
CREATE TEMPORARY TABLE _cluster_info_ AS
SELECT
coinc_event.coinc_event_id AS coinc_event_id,
(coinc_event.time_slide_id || ";" || coinc_event.instruments) AS category,
(coinc_inspiral.end_time - (SELECT MIN(end_time) FROM coinc_inspiral)) + 1e-9 * coinc_inspiral.end_time_ns AS end_time,
coinc_inspiral.snr AS snr
--CASE WHEN coinc_inspiral.combined_far != 0 THEN 1.0 / coinc_inspiral.combined_far ELSE coinc_inspiral.snr / (SELECT MIN(coinc_inspiral.combined_far) FROM coinc_inspiral WHERE coinc_inspiral.combined_far != 0) END AS ifar
FROM
coinc_event
JOIN coinc_inspiral ON (
coinc_inspiral.coinc_event_id == coinc_event.coinc_event_id
);
CREATE INDEX tmpindex1 ON _cluster_info_ (coinc_event_id);
CREATE INDEX tmpindex2 ON _cluster_info_ (category, end_time, snr);
--
-- delete coincs that are within 10 s of coincs with higher SNR in the same
-- category
--
DELETE FROM
coinc_event
WHERE
EXISTS (
SELECT
*
FROM
_cluster_info_ AS _cluster_info_a_
JOIN _cluster_info_ AS _cluster_info_b_ ON (
_cluster_info_b_.category == _cluster_info_a_.category
AND (_cluster_info_b_.end_time BETWEEN _cluster_info_a_.end_time - 10.0 AND _cluster_info_a_.end_time + 10.0)
AND _cluster_info_b_.snr > _cluster_info_a_.snr
)
WHERE
_cluster_info_a_.coinc_event_id == coinc_event.coinc_event_id
);
DROP INDEX tmpindex1;
DROP INDEX tmpindex2;
DROP TABLE _cluster_info_;
SELECT
"Number of coincs after clustering: " || count(*)
FROM
coinc_event;
--
-- delete unused coinc_inspiral rows
--
DELETE FROM
coinc_inspiral
WHERE
coinc_event_id NOT IN (
SELECT
coinc_event_id
FROM
coinc_event
);
--
-- delete unused coinc_event_map rows
--
DELETE FROM
coinc_event_map
WHERE
coinc_event_id NOT IN (
SELECT
coinc_event_id
FROM
coinc_event
);
--
-- delete unused sngl_inspiral rows
--
DELETE FROM
sngl_inspiral
WHERE
event_id NOT IN (
SELECT
event_id
FROM
coinc_event_map
WHERE
table_name == 'sngl_inspiral'
);
--
-- shrink the file
--
VACUUM;
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