Skip to content

Add SECOFS processing to STOFS bathymetry editing - #232

Open
hyungjuyoo wants to merge 1 commit into
schism-dev:masterfrom
hyungjuyoo:feature/stofs-bathy-edit-secofs
Open

Add SECOFS processing to STOFS bathymetry editing#232
hyungjuyoo wants to merge 1 commit into
schism-dev:masterfrom
hyungjuyoo:feature/stofs-bathy-edit-secofs

Conversation

@hyungjuyoo

Copy link
Copy Markdown
Contributor

Summary

This PR adds SECOFS-related processing to the STOFS-3D-Atlantic bathymetry editing workflow.

The updates include:

  • Added SECOFS-specific DEM loading configuration and domain shapefile.
  • Added regional bathymetry tweaks for selected SECOFS areas.
  • Added new shapefiles used for regional bathymetry adjustments.
  • Added a temporary SECOFS bathymetry fix workflow.

Main changes

  • DEM_loading

    • Added secofs3d_v1.yaml
    • Added the SECOFS domain shapefile used for DEM processing.
  • Regional_tweaks

    • Updated regional_tweaks.py to support additional SECOFS regional bathymetry adjustments.
    • Added regional shapefiles for locations including Savannah, Cooper/Wando, Wachapreague, Providence, Fall River, Baltimore, and Turkey.
  • Temporary_Fix_secofs

    • Added temp_fix_secofs.py.
    • Added the SECOFS domain shapefile used by the temporary fix.

Scope

This PR only contains changes under the Bathy_edit workflow. Other STOFS-3D-Atlantic configuration, GR3, and source/sink updates will be handled separately.

@feiye-vims feiye-vims Aug 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order matters, put this before 'Regional_tweaks'

Comment on lines -106 to +109
'/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'

@feiye-vims feiye-vims Aug 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@feiye-vims feiye-vims Aug 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll use the existing shape_tweak() def to carry out the operation, please revert the change.

@feiye-vims feiye-vims left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address all comments, including the ones above. Thanks!

reverse_sign: true
copy_provenance: true
sources:
- name: secofs_orginal_patch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix typo

merge_rules:
- name: deeper_bluetopo_region
method: max_depth
sources: [secofs_orginal_patch, bluetopo]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix typo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is a duplicate of the one under DEM_loading/, consider keeping just one copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants