From 1143b0ecfd1e500efe2cf6ebfee9ea533c75ad7b Mon Sep 17 00:00:00 2001 From: navidgh67 Date: Thu, 8 Oct 2026 17:57:15 -0400 Subject: [PATCH] Record the lab's XRD setup in the legacy converter Tufail (2026-10-08): all legacy scans are top-loaded ground powder, Cu K-alpha with K-alpha2 not stripped (weighted average), and the furnace gets a Precursors input that the legacy filenames can't fill. Reviewed by Codex Astra (approved). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01Ve21T1az57p9vrmYj8vdNe --- scripts/legacy_xrd/convert_legacy_xrd.py | 13 +++++++++++-- scripts/legacy_xrd/test_convert_legacy_xrd.py | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/legacy_xrd/convert_legacy_xrd.py b/scripts/legacy_xrd/convert_legacy_xrd.py index 1a3899b..b87014a 100644 --- a/scripts/legacy_xrd/convert_legacy_xrd.py +++ b/scripts/legacy_xrd/convert_legacy_xrd.py @@ -80,7 +80,11 @@ "Heating Rate": 3.5, # degC/min "Cooling Rate": 5.0, # degC/min "Crucible": "Alumina", - "Radiation": "Cu K-alpha", + # Kα2 not stripped; the lab uses the weighted Kα1/Kα2 average (Tufail, 10-08). + "Radiation": "Cu K-alpha (weighted K-alpha1/K-alpha2, not stripped)", + # All legacy scans: top-loaded ground powder (Tufail, 10-08). + "Loading": "top", + "Sample Preparation": "ground powder", "Furnace": "High Temperature Furnace_1_Indy", } @@ -104,6 +108,7 @@ "Heating Rate", "Cooling Rate", "Crucible", + "Precursors", "Sample ID", "Temperature Profile", "Source File", @@ -115,6 +120,7 @@ "run_date", "Sample ID", "Loading", + "Sample Preparation", "Radiation", "Scan Type", "Step Size", @@ -457,6 +463,8 @@ def convert( "Heating Rate": _fmt_number(LEGACY_CONSTANTS["Heating Rate"]), "Cooling Rate": _fmt_number(LEGACY_CONSTANTS["Cooling Rate"]), "Crucible": LEGACY_CONSTANTS["Crucible"], + # Not recorded in the legacy filenames. + "Precursors": "", "Sample ID": sample_id, # Not recorded for legacy runs. "Temperature Profile": "", @@ -481,7 +489,8 @@ def convert( # The scan date isn't recorded; the synthesis date is used. "run_date": run_date, "Sample ID": sample_id, - "Loading": "", + "Loading": LEGACY_CONSTANTS["Loading"], + "Sample Preparation": LEGACY_CONSTANTS["Sample Preparation"], "Radiation": LEGACY_CONSTANTS["Radiation"], "Scan Type": scan_type, "Step Size": f"{pattern.step:.4g}" if pattern.two_theta else "", diff --git a/scripts/legacy_xrd/test_convert_legacy_xrd.py b/scripts/legacy_xrd/test_convert_legacy_xrd.py index 1da9f45..59c4316 100644 --- a/scripts/legacy_xrd/test_convert_legacy_xrd.py +++ b/scripts/legacy_xrd/test_convert_legacy_xrd.py @@ -125,6 +125,9 @@ def test_splits_into_synthesis_and_xrd_linked_by_sample_id(self): self.assertEqual({row["Sample ID"] for row in xrd}, {sample["Sample ID"]}) self.assertEqual(xrd[0]["Scan Type"], "quick") self.assertEqual(xrd[1]["Tags"], "rescan") + self.assertEqual((xrd[0]["Loading"], xrd[0]["Sample Preparation"]), ("top", "ground powder")) + self.assertIn("not stripped", xrd[0]["Radiation"]) + self.assertEqual(sample["Precursors"], "") pattern = (out / xrd[0]["XRD Pattern"]).read_text().splitlines() self.assertEqual(pattern[0], "two_theta_deg,intensity_counts")