Skip to content

Commit

Permalink
New service - Alaska AEP FIM (#1054)
Browse files Browse the repository at this point in the history
Implements AEP FIM - Alaska static service
Refs #917
  • Loading branch information
cfitzpat479 authored and nickchadwick-noaa committed Jan 23, 2025
1 parent 2c73d72 commit e58d4c1
Show file tree
Hide file tree
Showing 14 changed files with 2,869 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
crosswalk.hand_id,
max_forecast.feature_id,
CONCAT(LPAD(crosswalk.huc8::text, 8, '0'), '-', crosswalk.branch_id) as huc8_branch,
LEFT(LPAD(crosswalk.huc8::text, 8, '0'), 6) as huc,
crosswalk.hydro_id,
ROUND(CAST(max_forecast.rf_10_0_17c * 0.0283168 as numeric), 2) AS streamflow_cms
FROM derived.recurrence_flows_ak AS max_forecast
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON max_forecast.feature_id = crosswalk.feature_id
LEFT OUTER JOIN publish.rf_10_inundation_ak AS fim ON max_forecast.feature_id = fim.feature_id
WHERE
crosswalk.huc8 IS NOT NULL AND
crosswalk.lake_id = -999 AND
fim.feature_id IS NULL AND
crosswalk.branch_id != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
crosswalk.hand_id,
max_forecast.feature_id,
CONCAT(LPAD(crosswalk.huc8::text, 8, '0'), '-', crosswalk.branch_id) as huc8_branch,
LEFT(LPAD(crosswalk.huc8::text, 8, '0'), 6) as huc,
crosswalk.hydro_id,
ROUND(CAST(max_forecast.rf_25_0_17c * 0.0283168 as numeric), 2) AS streamflow_cms
FROM derived.recurrence_flows_ak AS max_forecast
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON max_forecast.feature_id = crosswalk.feature_id
LEFT OUTER JOIN publish.rf_25_inundation_ak AS fim ON max_forecast.feature_id = fim.feature_id
WHERE
crosswalk.huc8 IS NOT NULL AND
crosswalk.lake_id = -999 AND
fim.feature_id IS NULL AND
crosswalk.branch_id != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
crosswalk.hand_id,
max_forecast.feature_id,
CONCAT(LPAD(crosswalk.huc8::text, 8, '0'), '-', crosswalk.branch_id) as huc8_branch,
LEFT(LPAD(crosswalk.huc8::text, 8, '0'), 6) as huc,
crosswalk.hydro_id,
ROUND(CAST(max_forecast.rf_2_0_17c * 0.0283168 as numeric), 2) AS streamflow_cms
FROM derived.recurrence_flows_ak AS max_forecast
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON max_forecast.feature_id = crosswalk.feature_id
LEFT OUTER JOIN publish.rf_2_inundation_ak AS fim ON max_forecast.feature_id = fim.feature_id
WHERE
crosswalk.huc8 IS NOT NULL AND
crosswalk.lake_id = -999 AND
fim.feature_id IS NULL AND
crosswalk.branch_id != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
crosswalk.hand_id,
max_forecast.feature_id,
CONCAT(LPAD(crosswalk.huc8::text, 8, '0'), '-', crosswalk.branch_id) as huc8_branch,
LEFT(LPAD(crosswalk.huc8::text, 8, '0'), 6) as huc,
crosswalk.hydro_id,
ROUND(CAST(max_forecast.rf_50_0_17c * 0.0283168 as numeric), 2) AS streamflow_cms
FROM derived.recurrence_flows_ak AS max_forecast
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON max_forecast.feature_id = crosswalk.feature_id
LEFT OUTER JOIN publish.rf_50_inundation_ak AS fim ON max_forecast.feature_id = fim.feature_id
WHERE
crosswalk.huc8 IS NOT NULL AND
crosswalk.lake_id = -999 AND
fim.feature_id IS NULL AND
crosswalk.branch_id != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
crosswalk.hand_id,
max_forecast.feature_id,
CONCAT(LPAD(crosswalk.huc8::text, 8, '0'), '-', crosswalk.branch_id) as huc8_branch,
LEFT(LPAD(crosswalk.huc8::text, 8, '0'), 6) as huc,
crosswalk.hydro_id,
ROUND(CAST(max_forecast.rf_5_0_17c * 0.0283168 as numeric), 2) AS streamflow_cms
FROM derived.recurrence_flows_ak AS max_forecast
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON max_forecast.feature_id = crosswalk.feature_id
LEFT OUTER JOIN publish.rf_5_inundation_ak AS fim ON max_forecast.feature_id = fim.feature_id
WHERE
crosswalk.huc8 IS NOT NULL AND
crosswalk.lake_id = -999 AND
fim.feature_id IS NULL AND
crosswalk.branch_id != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
crosswalk.hand_id,
max_forecast.feature_id,
CONCAT(LPAD(crosswalk.huc8::text, 8, '0'), '-', crosswalk.branch_id) as huc8_branch,
LEFT(LPAD(crosswalk.huc8::text, 8, '0'), 6) as huc,
crosswalk.hydro_id,
ROUND(CAST(max_forecast.high_water_threshold * 0.0283168 as numeric), 2) AS streamflow_cms
FROM derived.recurrence_flows_ak AS max_forecast
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON max_forecast.feature_id = crosswalk.feature_id
LEFT OUTER JOIN publish.rf_high_water_inundation_ak AS fim ON max_forecast.feature_id = fim.feature_id
WHERE
crosswalk.huc8 IS NOT NULL AND
crosswalk.lake_id = -999 AND
fim.feature_id IS NULL AND
crosswalk.branch_id != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- No RAS2FIM cached features for Alaska yet, but keeping the script in case it is added later.

DROP TABLE IF EXISTS publish.rf_10_inundation_ak;
SELECT
crosswalk.hydro_id,
crosswalk.hydro_id::text AS hydro_id_str,
ST_Transform(gc.geom, 3857) AS geom,
crosswalk.feature_id,
crosswalk.feature_id::text AS feature_id_str,
ROUND(CAST(fs.rf_10_0_17c as numeric), 2) AS streamflow_cfs,
gc.stage_ft as fim_stage_ft,
mgc.max_rc_stage_ft,
mgc.max_rc_discharge_cfs,
mgc.model_version,
'{fim_version}' as fim_version,
to_char('1900-01-01 00:00:00'::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS reference_time,
crosswalk.huc8 as huc8,
crosswalk.branch_id as branch
INTO publish.rf_10_inundation_ak
FROM ras2fim.geocurves gc
JOIN derived.recurrence_flows_ak fs ON fs.feature_id = gc.feature_id
JOIN ras2fim.max_geocurves mgc ON gc.feature_id = mgc.feature_id
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON gc.feature_id = crosswalk.feature_id
WHERE gc.discharge_cfs >= fs.rf_10_0_17c AND gc.previous_discharge_cfs < fs.rf_10_0_17c;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- No RAS2FIM cached features for Alaska yet, but keeping the script in case it is added later.

DROP TABLE IF EXISTS publish.rf_25_inundation_ak;
SELECT
crosswalk.hydro_id,
crosswalk.hydro_id::text AS hydro_id_str,
ST_Transform(gc.geom, 3857) AS geom,
crosswalk.feature_id,
crosswalk.feature_id::text AS feature_id_str,
ROUND(CAST(fs.rf_25_0_17c as numeric), 2) AS streamflow_cfs,
gc.stage_ft as fim_stage_ft,
mgc.max_rc_stage_ft,
mgc.max_rc_discharge_cfs,
mgc.model_version,
'{fim_version}' as fim_version,
to_char('1900-01-01 00:00:00'::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS reference_time,
crosswalk.huc8 as huc8,
crosswalk.branch_id as branch
INTO publish.rf_25_inundation_ak
FROM ras2fim.geocurves gc
JOIN derived.recurrence_flows_ak fs ON fs.feature_id = gc.feature_id
JOIN ras2fim.max_geocurves mgc ON gc.feature_id = mgc.feature_id
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON gc.feature_id = crosswalk.feature_id
WHERE gc.discharge_cfs >= fs.rf_25_0_17c AND gc.previous_discharge_cfs < fs.rf_25_0_17c;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- No RAS2FIM cached features for Alaska yet, but keeping the script in case it is added later.

DROP TABLE IF EXISTS publish.rf_2_inundation_ak;
SELECT
crosswalk.hydro_id,
crosswalk.hydro_id::text AS hydro_id_str,
ST_Transform(gc.geom, 3857) AS geom,
crosswalk.feature_id,
crosswalk.feature_id::text AS feature_id_str,
ROUND(CAST(fs.rf_2_0_17c as numeric), 2) AS streamflow_cfs,
gc.stage_ft as fim_stage_ft,
mgc.max_rc_stage_ft,
mgc.max_rc_discharge_cfs,
mgc.model_version,
'{fim_version}' as fim_version,
to_char('1900-01-01 00:00:00'::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS reference_time,
crosswalk.huc8 as huc8,
crosswalk.branch_id as branch
INTO publish.rf_2_inundation_ak
FROM ras2fim.geocurves gc
JOIN derived.recurrence_flows_ak fs ON fs.feature_id = gc.feature_id
JOIN ras2fim.max_geocurves mgc ON gc.feature_id = mgc.feature_id
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON gc.feature_id = crosswalk.feature_id
WHERE gc.discharge_cfs >= fs.rf_2_0_17c AND gc.previous_discharge_cfs < fs.rf_2_0_17c;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- No RAS2FIM cached features for Alaska yet, but keeping the script in case it is added later.

DROP TABLE IF EXISTS publish.rf_50_inundation_ak;
SELECT
crosswalk.hydro_id,
crosswalk.hydro_id::text AS hydro_id_str,
ST_Transform(gc.geom, 3857) AS geom,
crosswalk.feature_id,
crosswalk.feature_id::text AS feature_id_str,
ROUND(CAST(fs.rf_50_0_17c as numeric), 2) AS streamflow_cfs,
gc.stage_ft as fim_stage_ft,
mgc.max_rc_stage_ft,
mgc.max_rc_discharge_cfs,
mgc.model_version,
'{fim_version}' as fim_version,
to_char('1900-01-01 00:00:00'::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS reference_time,
crosswalk.huc8 as huc8,
crosswalk.branch_id as branch
INTO publish.rf_50_inundation_ak
FROM ras2fim.geocurves gc
JOIN derived.recurrence_flows_ak fs ON fs.feature_id = gc.feature_id
JOIN ras2fim.max_geocurves mgc ON gc.feature_id = mgc.feature_id
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON gc.feature_id = crosswalk.feature_id
WHERE gc.discharge_cfs >= fs.rf_50_0_17c AND gc.previous_discharge_cfs < fs.rf_50_0_17c;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- No RAS2FIM cached features for Alaska yet, but keeping the script in case it is added later.

DROP TABLE IF EXISTS publish.rf_5_inundation_ak;
SELECT
crosswalk.hydro_id,
crosswalk.hydro_id::text AS hydro_id_str,
ST_Transform(gc.geom, 3857) AS geom,
crosswalk.feature_id,
crosswalk.feature_id::text AS feature_id_str,
ROUND(CAST(fs.rf_5_0_17c as numeric), 2) AS streamflow_cfs,
gc.stage_ft as fim_stage_ft,
mgc.max_rc_stage_ft,
mgc.max_rc_discharge_cfs,
mgc.model_version,
'{fim_version}' as fim_version,
to_char('1900-01-01 00:00:00'::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS reference_time,
crosswalk.huc8 as huc8,
crosswalk.branch_id as branch
INTO publish.rf_5_inundation_ak
FROM ras2fim.geocurves gc
JOIN derived.recurrence_flows_ak fs ON fs.feature_id = gc.feature_id
JOIN ras2fim.max_geocurves mgc ON gc.feature_id = mgc.feature_id
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON gc.feature_id = crosswalk.feature_id
WHERE gc.discharge_cfs >= fs.rf_5_0_17c AND gc.previous_discharge_cfs < fs.rf_5_0_17c;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- No RAS2FIM cached features for Alaska yet, but keeping the script in case it is added later.

DROP TABLE IF EXISTS publish.rf_high_water_inundation_ak;
SELECT
crosswalk.hydro_id,
crosswalk.hydro_id::text AS hydro_id_str,
ST_Transform(gc.geom, 3857) AS geom,
crosswalk.feature_id,
crosswalk.feature_id::text AS feature_id_str,
ROUND(CAST(fs.high_water_threshold as numeric), 2) AS streamflow_cfs,
gc.stage_ft as fim_stage_ft,
mgc.max_rc_stage_ft,
mgc.max_rc_discharge_cfs,
mgc.model_version,
'{fim_version}' as fim_version,
to_char('1900-01-01 00:00:00'::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS reference_time,
crosswalk.huc8 as huc8,
crosswalk.branch_id as branch
INTO publish.rf_high_water_inundation_ak
FROM ras2fim.geocurves gc
JOIN derived.recurrence_flows_ak fs ON fs.feature_id = gc.feature_id
JOIN ras2fim.max_geocurves mgc ON gc.feature_id = mgc.feature_id
JOIN derived.fim4_featureid_crosswalk AS crosswalk ON gc.feature_id = crosswalk.feature_id
WHERE gc.discharge_cfs >= fs.high_water_threshold AND gc.previous_discharge_cfs < fs.high_water_threshold;
Loading

0 comments on commit e58d4c1

Please sign in to comment.