ImageD11.sinograms.dataset module#
- class ImageD11.sinograms.dataset.DataSet(dataroot='.', analysisroot='.', sample='sample', dset='dataset', detector='eiger', omegamotor='rot_center', dtymotor='dty', filename=None, analysispath=None, omega_wraps=False)#
Bases:
objectOne DataSet instance per detector!
- ATTRNAMES = ('dataroot', 'analysisroot', 'sample', 'dset', 'shape', 'dsname', 'datapath', 'analysispath', 'masterfile', 'limapath', 'detector', 'omegamotor', 'dtymotor', 'monitorname', 'monitor_ref', 'pksfile', 'sparsefile', 'parfile', 'e2dxfile', 'e2dyfile', 'detectorh5', 'splinefile', 'maskfile', 'bgfile', 'pksfile', 'col4dfile', 'col3dfile', 'col2dfile', 'grainsfile', 'sparsefile', 'icolfile', 'pbpfile', 'y0', 'f2scan_dy_domega', 'omega_wraps')#
- NDNAMES = ('omega', 'omega_for_bins', 'dty', 'nnz', 'frames_per_file', 'nlm', 'frames_per_scan', 'monitor', 'ybinedges', 'ybincens', 'obinedges', 'obincens', 'ybin_real_mask', 'dty_raw')#
- STRINGLISTS = ('scans', 'imagefiles', 'sparsefiles')#
- check_files(path, filenames, verbose=0)#
See whether files are created or not
- check_images()#
Is the experiment finished ?
- check_sparse()#
Has the segmentation been done ?
- compare(other)#
Try to see if the load/save is working
- correct_bins_for_half_scan(y0=0.0)#
Pad self.ybincens / self.ybinedges around the bin nearest to y0 so that the dataset becomes symmetric. The original measured bins are never moved; only virtual bins are added on whichever side is shorter. A boolean mask records which bins are real.
Sets self.ybin_real_mask : bool array on self.ybincens, False on virtual bins
- get_cf_2d(ignore_existing=False)#
- get_cf_2d_from_disk()#
- get_cf_3d_from_disk()#
- get_cf_4d(ignore_existing=False)#
- get_cf_4d_from_disk()#
- get_colfile_from_peaks_dict(peaks_dict=None, corrector=None)#
Converts a dictionary of peaks (peaks_dict) into an ImageD11 columnfile adds on the geometric computations (tth, eta, gvector, etc) Uses self.pk2d if no peaks_dict provided
- get_grains_from_disk(phase_name=None)#
- get_monitor(name='fpico6')#
- get_monitor_pk2d(pk2d, name='fpico6')#
To be used to normalise the peaks 2d
- get_phases_from_disk()#
- get_ring_current_per_scan()#
Gets the ring current for each scan (i.e rotation/y-step) Stores it inside self.ring_currents_per_scan and a scaled version inside self.ring_currents_per_scan_scaled
- get_spatial_corrector()#
Return a spatial corrector callable built from whichever distortion source is set on self, in priority order: detectorh5, then e2dx/e2dy files, then splinefile. Returns None if none is configured.
The returned callable takes a columnfile and adds the ‘sc’/’fc’ corrected coordinate columns:
corrector = self.get_spatial_corrector() if corrector is not None:
cf = corrector(cf)
- guess_detector()#
Guess which detector we are using from the masterfile
- guess_shape()#
- guess_y0()#
Guess y0 from y bins. We assume the scan is symmetric across y0. Should be good for an initial guess.
- guessbins()#
Attempts to estimate the step size in the data by looking at the numbers in self.omega and self.dty that should already have self.shape reflecting the length of the individual scans.
Perhaps this is the wrong approach. But we don’t have it in the bliss data.
The data might not be on a regular grid.
- import_all(scans=None, shape=None, guess_y0=True)#
- import_from_sparse(hname, scans=None, shape=None)#
hname = hdf5 file containing sparse pixels (and motors) dataset = a dataset instance to import into scans = defaults to reading all “%d.1” scans in the file
give a list to read in some other order or a subset
- import_imagefiles()#
Get the Lima file names from the bliss master file, also scan_npoints
- import_motors_from_master()#
read the motors from the lima file you need to import the imagefiles first these will be the motor positions to accompany the images # could also get these from sparse files if saved
- import_nnz()#
Read the nnz arrays from the sparsefiles
- import_nnz_from_sparse()#
Read the nnz arrays from the sparsefiles
- import_scans(scans=None, hname=None)#
Reads in the scans from the bliss master file
- load(h5name=None, h5group='/')#
- property peaks_table#
- property pk2d#
- property pk4d#
- report()#
- reset_peaks_cache()#
Clear cached peaks table - relevant if you set a monitor which will change intensities in columnfiles.
- save(h5name=None, h5group='/')#
- save_grains_to_disk(grains, phase_name=None)#
- set_monitor(name='fpico6', ref_value_func=<function mean>)#
Sets self.monitor and self.monitor_ref after calling self.get_monitor() Clears cached pk2d and pk4d so they can be re-computed
ref_value_func: function to apply to self.monitor to generate a reference value when we normalise, we multiply by ref_value_func(self.monitor)/self.monitor we suggest np.mean as an example… hint: if you want to return a constant, use this: ref_value_func=lambda x: 1e5
- sinohist(weights=None, omega=None, dty=None, method='fast', return_edges=False)#
Bin some data onto the sinogram histogram
- update_colfile_pars(cf, phase_name=None)#
Load parameters and update geometry for colfile
- update_paths(force=False, verbose=False)#
- ImageD11.sinograms.dataset.bin_phase(values, step)#
Where to put the first bin centre so that the bins line up with values.
Returns the circular mean of values modulo step, in [0, step). Circular because the residuals pile up at both ends when the bins are nearly right, and a linear mean would then land half a step away from all of them.
- ImageD11.sinograms.dataset.check(dataroot, analysisroot, sample, dset, destination, scans=None)#
- ImageD11.sinograms.dataset.get_rotations_images(omega)#
Per-turn frame counts of a continuous rotation.
omega: the delivered per-frame centre angles (a mod-360 motor column, e.g. diffrz_cen360). The frame-to-frame step is normalised to [-180,180) and averaged, which is robust to a bad first frame and to the delivered step drifting from the requested one. A turn ends each time the motor has passed a whole number of 360-degree bin edges, so a frame’s turn index depends only on (i + 0.5) * omegastep and the first angle cancels out entirely.
- ImageD11.sinograms.dataset.guess_chunks(name, shape)#
- ImageD11.sinograms.dataset.guess_omega_step(omega, rptcut=0.02)#
Estimates the step in omega angle data for multi-turn
- Case 1: more turns try to interleave intentionally (irrationals)
step should reduce smoothly as more frames are added
example: step = pi or sqrt(2) or 180 * (3 - np.sqrt(5)) or any irrational
data improve resolution ‘forever’
- Case 2: more turns repeat the same angles over and over
step stays the same when more frames are added
example: 0.25, 0.3, 0.5, 1.0, etc
- Case 1&2: Prime rationals. Frames start interleaving, eventually repeat.
example: 17 degree step. Needs 17 turns, then starts repeating.
example: 1/3607 degree step. Needs a lot of turns, then starts repeating.
- rptcut = tolerance to decide if frames are the same angle.
A fraction of the largest step found.
- ImageD11.sinograms.dataset.load(h5name, h5group='/')#