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 pointlat (
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 coordinatesy (
Series
) – Series of y coordinatesfrom_crs (
CRS
) – Source CRSto_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 objectmesh_crs (
CRS
) – CRS of the mesh coordinates. If None, assumes coordinates are already in meterspolylines_gdf (
GeoDataFrame
) – GeoDataFrame containing polylinesdist_max (
float
) – Maximum distance for nearest neighbor search in meters
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 objectcoordinate_mode (
bool
) – If True, use coordinate-based node matching instead of node IDstolerance (
float
) – Distance tolerance for coordinate matching (in mesh units)
- _find_node_by_coordinates(x, y)[source]
Find the closest mesh node to given coordinates within tolerance.
- Parameters:
x (
float
) – X coordinatey (
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)
- 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 filevewfile (
str
) – Path to input YAML file containing VEW string definitionsoutput_f14 (
str
) – Path to output fort.14 file (optional)coordinate_mode (
bool
) – If True, use coordinate-based node matching instead of node IDstolerance (
float
) – Distance tolerance for coordinate matching (in mesh units)
- Return type:
None
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.
- _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.