dyadkin 7f3f46740f
ci linux-qt6 / build-test (push) Successful in 1m35s
ci win / build-test (push) Successful in 1m51s
ci macos / build-test (push) Successful in 3m47s
Bump cmake-tools
2026-09-30 09:55:33 +02:00
2022-10-14 17:17:45 +02:00
2026-07-03 15:42:32 +02:00
2026-09-30 09:55:33 +02:00
2026-08-14 12:34:29 +02:00

integracio

C library for integration of 2D diffraction images using PONI geometry.

integracio implements radial, azimuthal and cake integration as well as grazing incidence integration for Qz/Qr/Qy and Alpha/Theta. The integrator handles polarization and solid angle corrections and supports both 1D and 2D binning with pixel splitting.

Overview

The library is built around struct integrator which is initialized from a PONI description and image dimensions. After initialization the integrator precomputes pixel corners, bin boundaries and correction arrays. Integration is performed by passing a struct integrable describing the image data, limits and integration type. Pixel contributions are split between bins to avoid systematic errors.

Units can be 2theta in degrees or Q in nm. Integration types include radial IT_Tth, azimuthal IT_Chi, cake IT_Tth_vs_Chi, grazing IT_Qz_vs_Qr, IT_Qz_vs_Qy, IT_Alpha_vs_Theta and related 1D projections.

Components

  • integracio/integracio.h - public API: integrator_new, integrator_destroy, integrator_init, integrator_init_grazing, integrator_integrate, setters for units, polarization and solid angle usage, position accessors.
  • integracio/integracio.c - implementation of geometry calculation, binning, 1D and 2D integration with pixel splitting and corrections.

Build

Requires CMake 3.27+ and a C compiler. Dependencies are managed via cmake-tools. The PONI header is provided by cmake-tools base.

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

Install target provides headers in include/integracio and static library libintegracio.a.

Options:

  • -DINTEGRACIO_BUILD_TESTS=ON builds the GoogleTest suite in tests/. Tests require cryio and integrustio test data.

Usage

#include <integracio/integracio.h>

struct integrator *i = integrator_new(dim1, dim2);
integrator_set_units(i, IU_q_nm);
integrator_set_use_polarization(i, 1);
integrator_set_use_solid_angle(i, 1);
integrator_set_polarization(i, 0.99);

if (integrator_init(i, &poni, tth_bins, chi_bins) < 0) { /* error */ }

struct integrable data = {
    .array = frame,
    .limits = {d1_min, d1_max, d2_min, d2_max},
    .type = IT_Tth
};

double *intensity = calloc(tth_bins, sizeof(double));
double *errors = calloc(tth_bins, sizeof(double));
integrator_integrate(i, &data, intensity, errors);
integrator_destroy(i);

Grazing incidence:

integrator_init(i, &poni, dim2, dim1);
integrator_init_grazing(i, dim2, dim1, alpha_i);

Integration types are defined in integracio.h and include IT_Tth, IT_Chi, IT_Tth_vs_Chi, IT_Qz_Qr, IT_Qr, IT_Qy, IT_Qz_vs_Qr, IT_Qz_vs_Qy, IT_Alpha, IT_Theta, IT_Alpha_vs_Theta.

License

GPL-3.0+

S
Description
pyFAI on steroids in C
Readme
9.1 MiB
0 Stars 1 Watchers 0 Forks
Languages
C 69.4%
C++ 21%
CMake 9.6%