Вы находитесь на странице: 1из 6

Assumptions

CREATE TEMP TABLE post_platforms AS SELECT DISTINCT mr.platform_id, mr.member_name


AS name, mr.force_name AS team_color, CASE WHEN TRUE THEN 'rso' END AS operation
FROM post_run_data rd JOIN run.master_roster mr ON mr.run_id = rd.run_id WHERE
scenario_name LIKE '%rso%' AND force_name IN ('Blue', 'Red') UNION SELECT DISTINCT
mr.platform_id,
mr.member_name AS name, mr.force_name AS team_color, CASE WHEN
TRUE THEN 'fso' END AS operation FROM post_run_data rd JOIN run.master_roster mr ON
mr.run_id = rd.run_id WHERE scenario_name LIKE '%fso%' AND force_name IN ('Blue',
'Red');

The query creates a table of valid platforms descriptions depending on if FSO or RSO is being
processed. The platforms are tagged with the team color.
SELECT name FROM post_platforms WHERE operation = '$operation';

The query selects the platforms that are appropriate for the current operation: RSO or FSO.
CREATE OR REPLACE VIEW post_run_data AS SELECT rd.id AS run_id, cs.name AS
scenario_name, rd.run AS run_number, CASE WHEN cs.name LIKE '_so%-baseline' THEN
'baseline' WHEN cs.name LIKE '_so%-optical' THEN 'optical' WHEN cs.name LIKE '_so%-radar'
THEN 'radar'
ELSE 'unknown' END AS
sensor_combination_scenario,
CASE WHEN TRUE
THEN 'cumulative'
ELSE NULL END
AS all_runs,
CASE WHEN cs.name LIKE '_so%-bad-%'
THEN 'bad'
WHEN cs.name LIKE '_so%-good-%'
THEN 'good'
ELSE 'unknown' END AS ground_type,
CASE WHEN cs.name LIKE
'_so%-hazy-%'
THEN 'hazy'
WHEN
cs.name LIKE '_so%-clear-%'
THEN 'clear'
ELSE 'unknown' END AS atmosphere_type,
CASE WHEN cs.name
LIKE '_so%-hazy-bad%'
THEN 'hazy-bad'
WHEN cs.name LIKE '_so%-hazy-good%'
THEN 'hazy-good'
WHEN cs.name LIKE '_so%-clear-good%'
THEN 'clear-good'
WHEN cs.name LIKE '_so%-clear-bad%'
THEN 'clear-bad'
ELSE 'unknown' END AS environmental_condition,
CASE WHEN
cs.name LIKE 'fso%'
THEN 'fso'
WHEN
cs.name LIKE 'rso%'
THEN 'rso'
ELSE
'unknown' END AS operation
FROM run.run_data rd
JOIN config.scenario cs ON cs.id = rd.scenario;

The query creates a view that parses a run id into its corresponding technology, ground, and atmosphere
types.
Experimental Context
SELECT DISTINCT pl.name FROM run.platform pl INNER JOIN config.master_capability mc ON
pl.name = mc.platform_instance_name WHERE pl.aerial = TRUE AND mc.scenario_type =
'$operation';

The query selects all the aerial platforms from the config tables depending on the operation type: FSO
or RSO.
Sensor Coverage
SELECT mc.platform_instance_name platform, mc.scenario_type operation, mc.sensor_type,
pd.has_zoom FROM config.master_capability mc JOIN (SELECT DISTINCT sensor_type, CASE
WHEN zoom > 1 THEN TRUE ELSE FALSE END AS has_zoom FROM
config.detection_probability) pd ON (pd.sensor_type = mc.sensor_type) WHERE allowed =
TRUE;

The query selects all appropriate platform and sensor type pairs from the config tables.
SELECT iss.run_id, iss.frame, iss.magnification, iss.platform_id, iss.type_name,
dd.was_detected, dd.target_id FROM run.imaging_sensor_state iss JOIN run.detection_draw dd
ON (iss.run_id = dd.run_id AND iss.frame = dd.frame AND iss.platform_id =
dd.sensor_platform_id AND iss.type_name = dd.sensor_type) WHERE iss.run_id = ?;

The query joins the detection draw table with the imaging sensor state table to obtain magnification
information on the detection draws.
Path Coverage
select platform, route_section_id, bihour_interval, trunc(least(count(*) * 1.0 / $threshold, 1), 2)
as color from (select rc.run_id, route_section_id, frame_entered, pl.name as platform, case
when true then (frame_entered / $interval) end as bihour_interval from
run.route_section_sensor_coverage rc\n join run.platform pl on (pl.run_id = rc.run_id and
pl.platformuid = rc.sensing_platform_id) where rc.run_id = ? and rc.sensing_platform_id in %
%) rimg group by platform, route_section_id, bihour_interval order by bihour_interval,
route_section_id;

