AfterNight

Open-source astrophotography processing in C++. Calibration (darks, flats, bias), star detection, sub-pixel registration, sigma-clipped stacking, background gradient removal — with a focus on speed (SIMD, OpenCL) and reproducible results.

OpenXISF

A C++20 library for reading and writing XISF, the image format of PixInsight. I wrote it for AfterNight. The libraries I found covered only part of the specification, lived outside the platforms where people send pull requests, or were written in another language behind a C interface. I wanted one that a C++ application can take as an ordinary dependency and that anyone can contribute to.

It is written from the published specification, XISF 1.0 Revision 1, and every section maps to the tests that cover it. It reads and writes monolithic and distributed units, with every standard codec (zlib, LZ4, LZ4HC, Zstandard, with byte shuffling), and it verifies each checksum before a block is decompressed. Files are treated as untrusted input: sizes are overflow-checked, blocks are bounds-checked, and the parsers are fuzzed and run under sanitizers. It builds on Windows, Linux and macOS and is licensed under Apache 2.0.

OpenFITS

A C++20 library for reading, writing and editing FITS, the standard file format of astronomy. It is the second library of AstroFormats, after OpenXISF, and shares its design. It is meant to replace CFITSIO in C++ programs: its API does not depend on any application, and where CFITSIO serializes every call behind one global lock, any number of threads can read a file at once.

It is written from the FITS 4.0 standard, and a conformance matrix maps each area of the standard to the tests that cover it. It reads every structure the standard defines and writes all but the deprecated random groups, including tile compression with every algorithm of the standard. Existing files are edited through a commit: changes that keep the layout are written in place, the rest rewrite the file through a copy that replaces it atomically, and CHECKSUM and DATASUM are updated from the changed bytes alone. Files are treated as untrusted input: sizes and offsets are overflow-checked, allocations are limited, and the parsers are fuzzed and run under sanitizers. It builds on Windows, Linux and macOS and is licensed under Apache 2.0.

Measured against CFITSIO 4.7.0, its median time is at most CFITSIO’s, within the 5% noise of the measurement, in all 179 operations both libraries offer, and lower where the work vectorizes or runs in parallel: a 6000 × 4000 frame of 16-bit values is read in 0.57 of CFITSIO’s time, and the same frame compressed with RICE_1 in 0.48 on one thread and 0.10 on sixteen. The full table was measured on an AMD Ryzen 9 9950X under Windows 11, both libraries built with MSVC 14.51 in Release.

Code from the series

Each series ships its code alongside the posts, so every number can be re-run.

  • What the Compiler Did: the loops, the build flags and the scripts that produce the tables in each post, ready for Compiler Explorer.
  • AI in the loop: the agent setup the series describes: the project instructions, the hooks that enforce them, the review checklist.
  • Parsers from scratch: every parser from the series, with its tests and the inputs that broke earlier versions.

Smaller experiments live on GitHub.