Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/legacy_xrd/convert_legacy_xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand All @@ -104,6 +108,7 @@
"Heating Rate",
"Cooling Rate",
"Crucible",
"Precursors",
"Sample ID",
"Temperature Profile",
"Source File",
Expand All @@ -115,6 +120,7 @@
"run_date",
"Sample ID",
"Loading",
"Sample Preparation",
"Radiation",
"Scan Type",
"Step Size",
Expand Down Expand Up @@ -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": "",
Expand All @@ -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 "",
Expand Down
3 changes: 3 additions & 0 deletions scripts/legacy_xrd/test_convert_legacy_xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down