Readers: polarization from miniCBF and d*TREK headers (RESULT-CHANGING)

No reader parsed a polarization, and ApplyRugnuxExperimentDefaults then set
P = 0.99 (an undulator value) unconditionally, so laboratory-source data were
corrected as if from a synchrotron. Every d*TREK (Rigaku Saturn/A200) header in
the open arm states SOURCE_POLARZ=0.5 1 0 0, i.e. unpolarized; at Cu K-alpha and
2 A the wrong factor puts a +-33% azimuthal modulation on the intensities.

- d*TREK SMV: SOURCE_POLARZ is the fraction f followed by the plane normal (as
  dxtbx's FormatSMVRigaku reads it); stored as degree 2f - 1, negative where the
  normal lies along lab x (plane containing y).
- miniCBF: "# Polarization f" is the fraction in the horizontal plane; stored as
  2f - 1 ("None" or a missing line leave it unset).
- ApplyRugnuxExperimentDefaults sets 0.99 only where the file stated none;
  --polarization still overrides. ADSC SMV, marCCD and NXmx state nothing and
  keep 0.99.
- The "Header:" log line reports the stated polarization.

RESULT-CHANGING: d*TREK home-source sets (0.99 -> 0), one Rigaku miniCBF set
(0.99 -> 0), miniCBF sets stating 0.99 (0.99 -> 0.98).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXc1zD1yxHqaR1DGdCTHL4
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-18 09:25:14 +02:00
1 parent 14ee27f362
commit b17b643bd9
11 files changed
+84 -14

No files matched your search

+34 -1
View File
@@ -4049,6 +4049,33 @@ namespace {
}
}
TEST_CASE("JFJochCBFReader_Polarization", "[HDF5][Full][portable]") {
const int64_t nx = 24, ny = 16;
// The line states the fraction polarized in the horizontal plane; the correction wants the degree.
WriteMiniCBFSweep("cbfpol", "# Polarization 0.990\n", nx, ny);
JFJochCBFReader reader;
REQUIRE_NOTHROW(reader.ReadFiles("cbfpol_0001.cbf"));
REQUIRE(reader.GetDataset()->experiment.GetPolarizationFactor().has_value());
CHECK(reader.GetDataset()->experiment.GetPolarizationFactor().value() == Catch::Approx(0.98));
reader.Close();
RemoveMiniCBFSweep("cbfpol");
WriteMiniCBFSweep("cbfunpol", "# Polarization 0.500000\n", nx, ny); // a laboratory tube
JFJochCBFReader lab;
REQUIRE_NOTHROW(lab.ReadFiles("cbfunpol_0001.cbf"));
REQUIRE(lab.GetDataset()->experiment.GetPolarizationFactor().has_value());
CHECK(lab.GetDataset()->experiment.GetPolarizationFactor().value() == Catch::Approx(0.0).margin(1e-6));
lab.Close();
RemoveMiniCBFSweep("cbfunpol");
WriteMiniCBFSweep("cbfnopol", "# Polarization None\n", nx, ny);
JFJochCBFReader none;
REQUIRE_NOTHROW(none.ReadFiles("cbfnopol_0001.cbf"));
CHECK_FALSE(none.GetDataset()->experiment.GetPolarizationFactor().has_value());
none.Close();
RemoveMiniCBFSweep("cbfnopol");
}
TEST_CASE("JFJochCBFReader_AxisTableStatesTheMounting", "[HDF5][Full][portable]") {
const int64_t nx = 24, ny = 16;
@@ -4553,6 +4580,7 @@ TEST_CASE("JFJochSMVReader_Geometry", "[HDF5][Full][portable]") {
REQUIRE(x.GetGoniometer().has_value());
CHECK(x.GetGoniometer()->GetStart_deg() == Catch::Approx(5.0));
CHECK(x.GetGoniometer()->GetIncrement_deg() == Catch::Approx(0.2));
CHECK_FALSE(x.GetPolarizationFactor().has_value()); // an ADSC header states none
reader.Close();
RemoveSMVSweep("smv_", ".img");
}
@@ -4572,7 +4600,8 @@ TEST_CASE("JFJochSMVReader_Geometry", "[HDF5][Full][portable]") {
<< "CCD_GONIO_VECTORS=0 0 1 1 0 0 0 1 0 1 0 0 0 1 0 0 0 -1;\n"
<< "ROTATION=-13.500 -13.000 0.500 30.000 0.000 0.000 0.000 100.000 0.000 0.000;\n"
<< "ROTATION_AXIS_NAME=Omega;\nROTATION_VECTOR=1.000 0.000 0.000;\n"
<< "SOURCE_WAVELENGTH=1.000000 1.541780;\nSATURATED_VALUE=4194176;\nRAXIS_COMPRESSION_RATIO=128;\n}\n";
<< "SOURCE_WAVELENGTH=1.000000 1.541780;\nSATURATED_VALUE=4194176;\nRAXIS_COMPRESSION_RATIO=128;\n"
<< "SOURCE_POLARZ=0.9000 1.0000 0.0000 0.0000;\n}\n";
std::string head = h.str();
head.resize(1024, ' ');
std::vector<uint16_t> pixels(static_cast<size_t>(nx) * ny, 100);
@@ -4613,6 +4642,10 @@ TEST_CASE("JFJochSMVReader_Geometry", "[HDF5][Full][portable]") {
CHECK(x.GetGoniometer()->GetStart_deg() == Catch::Approx(-13.5));
CHECK(x.GetGoniometer()->GetIncrement_deg() == Catch::Approx(0.5));
CHECK((x.GetGoniometer()->GetAxis() - Coord(1, 0, 0)).Length() < 1e-5f);
// A fraction of 0.9 is a degree of 0.8; the plane's normal along x puts the plane on y, which
// the correction spells as a negative degree.
REQUIRE(x.GetPolarizationFactor().has_value());
CHECK(x.GetPolarizationFactor().value() == Catch::Approx(-0.8));
reader.Close();
remove("dtrek_0001.img");
}