Made a few more updates to some example scripts, to show the panel plot mode

This commit is contained in:
allevitan
2026-03-20 17:35:25 +01:00
parent f4260837bc
commit e7f943e254
4 changed files with 14 additions and 12 deletions
+6 -5
View File
@@ -1,6 +1,6 @@
import cdtools
from matplotlib import pyplot as plt
import torch as t
from matplotlib import pyplot as plt
filename = 'example_data/AuBalls_700ms_30nmStep_3_6SS_filter.cxi'
dataset = cdtools.datasets.Ptycho2DDataset.from_cxi(filename)
@@ -26,7 +26,8 @@ model = cdtools.models.FancyPtycho.from_dataset(
probe_support_radius=50,
propagation_distance=2e-6,
units='um',
probe_fourier_crop=pad
probe_fourier_crop=pad,
panel_plot_mode=True,
)
@@ -39,9 +40,9 @@ model.translation_offsets.data += 0.7 * t.randn_like(model.translation_offsets)
# Not much probe intensity instability in this dataset, no need for this
model.weights.requires_grad = False
device = 'cuda'
model.to(device=device)
dataset.get_as(device=device)
if t.cuda.is_available():
model.to(device='cuda')
dataset.get_as(device='cuda')
# Create the reconstructor
recon = cdtools.reconstructors.AdamReconstructor(model, dataset)
+5 -4
View File
@@ -1,11 +1,11 @@
import cdtools
import torch as t
from matplotlib import pyplot as plt
filename = 'example_data/PETRAIII_P25_Near_Field_Ptycho.cxi'
dataset = cdtools.datasets.Ptycho2DDataset.from_cxi(filename)
dataset.inspect()
plt.show()
# Setting near_field equal to True uses an angular spectrum propagator in
# lieu of the default Fourier-transform propagator for far-field ptychography.
@@ -27,11 +27,12 @@ model = cdtools.models.FancyPtycho.from_dataset(
propagation_distance=3.65e-3, # 3.65 downstream from focus
units='um', # Set the units for the live plots
obj_view_crop=-35,
panel_plot_mode=True,
)
device = 'cuda'
model.to(device=device)
dataset.get_as(device=device)
if t.cuda.is_available():
model.to(device='cuda')
dataset.get_as(device='cuda')
model.inspect(dataset)
+1 -1
View File
@@ -688,7 +688,7 @@ class CDIModel(t.nn.Module):
else:
with plt.rc_context({'figure.raise_window': False}):
fig = plt.figure(plot['title'],
figsize = panel_def.get('figure_size', None)
figsize = figsize,
constrained_layout=True)
try:
+2 -2
View File
@@ -716,9 +716,9 @@ def plot_nanomap_with_images(translations, get_image_func, values=None, mask=Non
# mode, i.e. on a figure that already has this thing showing.
if fig is None:
fig = plt.figure(figsize=(20,4.5), constrained_layout=True)
fig = plt.figure(figsize=(8,5.3), constrained_layout=True)
else:
fig = plt.figure(fig.number, figsize=(20,4.5), constrained_layout=True)
fig = plt.figure(fig.number, figsize=(8,5.3), constrained_layout=True)
fig.clear()
if hasattr(fig, 'nanomap_cids'):
for cid in fig.nanomap_cids: