Skip to content

Commit

Permalink
Merge pull request #764 from NOAA-OWP/gfs_hfm_alaska
Browse files Browse the repository at this point in the history
Added sql, mapx, and yml files to generate the new Alaska GFS 10-Day High Flow Mag service - issue #734 .
  • Loading branch information
nickchadwick-noaa authored Jun 24, 2024
2 parents 5550ea6 + 2934ed8 commit c354ed7
Show file tree
Hide file tree
Showing 4 changed files with 3,043 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
DROP TABLE IF EXISTS publish.mrf_gfs_10day_max_high_flow_magnitude_ak;
WITH high_flow_mag AS (
SELECT maxflows_10day.feature_id,
maxflows_3day.discharge_cfs AS maxflow_3day_cfs,
maxflows_5day.discharge_cfs AS maxflow_5day_cfs,
maxflows_10day.discharge_cfs AS maxflow_10day_cfs,
maxflows_10day.nwm_vers,
maxflows_10day.reference_time,
CASE
WHEN maxflows_3day.discharge_cfs >= thresholds.rf_50_0_17c THEN '2'::text
WHEN maxflows_3day.discharge_cfs >= thresholds.rf_25_0_17c THEN '4'::text
WHEN maxflows_3day.discharge_cfs >= thresholds.rf_10_0_17c THEN '10'::text
WHEN maxflows_3day.discharge_cfs >= thresholds.rf_5_0_17c THEN '20'::text
WHEN maxflows_3day.discharge_cfs >= thresholds.rf_2_0_17c THEN '50'::text
WHEN maxflows_3day.discharge_cfs >= thresholds.high_water_threshold THEN '>50'::text
ELSE NULL::text
END AS recur_cat_3day,
CASE
WHEN maxflows_5day.discharge_cfs >= thresholds.rf_50_0_17c THEN '2'::text
WHEN maxflows_5day.discharge_cfs >= thresholds.rf_25_0_17c THEN '4'::text
WHEN maxflows_5day.discharge_cfs >= thresholds.rf_10_0_17c THEN '10'::text
WHEN maxflows_5day.discharge_cfs >= thresholds.rf_5_0_17c THEN '20'::text
WHEN maxflows_5day.discharge_cfs >= thresholds.rf_2_0_17c THEN '50'::text
WHEN maxflows_5day.discharge_cfs >= thresholds.high_water_threshold THEN '>50'::text
ELSE NULL::text
END AS recur_cat_5day,
CASE
WHEN maxflows_10day.discharge_cfs >= thresholds.rf_50_0_17c THEN '2'::text
WHEN maxflows_10day.discharge_cfs >= thresholds.rf_25_0_17c THEN '4'::text
WHEN maxflows_10day.discharge_cfs >= thresholds.rf_10_0_17c THEN '10'::text
WHEN maxflows_10day.discharge_cfs >= thresholds.rf_5_0_17c THEN '20'::text
WHEN maxflows_10day.discharge_cfs >= thresholds.rf_2_0_17c THEN '50'::text
WHEN maxflows_10day.discharge_cfs >= thresholds.high_water_threshold THEN '>50'::text
ELSE NULL::text
END AS recur_cat_10day,
thresholds.high_water_threshold AS high_water_threshold,
thresholds.rf_2_0_17c AS flow_2yr,
thresholds.rf_5_0_17c AS flow_5yr,
thresholds.rf_10_0_17c AS flow_10yr,
thresholds.rf_25_0_17c AS flow_25yr,
thresholds.rf_50_0_17c AS flow_50yr
FROM cache.max_flows_mrf_gfs_10day_ak AS maxflows_10day
JOIN cache.max_flows_mrf_gfs_5day_ak AS maxflows_5day ON maxflows_10day.feature_id = maxflows_5day.feature_id
JOIN cache.max_flows_mrf_gfs_3day_ak AS maxflows_3day ON maxflows_10day.feature_id = maxflows_3day.feature_id
JOIN derived.recurrence_flows_ak thresholds ON maxflows_10day.feature_id = thresholds.feature_id
WHERE (thresholds.high_water_threshold > 0::double precision) AND maxflows_10day.discharge_cfs >= thresholds.high_water_threshold
)

SELECT channels.feature_id,
channels.feature_id::TEXT AS feature_id_str,
channels.strm_order,
channels.name,
channels.huc6,
'AK' as state,
high_flow_mag.nwm_vers,
high_flow_mag.reference_time,
high_flow_mag.maxflow_3day_cfs,
high_flow_mag.maxflow_5day_cfs,
high_flow_mag.maxflow_10day_cfs,
high_flow_mag.recur_cat_3day,
high_flow_mag.recur_cat_5day,
high_flow_mag.recur_cat_10day,
high_flow_mag.high_water_threshold,
high_flow_mag.flow_2yr,
high_flow_mag.flow_5yr,
high_flow_mag.flow_10yr,
high_flow_mag.flow_25yr,
high_flow_mag.flow_50yr,
to_char(now()::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS update_time,
channels.geom
INTO publish.mrf_gfs_10day_max_high_flow_magnitude_ak
FROM derived.channels_alaska channels
JOIN high_flow_mag ON channels.feature_id = high_flow_mag.feature_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
product: mrf_gfs_10day_max_high_flow_magnitude_ak
configuration: medium_range_alaska_mem1
product_type: "vector"
run: true

ingest_files:
- file_format: common/data/model/com/nwm/{{variable:NWM_DATAFLOW_VERSION}}/nwm.{{datetime:%Y%m%d}}/medium_range_alaska_mem1/nwm.t{{datetime:%H}}z.medium_range.channel_rt_1.f{{range:3,243,3,%03d}}.alaska.nc
file_step: None
file_window: None
target_table: ingest.nwm_channel_rt_mrf_gfs_mem1
target_keys: (feature_id, streamflow)

db_max_flows:
- name: mrf_gfs_3day_max_flows_ak
target_table: cache.max_flows_mrf_gfs_3day_ak
target_keys: (feature_id, streamflow)
method: database
max_flows_sql_file: mrf_gfs_3day_max_flows_ak
- name: mrf_gfs_5day_max_flows_ak
target_table: cache.max_flows_mrf_gfs_5day_ak
target_keys: (feature_id, streamflow)
method: database
max_flows_sql_file: mrf_gfs_5day_max_flows_ak
- name: mrf_gfs_10day_max_flows_ak
target_table: cache.max_flows_mrf_gfs_10day_ak
target_keys: (feature_id, streamflow)
method: database
max_flows_sql_file: mrf_gfs_10day_max_flows_ak

postprocess_sql:
- sql_file: mrf_gfs_10day_max_high_flow_magnitude_ak
target_table: publish.mrf_gfs_10day_max_high_flow_magnitude_ak

services:
- mrf_gfs_10day_max_high_flow_magnitude_alaska_noaa
Loading

0 comments on commit c354ed7

Please sign in to comment.