gruvoc.ufuncfile: Tools for reading AFLR3 ufunc files

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

cape.gruvoc.ufuncfile.SFUNC_MODE_CHECKERS = {'b4': <function check_sfunc_b>, 'b8': <function check_sfunc_b>, 'lb4': <function check_sfunc_lb>, 'lb8': <function check_sfunc_lb>, 'lr4': <function check_sfunc_lr>, 'lr8': <function check_sfunc_lr>, 'r4': <function check_sfunc_r>, 'r8': <function check_sfunc_r>, None: <function check_sfunc_ascii>}

Dictionary of mode checkers

class cape.gruvoc.ufuncfile.UFUNCFileType(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.ufuncfile.UFUNC_MODE_CHECKERS = {'b4': <function check_ufunc_b>, 'b8': <function check_ufunc_b>, 'lb4': <function check_ufunc_lb>, 'lb8': <function check_ufunc_lb>, 'lr4': <function check_ufunc_lr>, 'lr8': <function check_ufunc_lr>, 'r4': <function check_ufunc_r>, 'r8': <function check_ufunc_r>, None: <function check_ufunc_ascii>}

Dictionary of mode checkers

cape.gruvoc.ufuncfile.flatten_ufunc_vectors(mesh: UmeshBase, slot: str, shape: Tuple[int, int], order: str | None = 'F')
Convert ufunc vector from more user friendly (nvec, len, nnode)

to expected ufunc formatted vector (nvec, len*nnode) ordered as [(x1,y1,z1), (x2,y2,z2), …] for len = 3

Call:
>>> flatten_ufunc_vectors(mesh, slot, shape)
Inputs:
mesh: Umesh

Unstructured mesh object

slot: str

Name of ufunc vector slot

shape: tuple

Tuple of length 2 to control flattened output shape

order: {“F”} | str

Ordering of vector reshaping

cape.gruvoc.ufuncfile.get_sfunc_mode(fname_or_fp: IOBase | str, fmt: str | None = None) UFUNCFileType | None

Identify UFUNC 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 | UFUNCFileType

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

cape.gruvoc.ufuncfile.get_ufunc_mode(fname_or_fp: IOBase | str, fmt: str | None = None) UFUNCFileType | None

Identify UFUNC 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 | UFUNCFileType

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

cape.gruvoc.ufuncfile.inflate_ufunc_vectors(mesh: UmeshBase, slot: str, shape: Tuple[int, int, int], order: str | None = 'F')
Convert ufunc formatted vector (nvec, len*nnode) ordered as

[(x1,y1,z1), (x2,y2,z2), …] to more user friendly (nvec, len, nnode) for len = 3

Call:
>>> inflate_ufunc_vectors(mesh, slot, shape)
Inputs:
mesh: Umesh

Unstructured mesh object

slot: str

Name of ufunc vector slot

shape: tuple

Tuple of length 3 to control inflated output shape

order: {“F”} | str

Ordering of vector reshaping

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

Read data to a mesh object from .sfunc file

Call:
>>> read_sfunc(mesh, fname)
>>> read_sfunc(mesh, fp)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

Versions:
  • 2025-03-06 @aburkhea: v1.0

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

Read data to a mesh object from .ufunc file

Call:
>>> read_ufunc(mesh, fname)
>>> read_ufunc(mesh, fp)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

Versions:
  • 2025-03-06 @aburkhea: v1.0

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

Write data from a mesh object to .sfunc file

Call:
>>> write_sfunc(mesh, fname,)
>>> write_sfunc(mesh, fp)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

Versions:
  • 2025-03-06 @aburkhea: v1.0

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

Write data from a mesh object to .ufunc file

Call:
>>> write_ufunc(mesh, fname,)
>>> write_ufunc(mesh, fp)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

Versions:
  • 2025-03-06 @aburkhea: v1.0