with rimg as (select rc.run_id, route_section_id, frame_entered, pl.name as platform, case


when true then (frame_entered / $interval) end as bihour_interval from
run.route_section_sensor_coverage rc\n join run.platform pl on (pl.run_id = rc.run_id and
pl.platformuid = rc.sensing_platform_id) where rc.run_id = ? and rc.sensing_platform_id in %
%) select platform, route_section_id, bihour_interval, trunc(least(count(*) * 1.0 / $threshold,
1), 2) as color from rimg group by platform, route_section_id, bihour_interval order by
bihour_interval, route_section_id;

The top query is an H2 query; the bottom query is PostgreSQL. The query generates the PSSR image
numerical data.
SELECT route_zone, trunc(sum(passes) / post_sections_in_zone(route_zone),3) AS avg_passes,
trunc(sum(minutes) / post_sections_in_zone(route_zone),3) AS avg_minutes FROM (SELECT
route_section_id, sensing_platform_id, count(*)
AS passes, trunc(sum(length) /
30.0,3) AS minutes, pz.route_zone FROM (SELECT frame_entered, frame_exited,
route_section_id, sensing_platform_id, CASE WHEN TRUE THEN (frame_exited frame_entered) ELSE 0 END AS length FROM run.route_section_sensor_coverage WHERE
run_id = ? AND sensing_platform_id IN %%) rc JOIN post_zones pz ON pz.section_number =

rc.route_section_id AND pz.run_id = ? GROUP BY route_section_id, sensing_platform_id,


pz.route_zone) rd WHERE route_zone != 'BZ' GROUP BY route_zone UNION SELECT CASE
WHEN TRUE THEN 'AllE' END
AS rz, trunc(sum(passes) /
post_sections_in_zone('AllE'),3) AS avg_passes, trunc(sum(minutes) /
post_sections_in_zone('AllE'),3) AS avg_minutes FROM (SELECT route_section_id,
sensing_platform_id, count(*)
AS passes, trunc(sum(length) / 30.0,3) AS
minutes, pz.route_zone FROM (SELECT frame_entered, frame_exited, route_section_id,
sensing_platform_id, CASE WHEN TRUE THEN (frame_exited - frame_entered) ELSE 0 END AS
length FROM run.route_section_sensor_coverage WHERE run_id = ? AND sensing_platform_id
IN %%) rc JOIN post_zones pz ON pz.section_number = rc.route_section_id AND pz.run_id = ?
GROUP BY route_section_id, sensing_platform_id, pz.route_zone) rd WHERE route_zone IN
('EZ1', 'EZ2', 'EZ3', 'EZ4') UNION SELECT CASE WHEN TRUE THEN 'AllS' END AS rz,
trunc(sum(passes) / post_sections_in_zone('AllS'),3) AS avg_passes, trunc(sum(minutes) /
post_sections_in_zone('AllS'),3) AS avg_minutes FROM (SELECT route_section_id,
sensing_platform_id, count(*)
AS passes, trunc(sum(length) / 30.0,3) AS
minutes, pz.route_zone FROM (SELECT frame_entered, frame_exited, route_section_id,
sensing_platform_id, CASE WHEN TRUE THEN (frame_exited - frame_entered) ELSE 0 END AS
length FROM run.route_section_sensor_coverage WHERE run_id = ? AND sensing_platform_id
IN %%) rc JOIN post_zones pz ON pz.section_number = rc.route_section_id AND pz.run_id = ?
GROUP BY route_section_id, sensing_platform_id, pz.route_zone) rd WHERE route_zone IN
('SZ1', 'SZ2', 'SZ3', 'SZ4', 'SZ5') UNION SELECT CASE WHEN TRUE THEN 'All' END
AS rz, trunc(sum(passes) / post_sections_in_zone('All'),3) AS avg_passes,
trunc(sum(minutes) / post_sections_in_zone('All'),3) AS avg_minutes FROM (SELECT
route_section_id, sensing_platform_id, count(*)
AS passes, trunc(sum(length) /
30.0,3) AS minutes, pz.route_zone FROM (SELECT frame_entered, frame_exited,
route_section_id, sensing_platform_id, CASE WHEN TRUE THEN (frame_exited frame_entered) ELSE 0 END AS length FROM run.route_section_sensor_coverage WHERE
run_id = ? AND sensing_platform_id IN %%) rc JOIN post_zones pz ON pz.section_number =
rc.route_section_id AND pz.run_id = ? GROUP BY route_section_id, sensing_platform_id,
pz.route_zone) rd;

