bobleesj commited on
Commit
78d4f23
·
verified ·
1 Parent(s): e0e55b2

workshop: single Show2D for 3 CoM panels

Browse files
Files changed (1) hide show
  1. notebooks/berk_workshop_v1.ipynb +9 -42
notebooks/berk_workshop_v1.ipynb CHANGED
@@ -312,7 +312,7 @@
312
  "com_row = (data_f * qx).sum(dim=(-2, -1)) / total_per_dp\n",
313
  "com_col = (data_f * qy).sum(dim=(-2, -1)) / total_per_dp\n",
314
  "\n",
315
- "# Detrend so the colormap is zero-centered on the signed deflection.\n",
316
  "com_row -= com_row.mean()\n",
317
  "com_col -= com_col.mean()\n",
318
  "\n",
@@ -323,43 +323,11 @@
323
  "print(f\"|CoM| max {com_mag.max().item():.4f} px\")\n",
324
  "\n",
325
  "quantem.widget.Show2D(\n",
326
- " com_row.cpu().numpy(),\n",
327
- " title=\"CoM row (qx) — DPC\",\n",
328
  " sampling=meta[\"sampling\"][:2],\n",
329
  " units=meta[\"units\"][:2],\n",
330
- " cmap=\"RdBu_r\",\n",
331
- ")"
332
- ]
333
- },
334
- {
335
- "cell_type": "code",
336
- "execution_count": null,
337
- "id": "5d80052b",
338
- "metadata": {},
339
- "outputs": [],
340
- "source": [
341
- "quantem.widget.Show2D(\n",
342
- " com_col.cpu().numpy(),\n",
343
- " title=\"CoM col (qy) — DPC\",\n",
344
- " sampling=meta[\"sampling\"][:2],\n",
345
- " units=meta[\"units\"][:2],\n",
346
- " cmap=\"RdBu_r\",\n",
347
- ")"
348
- ]
349
- },
350
- {
351
- "cell_type": "code",
352
- "execution_count": null,
353
- "id": "24a5fdee",
354
- "metadata": {},
355
- "outputs": [],
356
- "source": [
357
- "quantem.widget.Show2D(\n",
358
- " com_mag.cpu().numpy(),\n",
359
- " title=\"|CoM| (total deflection)\",\n",
360
- " sampling=meta[\"sampling\"][:2],\n",
361
- " units=meta[\"units\"][:2],\n",
362
- " cmap=\"magma\",\n",
363
  ")"
364
  ]
365
  },
@@ -371,13 +339,12 @@
371
  "## What you just did\n",
372
  "\n",
373
  "1. Loaded real 4D-STEM gold from Hugging Face → torch tensor on the Colab T4.\n",
374
- "2. Browsed it with `Show4DSTEM` and found the probe center via CoM of the mean DP.\n",
375
- "3. Bright field via aperture mask × per-scan sum, rendered with `Show2D`.\n",
376
- "4. Dark field via the complementary mask.\n",
377
- "5. DPC / CoM maps: row, column, and total magnitude — three interactive `Show2D` widgets.\n",
378
  "\n",
379
- "Every reduction ran on the GPU in milliseconds; every visualization is an\n",
380
- "interactive WebGPU widget (zoom, contrast, scale bar).\n",
381
  "\n",
382
  "## Try next\n",
383
  "\n",
 
312
  "com_row = (data_f * qx).sum(dim=(-2, -1)) / total_per_dp\n",
313
  "com_col = (data_f * qy).sum(dim=(-2, -1)) / total_per_dp\n",
314
  "\n",
315
+ "# Detrend so RdBu_r is zero-centered on the signed deflection.\n",
316
  "com_row -= com_row.mean()\n",
317
  "com_col -= com_col.mean()\n",
318
  "\n",
 
323
  "print(f\"|CoM| max {com_mag.max().item():.4f} px\")\n",
324
  "\n",
325
  "quantem.widget.Show2D(\n",
326
+ " [com_row.cpu().numpy(), com_col.cpu().numpy(), com_mag.cpu().numpy()],\n",
327
+ " labels=[\"CoM row (qx)\", \"CoM col (qy)\", \"|CoM| total\"],\n",
328
  " sampling=meta[\"sampling\"][:2],\n",
329
  " units=meta[\"units\"][:2],\n",
330
+ " cmap=[\"RdBu_r\", \"RdBu_r\", \"magma\"],\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  ")"
332
  ]
333
  },
 
339
  "## What you just did\n",
340
  "\n",
341
  "1. Loaded real 4D-STEM gold from Hugging Face → torch tensor on the Colab T4.\n",
342
+ "2. Browsed it with `Show4DSTEM`; hardcoded the aperture at the detector center.\n",
343
+ "3. Bright field via aperture mask × per-scan sum (`Show2D`).\n",
344
+ "4. Dark field via the complementary mask (`Show2D`).\n",
345
+ "5. DPC / CoM: a single `Show2D` with three panels — CoM row, CoM col, and `|CoM|` magnitude.\n",
346
  "\n",
347
+ "Every reduction on the GPU in milliseconds; every viz is an interactive WebGPU widget.\n",
 
348
  "\n",
349
  "## Try next\n",
350
  "\n",