You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"_ = plot_3d_scatter_with_animation(x, y, z, browser=False)"
203
+
"_ = plot_3d_scatter_with_animation(x, y, z, browser=True)"
132
204
]
133
205
},
134
206
{
@@ -138,7 +210,9 @@
138
210
"source": [
139
211
"### Example Flight (Rotation-Corrected)\n",
140
212
"\n",
141
-
"Before decomposing the data, it is helpful to see what the rotation-corrected marker data looks like as a flight. The animation below shows the bilateral marker positions for Toothless (9 m, straight, period 2), averaged across flights by binning on horizontal distance to perch."
213
+
"Before decomposing the data, it is helpful to see what the rotation-corrected marker data looks like as a flight. The animation below shows the bilateral marker positions for Toothless (9 m, straight, period 2), averaged across flights by binning on horizontal distance to perch.\n",
214
+
"\n",
215
+
"Press play/pause, drag the scrollbar, or click and drag the plot to rotate. "
142
216
]
143
217
},
144
218
{
@@ -239683,7 +239757,53 @@
239683
239757
}
239684
239758
},
239685
239759
"outputs": [],
239686
-
"source": "# Select a flight: Toothless, 9 m, straight, 2020\nflight = dict(hawkname=\"Toothless\", perchDist=\"9m\", turn=\"Straight\", year=2020)\n\n# --- Original bilateral markers, binned by distance (ground truth) ---\nn = len(combined_frame_info_df)\nbilateral_mask = filter_by(scores_df.iloc[:n], **flight)\nbins = scores_df.iloc[:n].loc[bilateral_mask, \"bins\"]\norig = transformed_markers[bilateral_mask, :8, :]\n\norig_df = pd.DataFrame(orig.reshape(-1, 24), index=bins.index)\norig_df[\"bins\"] = bins.values\norig_binned = orig_df.groupby(\"bins\", observed=True).mean()\n\n# --- Bin raw scores using the same distance bins ---\nleft_binned = get_binned_raw_scores(scores, scores_df, **flight, left=True)\nright_binned = get_binned_raw_scores(scores, scores_df, **flight, left=False)\n\n# Align all to the same bin index\ncommon_bins = orig_binned.index.intersection(left_binned.index).intersection(right_binned.index)\nprint(f\"Bins: {len(orig_binned)} original, {len(left_binned)} left, {len(right_binned)} right, {len(common_bins)} common\")\n\norig_bilateral = orig_binned.loc[common_bins].to_numpy().reshape(-1, 8, 3)\nleft_np = left_binned.loc[common_bins].to_numpy()\nright_np = right_binned.loc[common_bins].to_numpy()\n\nmu = mean_shape.reshape(1, -1, 3)\n\n# --- Sanity check: 12-mode reconstruction must match original ---\nall_modes = list(range(12))\nfull_recon = to_bilateral(\n reconstruct(right_np, principal_components, mu, all_modes),\n left=reconstruct(left_np, principal_components, mu, all_modes),\n)\nmax_err = np.abs(full_recon - orig_bilateral).max()\nprint(f\"Max error (12-mode vs original): {max_err:.2e} m\")\nassert max_err < 1e-10, f\"12-mode reconstruction does not match original! Max error: {max_err}\"\n\n# --- 4-mode reconstruction ---\nmodes = [0, 1, 2, 3]\nrecon_bilateral = to_bilateral(\n reconstruct(right_np, principal_components, mu, modes),\n left=reconstruct(left_np, principal_components, mu, modes),\n)\n\nprint(f\"Reconstructed {len(common_bins)} distance bins using {len(modes)} modes\")"
239760
+
"source": [
239761
+
"# Select a flight: Toothless, 9 m, straight, 2020\n",
0 commit comments