WITH rc AS (SELECT frame_entered, frame_exited, route_section_id, sensing_platform_id,


CASE WHEN TRUE THEN (frame_exited - frame_entered) ELSE 0 END AS length FROM
run.route_section_sensor_coverage WHERE run_id = ? AND sensing_platform_id IN %%), rd
AS (SELECT route_section_id, sensing_platform_id, count(*)
AS passes,
trunc((sum(length)) / 30.0, 3) AS minutes, pz.route_zone FROM rc JOIN post_zones pz ON
pz.section_number = rc.route_section_id AND pz.run_id = ? GROUP BY route_section_id,
sensing_platform_id, pz.route_zone) SELECT route_zone, trunc(sum(passes) /
pg_temp.post_sections_in_zone(route_zone), 2) AS avg_passes, trunc(sum(minutes) /
pg_temp.post_sections_in_zone(route_zone), 2) AS avg_minutes FROM rd WHERE route_zone !
= 'BZ' GROUP BY route_zone UNION SELECT CASE WHEN TRUE THEN 'AllE' END AS rz,
trunc(sum(passes) / pg_temp.post_sections_in_zone('AllE'), 2) AS avg_passes,
trunc(sum(minutes) / pg_temp.post_sections_in_zone('AllE'), 2) AS avg_minutes FROM rd
WHERE route_zone IN ('EZ1', 'EZ2', 'EZ3', 'EZ4') UNION SELECT CASE WHEN TRUE THEN 'AllS'
END AS rz, trunc(sum(passes) / pg_temp.post_sections_in_zone('AllS'), 2) AS avg_passes,
trunc(sum(minutes) / pg_temp.post_sections_in_zone('AllS'), 2) AS avg_minutes FROM rd
WHERE route_zone IN ('SZ1', 'SZ2', 'SZ3', 'SZ4', 'SZ5') UNION SELECT CASE WHEN TRUE
THEN 'All' END
AS rz, trunc(sum(passes) /
pg_temp.post_sections_in_zone('All'), 2) AS avg_passes, trunc(sum(minutes) /
pg_temp.post_sections_in_zone('All'), 2) AS avg_minutes FROM rd;

The top query is H2 and the bottom query is PostgreSQL. The query is the run level summary Path

Coverage metric average number of passes and average number of minutes.


SELECT route_zone, pl.name, sum(passes) AS total_passes, sum(minutes) AS total_minutes
FROM (SELECT route_section_id, sensing_platform_id, count(*)
AS passes,
trunc((sum(length)) / 30.0, 3) AS minutes, pz.route_zone FROM (SELECT frame_entered,
frame_exited, route_section_id, sensing_platform_id, CASE WHEN TRUE THEN (frame_exited frame_entered) ELSE 0 END AS length FROM run.route_section_sensor_coverage WHERE
run_id = ? AND sensing_platform_id IN %%) rc JOIN post_zones pz ON rc.route_section_id =
pz.section_number AND pz.run_id = ? GROUP BY route_section_id, sensing_platform_id,
pz.route_zone) rd JOIN run.platform pl ON pl.platformuid = rd.sensing_platform_id WHERE
pl.run_id = ? AND route_zone != 'BZ' GROUP BY route_zone, pl.name;
WITH rc AS (SELECT frame_entered, frame_exited, route_section_id, sensing_platform_id,
CASE WHEN TRUE THEN (frame_exited - frame_entered) ELSE 0 END AS length FROM
run.route_section_sensor_coverage WHERE run_id = ? AND sensing_platform_id IN %%), rd
AS (SELECT route_section_id, sensing_platform_id, count(*)
AS passes,
trunc((sum(length)) / 30.0, 3) AS minutes, pz.route_zone FROM rc JOIN post_zones pz ON
rc.route_section_id = pz.section_number AND pz.run_id = ? GROUP BY route_section_id,
sensing_platform_id, pz.route_zone) SELECT route_zone, pl.name, sum(passes) AS
total_passes, sum(minutes) AS total_minutes FROM rd JOIN run.platform pl ON pl.platformuid
= rd.sensing_platform_id WHERE pl.run_id = ? AND route_zone != 'BZ' GROUP BY route_zone,
pl.name;

