ImageD11.frelon_peaksearch module#

ImageD11.frelon_peaksearch.do3dmerge(cf_2d_dict, n, omega, radius=1.6)#

Merges the peaks in cf_2d_dict if the center is within radius pixels n = the number of peaks on each frame in cf_2d_dict omega = the rotation motor position for each frame

returns cf_3d_dict = merged peaks, as well as the input

ImageD11.frelon_peaksearch.do4dmerge(cf_2d_dict, n, omega, dty, ostep, ystep, radius=1.6)#

Merges the peaks in cf_2d_dict if the center is within radius pixels n = the number of peaks on each frame in cf_2d_dict omega = the rotation motor position for each frame dty = the dty motor position for each frame

returns cf_4d_dict = merged peaks, as well as the input

ImageD11.frelon_peaksearch.get_dset(h5name, dsetname)#

This avoids to re-read the dataset many times

ImageD11.frelon_peaksearch.guess_bg(ds, scan_number=0, start=0, step=9, n=None)#

ds = dataset object scan_number = index into ds.scans start = 0 = first image to look at step is the step for going through frames n = number of frames to look at (None == all)

returns median( [ frames[j::step,:,:].min() for j in range(step) ] ) e.g. take the minimum of every step images

then return the median of these

ImageD11.frelon_peaksearch.peaks_list_to_dict(all_frames_peaks_list)#

Merges collected peak properties into structured dictionaries

ImageD11.frelon_peaksearch.pps(arg)#
ImageD11.frelon_peaksearch.segment_dataset(dataset, worker_args, num_cpus=None, scan_number=0, monitor_name=None, monitor_ref_func=<function mean>, **process_map_kwargs)#

Process a dataset by collecting all 2d peaks (for frames), merge them, and performing spatial correction (detector plane correction) Performs 4D merge if you give more than one scan number Returns columnfile_2d, columnfile_3d (and columnfile_4d if relevant)

dataset: ImageD11.sinograms.dataset.Dataset object worker_args: arguments to the peaksearch worker num_cpus: number of CPUs to multiprocess over scan_number: which scan number (or numbers) in ds.scans to segment. monitor_name: name of a monitor to look for via ds.set_monitor(name) Intensities will be scaled during semgnetation if a name is provided monitor_ref_func: function to apply to ds.monitor to generate a reference value when we normalise, we multiply by ref_value_func(ds.monitor)/ds.monitor we suggest np.mean as an example… hint: if you want to return a constant, use this: ref_value_func=lambda x: 1e5

ImageD11.frelon_peaksearch.segment_master_file(master_file, frames_dataset, omega_angles, worker_args, num_cpus=None, scale_factor=None, **process_map_kwargs)#

Collects peaks for all the frames in the first scan in the dataset using parallel processing.

class ImageD11.frelon_peaksearch.worker(bgfile, maskfile, threshold=50, smoothsigma=1.0, bgc=0.9, minpx=3, m_offset_thresh=100, m_ratio_thresh=135, flatfile=None, darkfile=None)#

Bases: object

subtracts background, custom for ma4750

bgsub(img, scale_factor=None)#

This attempts to remove a background by rescaling the self.bg image.

correct(img)#

Applies dark + flat if given

masksub(img)#
peaksearch(img, omega=0, scale_factor=None)#
plots()#