Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New service - Alaska MRF GFS 10-day High Water Arrival Time #832

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
DROP TABLE IF EXISTS publish.mrf_gfs_10day_high_water_arrival_time_ak;
WITH arrival_time AS (
SELECT forecasts.feature_id,
min(forecasts.forecast_hour) AS high_water_arrival_hour,
to_char(forecasts.reference_time::timestamp without time zone + INTERVAL '1 hour' * min(forecasts.forecast_hour), 'YYYY-MM-DD HH24:MI:SS UTC') AS high_water_arrival_time,
forecasts.nwm_vers,
forecasts.reference_time,
CASE
WHEN max(forecasts.forecast_hour) >= 240 THEN '> 10 days'::text
ELSE (max(forecasts.forecast_hour)+3)::text
END AS below_bank_return_hour,
to_char(forecasts.reference_time::timestamp without time zone + INTERVAL '1 hour' * (max(forecasts.forecast_hour)+3), 'YYYY-MM-DD HH24:MI:SS UTC') AS below_bank_return_time,
CASE
WHEN max(forecasts.forecast_hour) >= 240 THEN 'Outside MRF Forecast Window'::text
ELSE ((max(forecasts.forecast_hour)+3) - min(forecasts.forecast_hour))::text
END AS duration,
thresholds.high_water_threshold AS high_water_threshold,
round((max(forecasts.streamflow) * 35.315::double precision)::numeric, 2) AS max_flow,
to_char(now()::timestamp without time zone, 'YYYY-MM-DD HH24:MI:SS UTC') AS update_time
FROM ingest.nwm_channel_rt_mrf_gfs_ak_mem1 AS forecasts
JOIN derived.recurrence_flows_ak thresholds ON forecasts.feature_id = thresholds.feature_id
WHERE thresholds.high_water_threshold > 0::double precision AND (forecasts.streamflow * 35.315::double precision) >= thresholds.high_water_threshold
GROUP BY forecasts.feature_id, forecasts.reference_time, forecasts.nwm_vers, thresholds.high_water_threshold
)

SELECT channels.feature_id,
channels.feature_id::TEXT AS feature_id_str,
channels.name,
channels.strm_order,
channels.huc6,
'AK' as state,
arrival_time.nwm_vers,
arrival_time.reference_time,
arrival_time.high_water_arrival_hour,
arrival_time.high_water_arrival_time,
arrival_time.below_bank_return_hour,
arrival_time.below_bank_return_time,
arrival_time.duration,
arrival_time.high_water_threshold,
arrival_time.max_flow,
arrival_time.update_time,
channels.geom
INTO publish.mrf_gfs_10day_high_water_arrival_time_ak
FROM derived.channels_alaska channels
JOIN arrival_time ON channels.feature_id = arrival_time.feature_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
product: mrf_gfs_10day_high_water_arrival_time_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_ak_mem1
target_keys: (feature_id, streamflow)

postprocess_sql:
- sql_file: mrf_gfs_10day_high_water_arrival_time_ak
target_table: publish.mrf_gfs_10day_high_water_arrival_time_ak

services:
- mrf_gfs_10day_high_water_arrival_time_ak_noaa
Loading
Loading