Files
Jungfraujoch/common/MtzTable.h
T
leonarski_fandClaude Opus 5.5 5f731db81d rugnux: the library returns its outputs in memory; the callers write the files
The rugnux library wrote its results itself: _process.h5 through a
FileWriter, the merged/twin/_mr reflection files, the unmerged MTZs, the
maps and their MTZ, the placed models, _detector.jpg and _plot.txt, and
on a doubled cell it renamed files on disk. It now writes none of them.

- MtzTable (common/MtzTable.h): an MTZ file's header, columns and batch
  headers with no file behind it. It replaces MergedReflectionsMessage
  and MapCoefficientsMessage in the END message, with one CBOR encoding.
  WriteMtz (writer/WriteRugnuxFiles.h) is the one serialiser, used by
  rugnux and jfjoch_writer alike; it refuses a table whose columns differ
  in length, name a missing dataset, carry a malformed batch header or
  name a space group gemmi does not know. MergedMtzTable and
  UnmergedMtzTable build the tables the old writers built.
- ProcessResult::outputs (RugnuxOutputs) holds, for the output pass only:
  the answer's merge (MTZ table plus what the .cif/.hkl are written from),
  the twin hypothesis' and the model's choice's merges, the unmerged and
  unmerged-partials tables, the maps (coefficients always; the grids only
  with ProcessConfig::keep_map_grids), the placed models, the detector
  JPEG and the per-image plot table, and the start message of the
  no-lattice _process.h5. Map RMS is taken from the grid in memory, as the
  CCP4 header stated it, whether or not the map is kept.
- The per-image analysis goes to a caller-supplied RugnuxImageSink;
  rugnux and the viewer give a FileWriter-based ProcessFileSink. The
  geometry pre-pass no longer makes a _01_process.h5.
- The doubled cell keeps both output sets: the answer's in outputs, the
  other's in DoubledCell::other_outputs with its suffix; the report names
  files by suffix after the caller's prefix.
- The output prefix, write_process_h5 and the observation dump path are
  gone from ProcessConfig; --dump-observations is a callback.
- What used to be gated on having files to write (model validation and
  MR, the twin-hypothesis merges, the finalist ledger, the scaled fulls,
  the unmerged tables) is gated on the output pass instead, so a caller
  with no prefix gets the same results.
- RugnuxOutputFiles (new library JFJochRugnuxOutput, linked by rugnux,
  the viewer and the tests) writes every file from the result with the
  names and formats rugnux has always used. The viewer writes its job's
  files the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:51:20 +02:00

49 lines
1.7 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <array>
#include <cstdint>
#include <string>
#include <vector>
#include "UnitCell.h"
// What an MTZ file holds - its header, its columns and its batch headers - with no file behind it: the
// merged reflections, the map coefficients and the unmerged observations rugnux makes, for whatever
// writes them (WriteMtz, writer/WriteRugnuxFiles.h) or carries them (the END message). Every dataset
// has the table's cell; a dataset's id is its position in `datasets`.
struct MtzTable {
struct Dataset {
std::string project_name;
std::string crystal_name;
std::string dataset_name;
float wavelength_A = 0.0f; // 0 = not set
};
struct Column {
std::string label;
char type = 'R'; // the MTZ column type: H, J, Q, F, I, ...
int32_t dataset_id = 0;
std::vector<float> values; // one per row
};
// The header of one image of unmerged data: the integer and real arrays as the MTZ format lays them
// out (29 and 156 long), and the names of its goniostat axes.
struct Batch {
int32_t number = 0;
std::string title;
std::vector<int32_t> ints;
std::vector<float> floats;
std::vector<std::string> axes;
};
std::string title;
UnitCell unit_cell{};
std::string space_group_name; // extended Hermann-Mauguin (xhm), which keeps the setting
std::vector<std::string> history;
std::array<int32_t, 5> sort_order{};
std::vector<Dataset> datasets;
std::vector<Column> columns;
std::vector<Batch> batches;
};