def set_size_object(self, in_d1, positions, pobj): positions = self.get_positions() p, r = self.parse_params() sh = p.scans.savu.data.shape r.data = np.ones((positions.shape[-1], sh, sh)) p.scans.savu.data.recipe = r P = Ptycho(p, level=2) object_shape = P.obj.storages['S00G00'].data[0].shape self.obj_shape = object_shape + (self.get_num_object_modes(), )
def filter_frames(self, data): # idx = self.get_global_frame_index()# the current frame p = self.p p.scans.savu.data.recipe.data = data[0] positions = self.get_positions()[0]# just assume zero for now p.scans.savu.data.recipe.positions = positions.T[:600] P = Ptycho(p,level=5) object_stack = P.obj.storages['S00G00'].data.astype(np.float) probe_stack = P.probe.storages['S00G00'].data.astype(np.float) return [probe_stack, object_stack, positions]#] add fourier error, realspace error
def filter_frames(self, data): self.r.data = data[0] self.p.scans.savu.data.recipe = self.r # reconstruct P = Ptycho(self.p, level=5) # now post process object_stack = P.obj.storages['S00G00'].data.astype(np.float) probe_stack = P.probe.storages['S00G00'].data.astype(np.float) positions = self.get_positions() return [probe_stack, object_stack, positions] #] add fourier error, realspace error
def filter_frames(self, data): idx = self.get_global_frame_index()# the current frame print idx p = self.p p.scans.savu.data.recipe.data = data[0] positions = self.get_positions()[idx] p.scans.savu.data.recipe.positions = positions self.p.scans.savu.data.recipe = self.r P = Ptycho(self.p,level=5) object_stack = P.obj.storages['S00G00'].data.astype(np.float) probe_stack = P.probe.storages['S00G00'].data.astype(np.float) return [probe_stack, object_stack, positions]#] add fourier error, realspace error
'pilatus': 172e-6, 'merlin': 55e-6, 'eiger': 75e-6 }[detector] p.scans.scan00.data.min_frames = 10 p.scans.scan00.data.load_parallel = 'all' # Scan parameters: illumination p.scans.scan00.illumination = u.Param() p.scans.scan00.illumination.model = None p.scans.scan00.illumination.aperture = u.Param() p.scans.scan00.illumination.aperture.form = 'circ' p.scans.scan00.illumination.aperture.size = 500e-9 # Reconstruction parameters p.engines = u.Param() p.engines.engine00 = u.Param() p.engines.engine00.name = 'DM' p.engines.engine00.numiter = 100 p.engines.engine00.numiter_contiguous = 10 p.engines.engine01 = u.Param() p.engines.engine01.name = 'ML' p.engines.engine01.numiter = 100 p.engines.engine01.numiter_contiguous = 10 if LooseVersion(ptypy.version) < LooseVersion('0.3.0'): raise Exception('Use ptypy 0.3.0 or better!') P = Ptycho(p, level=5)
p.scans.scan01.data.shape = 20 # needs to be an EVEN number for using shifting p.scans.scan01.data.auto_center = False # #detind0 = raw_center[0] - p.scans.scan01.data.shape/2 #detind1 = raw_center[0] + p.scans.scan01.data.shape/2 #detind2 = raw_center[1] - p.scans.scan01.data.shape/2 #detind3 = raw_center[1] + p.scans.scan01.data.shape/2 #p.scans.scan01.data.detector_roi_indices = [detind0,detind1,detind2,detind3] # this one should not be needed since u have shape and center... #p.scans.scan01.data.center = (raw_center[0] - detind0,raw_center[1] - detind2) p.scans.scan01.data.psize = 55e-6 p.scans.scan01.data.energy = 15.0 p.scans.scan01.data.distance = 1.0 #? # prepare and run P = Ptycho(p, level=2) #%% # --------------------------------------------------------- # Load data, some metadata, gemetry object, and do some initial plotting #----------------------------------------------------------- import sys #to collect system path ( to collect function from another directory) sys.path.insert(0, 'C:/Users/Sanna/Documents/python_utilities') from movie_maker import movie_maker import h5py # define motorposition directory. Is this information included in P? scan_name_int = scans[2] scan_name_string = '%d' % scan_name_int
p.engine.DM.alpha = 1 # (94) Parameters that makes the difference p.engine.DM.probe_update_start = 2 # (95) Number of iterations before probe update starts p.engine.DM.update_object_first = True # (96) If False update object before probe p.engine.DM.overlap_converge_factor = 0.05 # (97) Loop overlap constraint until probe change is smaller than this fraction p.engine.DM.overlap_max_iterations = 100 # (98) Maximum iterations to be spent inoverlap constraint p.engine.DM.fourier_relax_factor = 0.1 # (99) If rms of model vs diffraction data is smaller than this fraction, Fourier constraint is met p.engine.ML = u.Param() p.engines = u.Param() # (100) empty structure to be filled with engines p.engines.engine00 = u.Param() p.engines.engine00.name = 'DM' p.engines.engine00.numiter = 100 p.engines.engine00.fourier_relax_factor = 0.05 #p.engines.engine01 = u.Param() #p.engines.engine01.name = 'ML' #p.engines.engine01.numiter = 10 p.simulation = u.Param() p.simulation.position_noise = 1e-10 # (104) p.simulation.detector = dict(dtype=np.uint32, full_well=2**32 - 1, psf=(0, 3)) ## UNCOMMENT FOR SIMULATION ### #P = sim.simulate_basic_with_pods(p,save=True) ### UNCOMMENT FOR RECONTRUCTION #### p.model.coherence.Nprobe_modes = 5 p.model.sample.source = None p.model.illumination.prop_dist = 0.0 P = Ptycho(p, level=3) P.save_run(kind='minimal')