Skip to content

Commit 5478554

Browse files
authored
v4.4.8.4 Tool to evaluate crosswalk accuracy (#1061)
1 parent 4b2762d commit 5478554

File tree

8 files changed

+342
-3
lines changed

8 files changed

+342
-3
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ ARG depDir=/dependencies
5454
ENV inputsDir=$dataDir/inputs
5555
ENV outputsDir=/outputs
5656
ENV srcDir=$projectDir/src
57+
ENV toolsDir=$projectDir/tools
5758
ENV workDir=/fim_temp
5859
ENV taudemDir=$depDir/taudem/bin
5960
ENV taudemDir2=$depDir/taudem_accelerated_flowDirections/taudem/build/bin

docs/CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
All notable changes to this project will be documented in this file.
22
We follow the [Semantic Versioning 2.0.0](http://semver.org/) format.
33

4+
## v4.4.8.4 - 2024-01-12 - [PR#1061](https://github.com/NOAA-OWP/inundation-mapping/pull/1061)
5+
6+
Adds a post-processing tool to compare crosswalked (conflated) `feature_id`s between NWM stream network to DEM-derived reaches. The tool is run if the `-x` flag is added to `fim_pipeline.sh`. Results are computed for branch 0 and saved in a summary file in the HUC output folder.
7+
8+
### Additions
9+
10+
- `tools/evaluate_crosswalk.py`: evaluates crosswalk accuracy using two methods:
11+
- intersections: the number of intersections between streamlines
12+
- network (or tree): compares the feature_ids of the immediate upstream segments
13+
14+
### Changes
15+
16+
- `Dockerfile`: added `toolsDir` environment variable
17+
- `fim_pipeline.sh`: added `-x` flag to run crosswalk evaluation tool
18+
- `fim_post_processing.sh`: changed hardcoded `/foss_fim/tools` to `toolsDir` environment variable
19+
- `fim_pre_processing.sh`: added `evaluateCrosswalk` environment variable
20+
- `src/`
21+
- `add_crosswalk.py`: fix bug
22+
- `delineate_hydros_and_produce_HAND.sh`: added a call to `verify_crosswalk.py` if evaluateCrosswalk is True.
23+
24+
<br/><br/>
25+
426
## v4.4.8.3 - 2024-01-05 - [PR#1059](https://github.com/NOAA-OWP/inundation-mapping/pull/1059)
527

628
Fixes erroneous branch inundation in levee-protected areas.

fim_pipeline.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ usage()
4848
will be skipped.
4949
-isaws : If this param is included, AWS objects will be used where possible
5050
- Note: This feature is not yet implemented.
51+
-x : If this param is included, the crosswalk will be evaluated.
5152
5253
5354
Running 'fim_pipeline.sh' is a quicker process than running all three scripts independently; however,

fim_post_processing.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ echo
210210
echo -e $startDiv"Combining crosswalk tables"
211211
# aggregate outputs
212212
Tstart
213-
python3 /foss_fim/tools/combine_crosswalk_tables.py \
213+
python3 $toolsDir/combine_crosswalk_tables.py \
214214
-d $outputDestDir \
215215
-o $outputDestDir/crosswalk_table.csv
216216
Tcount

fim_pre_processing.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ in
101101
-isaws)
102102
isAWS=1
103103
;;
104+
-x)
105+
evaluateCrosswalk=1
106+
;;
104107
*) ;;
105108
esac
106109
shift
@@ -129,6 +132,7 @@ if [ "$jobBranchLimit" = "" ]; then jobBranchLimit=1; fi
129132
if [ -z "$overwrite" ]; then overwrite=0; fi
130133
if [ -z "$skipcal" ]; then skipcal=0; fi
131134
if [ -z "$isAWS" ]; then isAWS=0; fi
135+
if [ -z "$evaluateCrosswalk" ]; then evaluateCrosswalk=0; fi
132136

133137
# validate and set defaults for the deny lists
134138
if [ "$deny_unit_list" = "" ]
@@ -234,6 +238,7 @@ echo "export deny_branch_zero_list=$deny_branch_zero_list" >> $args_file
234238
echo "export has_deny_branch_zero_override=$has_deny_branch_zero_override" >> $args_file
235239
echo "export isAWS=$isAWS" >> $args_file
236240
echo "export skipcal=$skipcal" >> $args_file
241+
echo "export evaluateCrosswalk=$evaluateCrosswalk" >> $args_file
237242

238243
echo "--- Pre-processing is complete"
239244

src/add_crosswalk.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ def add_crosswalk(
258258
else:
259259
update_id = output_flows.loc[output_flows.HydroID == short_id]['HydroID'].item()
260260

261-
str_order = output_flows.loc[output_flows.HydroID == short_id]['order_'].item()
261+
output_order = output_flows.loc[output_flows.HydroID == short_id]['order_']
262+
if len(output_order) == 1:
263+
str_order = output_order.item()
264+
else:
265+
str_order = output_order.max()
262266
sml_segs = pd.concat(
263267
[
264268
sml_segs,

src/delineate_hydros_and_produce_HAND.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ T_total_start
1717

1818
## MASK LEVEE-PROTECTED AREAS FROM DEM ##
1919
if [ "$mask_leveed_area_toggle" = "True" ] && [ -f $tempHucDataDir/LeveeProtectedAreas_subset.gpkg ]; then
20-
echo -e $startDiv"Mask levee-protected areas from DEM (*Overwrite dem_meters.tif output) $hucNumber $branch_zero_id"
20+
echo -e $startDiv"Mask levee-protected areas from DEM (*Overwrite dem_meters.tif output) $hucNumber $current_branch_id"
2121
date -u
2222
Tstart
2323
python3 $srcDir/mask_dem.py \
@@ -303,3 +303,18 @@ python3 $srcDir/add_crosswalk.py \
303303
-e $min_catchment_area \
304304
-g $min_stream_length
305305
Tcount
306+
307+
## EVALUATE CROSSWALK ##
308+
if [ "$current_branch_id" = "$branch_zero_id" ] && [ "$evaluateCrosswalk" = "1" ] ; then
309+
echo -e $startDiv"Evaluate crosswalk $hucNumber $current_branch_id"
310+
date -u
311+
Tstart
312+
python3 $toolsDir/evaluate_crosswalk.py \
313+
-a $tempCurrentBranchDataDir/demDerived_reaches_split_filtered_addedAttributes_crosswalked_$current_branch_id.gpkg \
314+
-b $b_arg \
315+
-c $tempHucDataDir/crosswalk_evaluation_$current_branch_id.csv \
316+
-d $tempHucDataDir/nwm_headwater_points_subset.gpkg \
317+
-u $hucNumber \
318+
-z $current_branch_id
319+
Tcount
320+
fi

0 commit comments

Comments
 (0)