vewprocessing

The vewprocessing module provides tools for processing Vertical Element Wall (VEW) in ADCIRC meshes.

Functions

Submodules

polyline_converter

Module for converting polylines to VEW strings in ADCIRC meshes.

vewutils.vewprocessing.polyline_converter.get_utm_crs(lon, lat)[source]

Determine the UTM CRS based on a longitude/latitude point.

Parameters:
  • lon (float) – Longitude of the point

  • lat (float) – Latitude of the point

Return type:

CRS

Returns:

CRS object for the appropriate UTM zone

vewutils.vewprocessing.polyline_converter.transform_mesh_coordinates(x, y, from_crs, to_crs)[source]

Transform mesh coordinates from one CRS to another.

Parameters:
  • x (Series) – Series of x coordinates

  • y (Series) – Series of y coordinates

  • from_crs (CRS) – Source CRS

  • to_crs (CRS) – Target CRS

Return type:

Tuple[Series, Series]

Returns:

Tuple of transformed (x, y) coordinates as Series

class vewutils.vewprocessing.polyline_converter.PolylineToVEWConverter(mesh, polylines_gdf, mesh_crs=None, dist_max=10.0)[source]

Bases: object

Class for converting polylines to VEW strings.

__init__(mesh, polylines_gdf, mesh_crs=None, dist_max=10.0)[source]

Initialize the converter.

Parameters:
  • mesh (AdcircMesh) – ADCIRC mesh object

  • mesh_crs (CRS) – CRS of the mesh coordinates. If None, assumes coordinates are already in meters

  • polylines_gdf (GeoDataFrame) – GeoDataFrame containing polylines

  • dist_max (float) – Maximum distance for nearest neighbor search in meters

_find_nearest_node(x, y)[source]

Find the nearest mesh node to a point.

Return type:

int

_create_nodestring(line)[source]

Create a nodestring along a line.

Return type:

List[int]

_create_vewstring(nodestring, bank_elevation=1.0, bank_mannings_n=0.02)[source]

Create a VEW string from a nodestring.

Return type:

List[Dict[str, Any]]

convert(bank_elevation=1.0, bank_mannings_n=0.02)[source]

Convert polylines to VEW strings.

Parameters:
  • bank_elevation (float) – Bank elevation for VEW strings

  • bank_mannings_n (float) – Manning’s n value for VEW strings

Return type:

List[List[Dict[str, Any]]]

Returns:

List of VEW strings

vewutils.vewprocessing.polyline_converter.get_parser()[source]
vewutils.vewprocessing.polyline_converter.main(args=None)[source]

vew_adder

Add VEW boundaries to an ADCIRC mesh based on VEW string definitions in a YAML file.

This program reads an ADCIRC mesh in fort.14 format and VEW string definitions from a YAML file, then adds VEW boundaries to the mesh. The modified mesh is written out.

The program supports two modes: 1. Node ID mode: VEW strings specify node_id values that directly reference mesh nodes 2. Coordinate mode: VEW strings specify x,y coordinates that are matched to mesh nodes using spatial search

class vewutils.vewprocessing.vew_adder.VEWBoundaryAdder(mesh, coordinate_mode=False, tolerance=1e-06)[source]

Bases: object

Class for adding VEW boundaries to an ADCIRC mesh.

__init__(mesh, coordinate_mode=False, tolerance=1e-06)[source]

Initialize with an ADCIRC mesh.

Parameters:
  • mesh (AdcircMesh) – ADCIRC mesh object

  • coordinate_mode (bool) – If True, use coordinate-based node matching instead of node IDs

  • tolerance (float) – Distance tolerance for coordinate matching (in mesh units)

_build_coordinate_tree()[source]

Build KDTree for fast coordinate-based node lookup.

_find_node_by_coordinates(x, y)[source]

Find the closest mesh node to given coordinates within tolerance.

Parameters:
  • x (float) – X coordinate

  • y (float) – Y coordinate

Return type:

int

Returns:

Node ID of closest mesh node

Raises:

ValueError – If no node found within tolerance

_process_vew_node_data(nodedata)[source]

Process a single VEW node data entry to extract node ID and bank elevation.

Parameters:

nodedata (Dict) – Dictionary containing either node_id or coordinates (x,y) plus bank_elevation

Return type:

Tuple[int, float]

Returns:

Tuple of (node_id, bank_elevation)

_get_node_identifier(nodedata)[source]

Get a string identifier for a node (used for validation and error messages).

Parameters:

nodedata (Dict) – Dictionary containing node information

Return type:

str

Returns:

String identifier for the node

add_vew_string(vewstring)[source]

Add a single VEW string to the mesh.

Return type:

AdcircMesh

add_vew_strings(vewstrings)[source]

Add multiple VEW strings to the mesh.

Parameters:

vewstrings (List[List[Dict]]) – List of VEW string definitions

Return type:

AdcircMesh

Returns:

Modified AdcircMesh object

vewutils.vewprocessing.vew_adder.add_vews_to_mesh(f14file, vewfile, output_f14=None, coordinate_mode=False, tolerance=1e-06)[source]

Add VEW boundaries to an ADCIRC mesh based on VEW string definitions.

Parameters:
  • f14file (str) – Path to input fort.14 file

  • vewfile (str) – Path to input YAML file containing VEW string definitions

  • output_f14 (str) – Path to output fort.14 file (optional)

  • coordinate_mode (bool) – If True, use coordinate-based node matching instead of node IDs

  • tolerance (float) – Distance tolerance for coordinate matching (in mesh units)

Return type:

None

vewutils.vewprocessing.vew_adder.get_parser()[source]
vewutils.vewprocessing.vew_adder.main(args=None)[source]

vew_scraper

Module for scraping VEW boundaries from ADCIRC meshes and saving them to YAML format.

class vewutils.vewprocessing.vew_scraper.VEWScraper(mesh)[source]

Bases: object

Class for scraping VEW boundaries from ADCIRC meshes.

__init__(mesh)[source]

Initialize the VEW scraper with a mesh.

_get_node_elements_for_nodes(mesh, node_ids)[source]

Get elements connected to specific nodes only (optimized version).

Return type:

Dict[int, set]

_get_node_neighbors_for_nodes(mesh, node_ids)[source]

Get neighbors for specific nodes only (optimized version).

Return type:

Dict[int, set]

_remap_elements_vectorized(elements_df, map_node)[source]

Vectorized remapping of element node IDs using numpy operations.

_remap_boundary_nodes_vectorized(boundaries, map_node)[source]

Vectorized remapping of boundary node IDs using numpy operations.

_strip_vewstring(mesh, ivewboundary)[source]

Strip a single VEW boundary from the mesh and return the modified mesh and VEW string.

Return type:

Tuple[AdcircMesh, List[Dict]]

strip_vewstrings(boundary_indices=None)[source]

Strip specified VEW boundaries from the mesh and return the modified mesh and VEW strings.

Parameters:

boundary_indices – List of boundary indices to scrape. If None, scrapes all boundaries.

Return type:

Tuple[AdcircMesh, Dict]

vewutils.vewprocessing.vew_scraper.get_parser()[source]
vewutils.vewprocessing.vew_scraper.main(args=None)[source]