The top query is H2 and the bottom query is PostgreSQL. The query is the scenario level diagnostics
Path Coverage number of passes.
Coverage Confidence
CREATE AGGREGATE product(numeric) (sfunc = numeric_mul, stype = numeric);

The PostgreSQL-only query creates a custom aggregate using the numeric mul function.
CREATE OR REPLACE VIEW post_run_data AS SELECT rd.id AS run_id, cs.name AS
scenario_name, rd.run AS run_number, CASE WHEN cs.name LIKE '_so%-baseline' THEN
'baseline' WHEN cs.name LIKE '_so%-optical' THEN 'optical' WHEN cs.name LIKE '_so%-radar'
THEN 'radar' ELSE 'unknown' END
AS sensor_combination_scenario, CASE WHEN TRUE
THEN 'cumulative' ELSE NULL END
AS all_runs, CASE WHEN cs.name LIKE '_so%-bad-%'
THEN 'bad' WHEN cs.name LIKE '_so%-good-%' THEN 'good' ELSE 'unknown' END
AS
ground_type, CASE WHEN cs.name LIKE '_so%-hazy-%' THEN 'hazy' WHEN cs.name LIKE '_so
%-clear-%' THEN 'clear' ELSE 'unknown' END
AS atmosphere_type, CASE WHEN cs.name
LIKE '_so%-hazy-bad%' THEN 'hazy-bad' WHEN cs.name LIKE '_so%-hazy-good%' THEN 'hazygood' WHEN cs.name LIKE '_so%-clear-good%' THEN 'clear-good' WHEN cs.name LIKE '_so%clear-bad%' THEN 'clear-bad' ELSE 'unknown' END
AS environmental_condition, CASE WHEN
cs.name LIKE 'fso%' THEN 'fso' WHEN cs.name LIKE 'rso%' THEN 'rso' ELSE 'unknown' END
AS operation FROM run.run_data rd JOIN config.scenario cs ON cs.id = rd.scenario;

CREATE OR REPLACE TEMP VIEW post_run_data AS SELECT rd.id AS run_id, cs.name AS


scenario_name, rd.run AS run_number, CASE WHEN cs.name :: TEXT ~~ '_so%-baseline' ::
TEXT THEN 'baseline' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-optical' :: TEXT THEN

'optical' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-radar' :: TEXT THEN 'radar' :: TEXT ELSE
'unknown' :: TEXT END AS sensor_combination_scenario, CASE WHEN TRUE THEN 'cumulative'
:: TEXT ELSE NULL :: TEXT END AS all_runs, CASE WHEN cs.name :: TEXT ~~ '_so%-bad-%' ::
TEXT THEN 'bad' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-good-%' :: TEXT THEN 'good' ::
TEXT ELSE 'unknown' :: TEXT END
AS ground_type, CASE WHEN cs.name :: TEXT ~~ '_so%hazy-%' :: TEXT THEN 'hazy' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-clear-%' :: TEXT THEN
'clear' :: TEXT ELSE 'unknown' :: TEXT END AS atmosphere_type, CASE WHEN cs.name :: TEXT
~~ '_so%-hazy-bad%' :: TEXT THEN 'hazy-bad' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-hazygood%' :: TEXT THEN 'hazy-good' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-clear-good%' ::
TEXT THEN 'clear-good' :: TEXT WHEN cs.name :: TEXT ~~ '_so%-clear-bad%' :: TEXT THEN
'clear-bad' :: TEXT ELSE 'unknown' :: TEXT END
AS environmental_condition, CASE WHEN
cs.name :: TEXT ~~ 'fso%' :: TEXT THEN 'fso' :: TEXT WHEN cs.name :: TEXT ~~ 'rso%' :: TEXT
THEN 'rso' :: TEXT ELSE 'unknown' :: TEXT END
AS operation FROM run.run_data rd JOIN
config.scenario cs ON cs.id = rd.scenario;

The top query is PostgresQL and the bottom query is H2. The query creates the post_run_date view that
parses a run id into the respective technology, ground, and atmosphere types.
create or replace view post_zones as select distinct run_id, section_number, case when
$ez1_lower <= section_number and section_number <= $ez1_upper then 'EZ1' when
$ez2_lower <= section_number and section_number <= $ez2_upper then 'EZ2' when
$ez3_lower <= section_number and section_number <= $ez3_upper then 'EZ3' when
$ez4_lower <= section_number and section_number <= $ez4_upper then 'EZ4' when
$sz1_lower <= section_number and section_number <= $sz1_upper then 'SZ1' when
$sz2_lower <= section_number and section_number <= $sz2_upper then 'SZ2' when
$sz3_lower <= section_number and section_number <= $sz3_upper then 'SZ3'when
$sz4_lower <= section_number and section_number <= $sz4_upper then 'SZ4'when
$sz5_lower <= section_number and section_number <= $sz5_upper then 'SZ5' when
section_number < $total_sections then 'BZ' end as route_zone from run.route_section_data;

