Skip to content

Commit a13c77b

Browse files
ivhclaude
andcommitted
Fix curvature save: match traces by (m, group) instead of index
The curvature step runs on a filtered subset of traces from _select_traces, but save() was mapping results back to disk by sequential index, misaligning curvature data with traces. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ec1b22 commit a13c77b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pyreduce/reduce.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,10 +2162,13 @@ def save(self, traces):
21622162
trace_objects, header = load_traces(trace_file)
21632163

21642164
# Update each trace with slit data from fitted traces
2165-
for i, t in enumerate(traces):
2166-
if i < len(trace_objects):
2167-
trace_objects[i].slit = t.slit
2168-
trace_objects[i].slitdelta = t.slitdelta
2165+
# Match by (m, group) since traces may be a filtered subset
2166+
fitted = {(t.m, t.group): t for t in traces}
2167+
for t in trace_objects:
2168+
match = fitted.get((t.m, t.group))
2169+
if match is not None:
2170+
t.slit = match.slit
2171+
t.slitdelta = match.slitdelta
21692172

21702173
# Save updated traces
21712174
steps = header.get("E_STEPS", "trace").split(",")

0 commit comments

Comments
 (0)