diff --git a/src/cal_tools/lpdlib.py b/src/cal_tools/lpdlib.py
index 7ede9b52dcea17614e899586496922806d060340..872a52964daaa8119b296cff7a7c2f305b09d65c 100644
--- a/src/cal_tools/lpdlib.py
+++ b/src/cal_tools/lpdlib.py
@@ -1,5 +1,6 @@
 import copy
 from typing import List, Optional, Tuple
+from warnings import warn
 
 import h5py
 import numpy as np
@@ -769,3 +770,23 @@ class LpdCorrections:
 
         self.initialize(offsets, rel_gains, rel_gains_b, bpixels, noises,
                         flat_fields)
+
+
+def get_mem_cell_order(run, sources) -> str:
+    """Load the memory cell order to use as a condition to find constants"""
+    res = set()
+    for source in sources:
+        cell_id_data = run[source, 'image.cellId'].drop_empty_trains()
+        if len(cell_id_data.train_ids) == 0:
+            continue  # No data for this module
+        cell_ids = cell_id_data[0].ndarray()
+        # Trailing comma required so e.g. "...,1" doesn't match "...,10"
+        res.add(",".join([str(c) for c in cell_ids.flatten()]) + ",")
+
+    if len(res) > 1:
+        warn("Memory cell order varies between detector modules: "
+             "; ".join([f"{s[:10]}...{s[-10:]}" for s in res]))
+    elif not res:
+        raise ValueError("Couldn't find memory cell order for any modules")
+
+    return res.pop()