Metadata-Version: 2.4
Name: surfio
Version: 0.0.17
Summary: Reader/Writer library for irap files.
License-Expression: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Other Environment
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# surfio

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

## Installation

```bash
pip install .
```

## Usage

Irap surfaces can be imported using the `from_ascii_file`, `from_ascii_string`, `from_binary_file` and `from_binary_buffer` methods of `IrapSurface`.

```python
import surfio


surface = surfio.IrapSurface.from_ascii_file("./file.irap")
print(surface.header.ncol, surface.header.nrow) # 10, 11
print(surface.values.shape) # (10, 11)
```

`from_ascii_file` is equivalent to

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

but is more performant.

Exporting irap surfaces can be done with

```python
    surface = surfio.IrapSurface(
        surfio.IrapHeader(
            ncol=3,
            nrow=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.to_ascii_file("./file.txt")
```

which is equivalent to:

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

## Development

```bash
pip install -e ".[dev]"
```

Style is enforced via pre-commit:

```bash
pre-commit install
```

## C++ development

To configure the project

```bash
cmake --preset release-posix
```

To build it

```bash
cmake --build --preset release-posix
```

To test it

```bash
ctest --preset release-posix
```
