diff --git a/templates/model/moonflower_resample_DM_pycuda.py b/templates/model/moonflower_resample_DM_pycuda.py new file mode 100644 index 000000000..8c9c4c311 --- /dev/null +++ b/templates/model/moonflower_resample_DM_pycuda.py @@ -0,0 +1,56 @@ +""" +This script is a test for ptychographic reconstruction in the absence +of actual data. It uses the test Scan class +`ptypy.core.data.MoonFlowerScan` to provide "data". +""" + +from ptypy.core import Ptycho +from ptypy import utils as u +import ptypy +ptypy.load_gpu_engines("cuda") + +p = u.Param() +# for verbose output +p.verbose_level = 3 +p.frames_per_block = 200 + +# set home path +p.io = u.Param() +p.io.home = "/tmp/ptypy/" +p.io.autosave = u.Param(active=False) +p.io.interaction = u.Param(active=True) +p.io.interaction.server = u.Param(poll_timeout=1) + +# max 200 frames (128x128px) of diffraction data +p.scans = u.Param() +p.scans.MF = u.Param() +# now you have to specify which ScanModel to use with scans.XX.name, +# just as you have to give 'name' for engines and PtyScan subclasses. +p.scans.MF.name = 'Vanilla' # or 'Full' +p.scans.MF.data= u.Param() +p.scans.MF.data.name = 'MoonFlowerScan' +p.scans.MF.data.shape = 128 +p.scans.MF.data.num_frames = 200 +p.scans.MF.data.save = None + +# position distance in fraction of illumination frame +p.scans.MF.data.density = 0.2 +# total number of photon in empty beam +p.scans.MF.data.photons = 1e8 +# Gaussian FWHM of possible detector blurring +p.scans.MF.data.psf = 0. + +# Resample by a factor of 2 +p.scans.MF.resample = 2 + +# attach a reconstrucion engine +p.engines = u.Param() +p.engines.engine00 = u.Param() +p.engines.engine00.name = 'DM_pycuda' +p.engines.engine00.numiter = 100 +p.engines.engine00.probe_support = 0.05 + +# prepare and run +P = Ptycho(p,level=4) +P.run() +P.finalize() diff --git a/templates/minimal_prep_and_run_resample_DM_serial.py b/templates/model/moonflower_resample_DM_serial.py similarity index 95% rename from templates/minimal_prep_and_run_resample_DM_serial.py rename to templates/model/moonflower_resample_DM_serial.py index 91b037441..a3bc42a0c 100644 --- a/templates/minimal_prep_and_run_resample_DM_serial.py +++ b/templates/model/moonflower_resample_DM_serial.py @@ -6,7 +6,7 @@ from ptypy.core import Ptycho from ptypy import utils as u -from ptypy.accelerate.base.engines import DM_serial +from ptypy.accelerate.base.engines import projectional_serial p = u.Param() # for verbose output diff --git a/templates/model/moonflower_resample_ML_pycuda.py b/templates/model/moonflower_resample_ML_pycuda.py new file mode 100644 index 000000000..870d55c3e --- /dev/null +++ b/templates/model/moonflower_resample_ML_pycuda.py @@ -0,0 +1,61 @@ +""" +This script is a test for ptychographic reconstruction in the absence +of actual data. It uses the test Scan class +`ptypy.core.data.MoonFlowerScan` to provide "data". +""" +#import ptypy +from ptypy.core import Ptycho +from ptypy import utils as u +import ptypy +ptypy.load_gpu_engines("cuda") + +p = u.Param() + +# for verbose output +p.verbose_level = 4 +p.frames_per_block = 100 + +# set home path +p.io = u.Param() +p.io.home = "/tmp/ptypy/" +p.io.autosave = u.Param(active=False) +p.io.interaction = u.Param(active=True) +p.io.interaction.server = u.Param(poll_timeout=1) + +# max 100 frames (128x128px) of diffraction data +p.scans = u.Param() +p.scans.MF = u.Param() +p.scans.MF.name = 'Full' +p.scans.MF.data= u.Param() +p.scans.MF.data.name = 'MoonFlowerScan' +p.scans.MF.data.shape = 128 +p.scans.MF.data.num_frames = 100 +p.scans.MF.data.save = None + +# position distance in fraction of illumination frame +p.scans.MF.data.density = 0.2 +# total number of photon in empty beam +p.scans.MF.data.photons = 1e8 +# Gaussian FWHM of possible detector blurring +p.scans.MF.data.psf = 0. + +# Resample by a factor of 2 +p.scans.MF.resample = 2 + +p.engines = u.Param() +p.engines.engine01 = u.Param() +p.engines.engine01.name = 'ML_serial' +p.engines.engine01.reg_del2 = True # Whether to use a Gaussian prior (smoothing) regularizer +p.engines.engine01.reg_del2_amplitude = 1. # Amplitude of the Gaussian prior if used +p.engines.engine01.scale_precond = True +p.engines.engine01.scale_probe_object = 1. +p.engines.engine01.smooth_gradient = 20. +p.engines.engine01.smooth_gradient_decay = 1/50. +p.engines.engine01.floating_intensities = True +p.engines.engine01.numiter = 300 + +# prepare and run +P = Ptycho(p,level=4) +P.run() +P.finalize() + diff --git a/templates/minimal_prep_and_run_resample_ML_serial.py b/templates/model/moonflower_resample_ML_serial.py similarity index 100% rename from templates/minimal_prep_and_run_resample_ML_serial.py rename to templates/model/moonflower_resample_ML_serial.py