gruvoc.ugridfile: Tools for reading AFLR3 ugrid files

One key functionality of this module is to determine the file type of .ugrid files or determine that they are not recognizable files of that format.

class cape.gruvoc.ugridfile.UGRIDFileType(fmt, byteorder, filetype, precision)
byteorder

Alias for field number 1

filetype

Alias for field number 2

fmt

Alias for field number 0

precision

Alias for field number 3

cape.gruvoc.ugridfile.UGRID_MODE_CHECKERS = {'b4': <function check_ugrid_b>, 'b8': <function check_ugrid_b>, 'lb4': <function check_ugrid_lb>, 'lb8': <function check_ugrid_lb>, 'lr4': <function check_ugrid_lr>, 'lr8': <function check_ugrid_lr>, 'r4': <function check_ugrid_r>, 'r8': <function check_ugrid_r>, None: <function check_ugrid_ascii>}

Dictionary of mode checkers

cape.gruvoc.ugridfile.get_ugrid_mode(fname_or_fp: IOBase | str, fmt: str | None = None) UGRIDFileType | None

Identify UGRID file format if possible

Call:
>>> mode = get_ugrid_mode(fname_or_fp, fmt=None)
Inputs:
fname_or_fp: str | IOBase

Name of file or file handle

fmt: {None} | str

Predicted file format

Outputs:
mode: None | UGRIDFileType

File type, big|little endian, stream|fortran, etc.

cape.gruvoc.ugridfile.read_ugrid(mesh: UmeshBase, fname_or_fp: str | IOBase, meta: bool = False, fmt: str | None = None, novol: bool = False)

Read data to a mesh object from .ugrid file

Call:
>>> read_ugrid(mesh, fname, meta=False, fmt=None)
>>> read_ugrid(mesh, fp, meta=False, fmt=None)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

meta: True | {False}

Read only metadata (number of nodes, tris, etc.)

fmt: {None} | str

Manual data format, "l?[br][48]l?"

cape.gruvoc.ugridfile.write_ugrid(mesh: UmeshBase, fname_or_fp: str | IOBase, fmt: str | None = None)

Write data from a mesh object to .ugrid file

Call:
>>> write_ugrid(mesh, fname, fmt=None)
>>> write_ugrid(mesh, fp, fmt=None)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

fmt: {None} | str

Manual data format, "l?[br][48]l?"