gruvoc.trifile: Tools for reading Cart3D tri 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.uh3dfile.UH3DFileType(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.uh3dfile.get_uh3d_mode(fname_or_fp: IOBase | str, fmt: str | None = None) UH3DFileType | None

Identify UH3D file format if possible

Call:
>>> mode = get_uh3d_mode(fname_or_fp, fmt=None)
Outputs:
mode: None | UH33DFileType

File type, always ASCII for UH3D

cape.gruvoc.uh3dfile.read_uh3d(mesh: UmeshBase, fname_or_fp: str | IOBase, meta: bool = False, fmt: str | None = None)

Read data to a mesh object from .tri file

Call:
>>> read_uh3d(mesh, fname, meta=False, fmt=None)
>>> read_uh3d(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.uh3dfile.write_uh3d(mesh: UmeshBase, fname_or_fp: str | IOBase, fmt: str | None = None)

Write data from a mesh object to .tri file

Call:
>>> write_uh3d(mesh, fname, fmt=None)
>>> write_uh3d(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?"