28 print(
"Usage: ./rename_hashes.py <export_dir>")
31 export_dir = Path(sys.argv[1])
32 if not export_dir.exists():
33 print(f
"Error: Directory {export_dir} not found.")
38 "CONTROLLER.actuation.timestamp_ns",
39 "CONTROLLER.actuation.duty_F",
40 "CONTROLLER.actuation.duty_O",
41 "CONTROLLER.actuation.u_F_on",
42 "CONTROLLER.actuation.u_O_on",
43 "CONTROLLER.actuation.valid",
44 "CONTROLLER.diagnostics.timestamp_ns",
45 "CONTROLLER.diagnostics.F_ref",
46 "CONTROLLER.diagnostics.MR_ref",
47 "CONTROLLER.diagnostics.F_estimated",
48 "CONTROLLER.diagnostics.MR_estimated",
49 "CONTROLLER.diagnostics.P_ch",
50 "CONTROLLER.diagnostics.cost",
51 "CONTROLLER.diagnostics.solver_iters",
52 "CONTROLLER.diagnostics.safety_filtered",
53 "CONTROLLER.diagnostics.cutoff_active",
54 "CONTROLLER.measurement.timestamp_ns",
55 "CONTROLLER.measurement.P_copv",
56 "CONTROLLER.measurement.P_reg",
57 "CONTROLLER.measurement.P_u_fuel",
58 "CONTROLLER.measurement.P_u_ox",
59 "CONTROLLER.measurement.P_d_fuel",
60 "CONTROLLER.measurement.P_d_ox",
61 "CONTROLLER.measurement.P_ch_mp1",
62 "CONTROLLER.measurement.P_ch_mp2",
63 "CONTROLLER.state.timestamp_ns",
64 "CONTROLLER.state.from_state",
65 "CONTROLLER.state.to_state",
66 "CONTROLLER.state.reason",
67 "CONTROLLER.fire.timestamp_ns",
68 "CONTROLLER.fire.fire_active",
69 "CONTROLLER.fire.duty_F",
70 "CONTROLLER.fire.duty_O",
75 for name
in controller_fields:
81 signed_h = h - (1 << 64)
if h >= (1 << 63)
else h
82 signed_str = str(signed_h)
83 hash_to_name[unsigned_str] = name
84 hash_to_name[signed_str] = name
87 for file_path
in export_dir.glob(
"*.csv"):
88 filename = file_path.stem
89 if filename
in hash_to_name:
90 real_name = hash_to_name[filename]
91 new_path = export_dir / f
"{real_name}.csv"
96 content = file_path.read_text(encoding=
"utf-8")
97 lines = content.splitlines()
101 new_header = header.replace(filename, real_name)
102 lines[0] = new_header
104 new_path.write_text(
"\n".join(lines) +
"\n", encoding=
"utf-8")
106 print(f
"✅ Renamed {filename}.csv -> {real_name}.csv")
108 except Exception
as e:
109 print(f
"Failed to process {file_path.name}: {e}")
111 print(f
"\nSuccessfully recovered {renamed_count} controller variables!")