Skip to content

Commit

Permalink
updated templates, ML_serial and ML_pycuda are broken
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer committed Mar 25, 2022
1 parent af9cc8c commit 0369ac3
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
56 changes: 56 additions & 0 deletions templates/model/moonflower_resample_DM_pycuda.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions templates/model/moonflower_resample_ML_pycuda.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 0369ac3

Please sign in to comment.