Skip to content
/ surfio Public

Library for reading file formats (currently only supports irap ascii)

License

Notifications You must be signed in to change notification settings

equinor/surfio

Repository files navigation

surfio

Surfio is a library for reading and writing surface files. Currently only supports the irap format.

Installation

pip install .

Usage

Irap surfaces can be imported using the import_ascii and import_ascii_file methods of IrapSurface.

import surfio


surface = surfio.IrapSurface.import_ascii_file("./file.irap")
print(surface.header.nx, surface.header.ny) # 10, 11
print(surface.values.shape) # (10, 11)

import_ascii_file is equivalent to

with open("./file.irap") as f:
    surface = surfio.IrapSurface.import_ascii_file(f.read())

but is more performant.

Exporting irap surfaces can be done with

    surface = surfio.IrapSurface(
        surfio.IrapHeader(
            nx=3,
            ny=2,
            xori=0.0,
            yori=0.0,
            xinc=2.0,
            yinc=2.0,
            xmax=2.0,
            ymax=2.0,
            rot=0.0,
            xrot=0.0,
            yrot=0.0,
        ),
        values=np.zeros((3, 2)),
    )
    surface.export_ascii_file("./file.txt")

which is equivalent to:

with open("./file.irap", mode="w") as f:
    f.write(surface.export_ascii())

Development

pip install -e ".[dev]"

Style is enforced via pre-commit:

pre-commit install

About

Library for reading file formats (currently only supports irap ascii)

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published