opatIO-cpp 0.3.0a
Open Parametrized Array Table
|
The opatIO-cpp
library is a high-performance C++ library designed for reading, writing, and manipulating OPAT (Open Parameterized Array Table) files. These files are used to store structured numeric, in a compact and efficient format, indexed by some arbitrary length floating point vector. The library provides both programmatic and command-line interfaces, making it suitable for integration into larger software systems or for standalone data inspection and validation tasks.
Key features of opatIO-cpp
include:
The library is part of the broader OPAT ecosystem and is designed to work seamlessly with other tools and libraries in the OPAT suite.
The opatIO-cpp
library is intended only for reading OPAT files. Writing OPAT files is not supported at this time. The library is designed to be fast and efficient, but it does not include all the features of the OPAT file format. For more advanced use cases, consider using the Python version of the library.
The opatIO-cpp
project relies on several external libraries to provide its functionality. Understanding these dependencies can be helpful for development and troubleshooting.
TableLattice
component for numerical linear algebra operations, specifically boost::numeric::ublas::matrix
and boost::numeric::ublas::vector
for solving systems of equations related to barycentric coordinate calculations.build-config/boost/install.sh
) that can download and build Boost locally if it's not detected on your system. The Meson build system will prompt you before attempting to run this script.TableLattice
class to perform N-dimensional Delaunay triangulation of the OPAT index points, which is a core part of the interpolation mechanism.OPAT
class. This is crucial for efficiently accessing data in OPAT files.opatIO-cpp
(e.g., opatHeader
, opatInspect
, opatVerify
) to handle user-provided arguments.In summary, for most users, only ensuring Boost is available (or allowing the build script to install it) is necessary. The other dependencies are handled seamlessly by the Meson build system.
You will need meson
, cmake
, and ninja
installed pre-installed. These can be installed with pip
Then you can build and install opat-core
If you want to run tests
To install headers, libraries, and the command line utilities
The OPAT I/O library provides a C++ API for interacting with OPAT files. Below are some common use cases:
TableLattice
for InterpolationThe opatIO-cpp
library includes a powerful feature for interpolating data within OPAT files: the TableLattice
class. This is particularly useful when you need to estimate data values at index points that are not explicitly defined in the OPAT file.
The TableLattice
works by performing N-dimensional Delaunay triangulation on the index vectors found in the provided OPAT file. Each unique index vector in the OPAT data becomes a vertex in this triangulation.
When you request data for a specific query point (an index vector):
TableLattice
first identifies the N-simplex (e.g., a triangle in 2D, a tetrahedron in 3D) within the Delaunay triangulation that encloses your query point. This is done using a "walk" algorithm through the triangulation.DataCard
s from the original OPAT file) are then interpolated using these barycentric weights. Currently, only linear interpolation is supported. This means each table within the DataCard
s is interpolated element-wise.The result is a new DataCard
containing tables where each value is an interpolated estimate corresponding to your query point.
To use TableLattice
, you first need an opat::OPAT
object, which you can get by reading an OPAT file. Then, you construct a TableLattice
object, passing the opat::OPAT
object to its constructor.
During construction, the TableLattice
will:
opat_data
.std::runtime_error
if, for example, there are insufficient or degenerate points for triangulation.Once the TableLattice
is initialized, you can get interpolated data using its get()
method. This method takes a FloatIndexVector
(representing the point at which you want to interpolate) and returns an opat::DataCard
.
InterpolationType::Linear
is implemented and supported. Attempting to set or use other types will result in a std::runtime_error
.get()
method will throw a std::out_of_range
exception if the query indexVector
is outside the rectangular bounds defined by the minimum and maximum values of the original index vectors in each dimension.findContainingSimplex
method cannot find a simplex that encloses the query point (i.e., the point is outside the convex hull), it will also typically result in a std::out_of_range
or std::runtime_error
(e.g., if the walk algorithm fails to locate the point).indexVector
must have the same number of dimensions as the index vectors in the OPAT file (opat_data.header.numIndex
). Mismatched dimensions will lead to a std::invalid_argument
exception.TableLattice
constructor might fail (throwing std::runtime_error
from Qhull).TableLattice
(building the Delaunay triangulation) can be computationally intensive for a very large number of unique index vectors or high dimensionality. However, this is a one-time cost.get()
operation involves a walk through the triangulation and then barycentric calculations. The TableLattice
caches the last found simplex, which can speed up queries for spatially coherent points.get()
, constructors, and setInterpolationType()
can throw various exceptions (std::out_of_range
, std::invalid_argument
, std::runtime_error
). It's good practice to wrap calls to these methods in try-catch
blocks in production code if you anticipate potentially problematic inputs.cpp lattice.dumpTriangulationToAscii("points_output.txt", "simplices_output.txt");
The TableLattice
provides a robust way to perform N-dimensional linear interpolation on OPAT data, extending the utility of your datasets.
The OPAT I/O library includes several CLI tools for inspecting and validating OPAT files. Below are the available tools and their usage:
opatHeader
Description: Displays the header information of an OPAT file.
Usage:
Example:
opatInspect
Description: Displays the header and card catalog information of an OPAT file.
Usage:
Example:
opatVerify
Description: Verifies if a file is a valid OPAT file.
Usage:
Example:
opatIO.h
, indexVector.h
) and the source code.`