The query creates the post_zones view that defines the section id numbers which compose a specific
zone. The zone information is calculated in RPT and is uploaded to the database for use in queries via
this view.
(SELECT mq.route_section_id, mq.sensor_type, mq.frame_entered, mq.magnification,
pd.target_state, pd.target_type,CASE WHEN TRUE THEN frame_entered / $frames_in_interval
END AS interval_num, trunc((1 - pd.detect_probability), 4) complement_pd FROM (SELECT
rc.run_id, sensor_type, frame_entered, route_section_id, rd.sensor_combination_scenario,
ground_type, atmosphere_type, iss.magnification, CASE WHEN (frame_entered % 43200) <
21600 THEN 'Day' ELSE 'Night' END AS time FROM run.route_section_sensor_coverage rc JOIN
post_run_data rd ON rc.run_id = rd.run_id JOIN run.imaging_sensor_state iss ON iss.run_id =
rc.run_id AND iss.platform_id = rc.sensing_platform_id AND iss.frame = rc.frame_entered AND
iss.type_name = rc.sensor_type WHERE rc.run_id = ? AND rc.sensing_platform_id in
($platform_list)) mq JOIN (SELECT lower(atmosphere) atmosphere, detect_probability,
lower(ground_factor) ground_factor, sensor_type, target_state, target_type, time,
lower(variant) technology, zoom FROM config.detection_probability WHERE target_type =
$object AND target_state = $state) pd ON pd.technology = mq.sensor_combination_scenario
AND pd.ground_factor = mq.ground_type AND pd.atmosphere = mq.atmosphere_type AND
pd.zoom = mq.magnification AND pd.sensor_type = mq.sensor_type AND pd.time = mq.time)

(WITH pd_query AS (SELECT lower(atmosphere) atmosphere, detect_probability,


lower(ground_factor) ground_factor, sensor_type, target_state, target_type, time,
lower(technology) technology, zoom FROM post_pd_table WHERE target_type = $object
AND target_state = $state), main_query AS (SELECT rc.run_id, sensor_type, frame_entered,
route_section_id, rd.sensor_combination_scenario, ground_type, atmosphere_type,
iss.magnification, CASE WHEN (frame_entered % 43200) < 21600 THEN 'Day' ELSE 'Night'
END AS time FROM run.route_section_sensor_coverage rc JOIN post_run_data rd ON rc.run_id
= rd.run_id JOIN run.imaging_sensor_state iss ON iss.run_id = rc.run_id AND iss.platform_id =
rc.sensing_platform_id AND iss.frame = rc.frame_entered AND iss.type_name =
rc.sensor_type WHERE rc.run_id = ? AND rc.sensing_platform_id IN ($platform_list)),
psr_query AS (SELECT mq.route_section_id, CASE WHEN TRUE THEN frame_entered /
$frames_in_interval END AS interval_num, trunc((1 - pd.detect_probability) :: NUMERIC, 4)
complement FROM main_query mq JOIN pd_query pd ON pd.technology =
mq.sensor_combination_scenario AND pd.ground_factor = mq.ground_type AND
pd.atmosphere = mq.atmosphere_type AND pd.zoom = mq.magnification AND
pd.sensor_type = mq.sensor_type AND pd.time = mq.time) SELECT pq.route_section_id,
pq.interval_num, 1 - trunc(product(complement), 3) AS psr, CASE WHEN TRUE THEN $object
END AS object_type, CASE WHEN TRUE THEN $category END
AS category, CASE WHEN
TRUE THEN $state END
AS state, pz.route_zone FROM psr_query pq JOIN post_zones
pz ON pz.section_number = pq.route_section_id AND pz.run_id = ? GROUP BY
pq.route_section_id, pq.interval_num, pz.route_zone)

The top query is H2 and the bottom query is PostgreSQL. The query is a template for creating the PSR
table. The PSR table is the intermediate structure for implementing Coverage Confidence. The table
provides all the necessary information to implement both the run level summary and the images for the
confidence and previous confidence metrics.

Вам также может понравиться