Add SECOFS processing to STOFS bathymetry editing - #232
Conversation
There was a problem hiding this comment.
The changes in this script largely overlap with the functionality of the "shape_tweak" def.
Please revert all changes in this file.
Later, I can help extend "shape_tweak", and you can just prepare a gpkg file including all regions in the following format and remove the relavant shapefiles after you make sure they are all included in the gpkg.
v7p4_regional_tweaks.gpkg
Use one layer named regional_tweaks, stored in EPSG:4326, with these fields:
- region: text
- operation: set or add
- value_m: numeric
- min_input_depth_m: nullable numeric
- max_input_depth_m: nullable numeric
Use the following operation:
- set: dp = value_m
- add: dp += value_m; negative values decrease depth
- Minimum and maximum input-depth bounds are exclusive; NULL means no bound.
for example, the attribute table should look like:
region operation value_m min_input_depth_m max_input_depth_m
━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━ ━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━
Savannah_upstream set 0.6 NULL NULL
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Cooper_upstream add 5.0 NULL NULL
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Wando_upstream add 2.0 NULL NULL
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Wachapreague add 2.0 NULL NULL
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Savannah_marsh_block add -2.0 -2.0 0.0
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Savannah_connectivity set 0.2 NULL 0.0
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Turkey set 0.6 NULL 0.0
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Baltimore set 2.0 NULL 2.0
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Fall_River set 1.5 NULL 1.5
─────────────────────── ─────────── ───────── ─────────────────── ───────────────────
Providence set 1.5 NULL 1.5
| if gdf.crs is None: | ||
| gdf = gdf.set_crs('EPSG:4326') | ||
| else: | ||
| gdf = gdf.to_crs('EPSG:4326') |
There was a problem hiding this comment.
Be careful of projection, because we have met issues when proj fails sliently. Since I'll extend shape_tweak(), this function is not needed. But in the future, please see how projection is safeguarded in this repo.
| reference_hgrid = read(reference_hgrid_file) | ||
|
|
||
| # Make sure node indexing is compatible | ||
| if gd_ll.np != reference_hgrid.np: |
There was a problem hiding this comment.
Equal node counts do not guarantee compatible node ordering. Please compare the node coordinates before copying reference_hgrid.dp[idx]:
coordinates_match = (
gd_ll.np == reference_hgrid.np
and np.allclose(gd_ll.x, reference_hgrid.x, atol=1e-8, rtol=0.0)
and np.allclose(gd_ll.y, reference_hgrid.y, atol=1e-8, rtol=0.0)
)
if not coordinates_match:
raise ValueError(
'Target and reference hgrids do not have identical '
'node coordinates and ordering.'
)
| 'Temporary_Fix_v7p2', # tweak depths around Bayou Lafourche | ||
| 'Temporary_Fix_v7.2.1', # tweak depth around Philadelphia International Airport and Minas Basin | ||
| 'Temporary_Fix_v7.4', # tweak depth around Philadelphia International Airport | ||
| 'Temporary_Fix_secofs', # tweak depths around Bayou Lafourche |
There was a problem hiding this comment.
The order matters, put this before 'Regional_tweaks'
| '/sciclone/schism10/Hgrid_projects/STOFS3D-v7.4/v32e/Bathy_edit/' | ||
| 'DEM_loading_for_temp_fix_v7p2/hgrid.ll.dem_loaded.mpi.gr3' | ||
| '/sciclone/schism10/Hgrid_projects/STOFS3D-v7.4/v32f_test/Bathy_edit/' | ||
| 'DEM_loading_v7.2_original/hgrid.ll.dem_loaded.mpi.gr3' |
There was a problem hiding this comment.
I noticed that your manual tweaks on the hgrid.gr3 has changed the node order from the original order in /sciclone/schism10/Hgrid_projects/STOFS3D-v7.4/v32f_test/Bathy_edit/ DEM_loading_v7.2_original/hgrid.ll.dem_loaded.mpi.gr3
Can you prevent the order change, since removing elements should not change node order?
If the node order has to be changed, this file needs to be regenerated in a similar way as the Temporary_Fix_secofs's reference_hgrid_file based on the manually tweaked hgrid.
But I'd prefer not to change the node order, because it may lead to unforeseen problems.
|
|
||
| if 'Regional_tweaks' in tasks: # set minimum depth in regions | ||
| from Regional_tweaks.regional_tweaks import tweak_hgrid_depth | ||
| from Regional_tweaks.regional_tweaks import tweak_hgrid_depth, tweak_shp_hgrid_depth |
There was a problem hiding this comment.
I'll use the existing shape_tweak() def to carry out the operation, please revert the change.
| reverse_sign: true | ||
| copy_provenance: true | ||
| sources: | ||
| - name: secofs_orginal_patch |
| merge_rules: | ||
| - name: deeper_bluetopo_region | ||
| method: max_depth | ||
| sources: [secofs_orginal_patch, bluetopo] |
There was a problem hiding this comment.
This file is a duplicate of the one under DEM_loading/, consider keeping just one copy.
Summary
This PR adds SECOFS-related processing to the STOFS-3D-Atlantic bathymetry editing workflow.
The updates include:
Main changes
DEM_loadingsecofs3d_v1.yamlRegional_tweaksregional_tweaks.pyto support additional SECOFS regional bathymetry adjustments.Temporary_Fix_secofstemp_fix_secofs.py.Scope
This PR only contains changes under the
Bathy_editworkflow. Other STOFS-3D-Atlantic configuration, GR3, and source/sink updates will be handled separately.