diff --git a/examples/gold_ball_ptycho.py b/examples/gold_ball_ptycho.py index 4971975..fd7ba32 100644 --- a/examples/gold_ball_ptycho.py +++ b/examples/gold_ball_ptycho.py @@ -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) diff --git a/examples/near_field_ptycho.py b/examples/near_field_ptycho.py index c91076f..7b86bd3 100644 --- a/examples/near_field_ptycho.py +++ b/examples/near_field_ptycho.py @@ -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) diff --git a/src/cdtools/models/base.py b/src/cdtools/models/base.py index 99a87f8..f6473dc 100644 --- a/src/cdtools/models/base.py +++ b/src/cdtools/models/base.py @@ -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: diff --git a/src/cdtools/tools/plotting/plotting.py b/src/cdtools/tools/plotting/plotting.py index 7069130..5380871 100644 --- a/src/cdtools/tools/plotting/plotting.py +++ b/src/cdtools/tools/plotting/plotting.py @@ -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: