Bay-Delta SELFE Tools

cut_mesh Module

Functions to cut certain parts in the mesh by cutting lines.

cut_mesh.cut_mesh(fpath_gr3_in, lines, fpath_gr3_out, cut_side='left')

Remove elements of a mesh in one side of cutting polyline segments. A mesh is read in from a gr3, and a result mesh is written in another gr3 file. A user needs to be careful that line segments forms a closed division. Otherwise, all elements would be deleted.

Parameters :

fpath_gr3_in :

Filename of the input grid in gr3

lines: array-like :

An array of coordinates of line segments specifying the location of cuts

fpath_gr3_out :

Filename of the output grid in gr3

cut_side: str, optional :

If cut_side is ‘left,’ which is default, the left side of cutting lines when one sees the second point from the first point of a line will be removed. If this value is ‘right,’ the right side will be removed.

cut_mesh.read_lines(fpath)

Read coordinates of cutting line segments from a plain text file. The expected format is: x1 y1 x2 y2 in each line.

Parameters :

fpath :

Name of a file containing coordinates of cutting lines

Returns :

list :

List of coordinates of cutting lines

cut_mesh.read_lines_from_shapefile(fpath)

Read coordinates of cutting line segments from a ESRI Shapefile containing line features.

Parameters :

fpath :

Name of a file containing coordinates of cutting lines

Returns :

list :

List of coordinates of cutting lines