ImageD11.sinograms.point_by_point module#
- class ImageD11.sinograms.point_by_point.PBP(parfile, dset, hkl_tol=0.01, fpks=0.7, ds_tol=0.005, etacut=0.1, ifrac=None, gmax=5, cosine_tol=np.float64(0.0017453283658982615), y0=0, symmetry='cubic', loglevel=3, foridx=None, forgen=None, uniqcut=0.75, phase_name=None, uniqueness=0.5)#
Bases:
object- iplot(skip=1)#
- point_by_point(grains_filename, icolf_filename=None, nprocs=None, gridstep=1, debugpoints=None, loglevel=3)#
grains_filename = output file icolf_filename = hdf5 file to read. Allows mmap to be used. The
voxel_mask peak index is read from its PBPPeakIndex group.
- setpeaks(colf, icolf_filename=None, keep_colf=True)#
Given a cf_2d in RAM (colf), make an icolf in RAM which contains the selection of peaks we want to index
- submit_slurm_chunks(grains_prefix, id11_code_path, gridstep=1, n_chunks=4, cpus_per_chunk=64, time_h=48, partition='nice-long', mem_G=32, debugpoints=None)#
- write_config(config_path, cpus_per_chunk)#
- class ImageD11.sinograms.point_by_point.PBPMap(*args, **kwargs)#
Bases:
columnfileColumnfile for point-by-point indexing and refinement results. The results of point-by-point indexing and refinement can be multi-valued e.g there can be more than one UBI found at a given map pixel Therefore this class stores pixel results in the following way:
# i j ntotal nuniq ubi00 ubi01 ubi02 ubi10 ubi11 ubi12 ubi20 ubi21 ubi22
We have an extra method to get all the results at one pixel: self.get_pixel_mask() There’s another concept: selecting a single best UBI at each pixel This will fill in self.best_UBI, self.best_npks, self.best_nuniq
- property NI#
- property NJ#
- property NY#
- property UBI#
- choose_best(minpeaks=6)#
- property eps#
eps computed on-demand from reshaping eps columns shape is (3, 3, nrows) to match previous PBPMap definition
- get_pixel_mask(i, j)#
Return mask to columnfile with those specified i and j values
- property i_shift#
- property j_shift#
- plot_best(minpeaks=6)#
- plot_nuniq_hist()#
- property ubi#
ubi computed on-demand from reshaping ubi columns. shape is (3, 3, nrows) to match previous PBPMap definition
- ImageD11.sinograms.point_by_point.get_local_gv(si, sj, ystep, omega, sinomega, cosomega, xl, yl, zl)#
Given a point (si, sj) in step space, compute the x values in the lab frame for each omega angle Then subtract them from xl to account for the change in the diffraction origin point. Then re-compute the g-vectors.
- ImageD11.sinograms.point_by_point.hkluniq(ubi, gx, gy, gz, eta, m, tol, hmax)#
count uniq peaks - move to cImageD11 in the future
- ImageD11.sinograms.point_by_point.idxpoint(si, sj, omega, sinomega, cosomega, dty, dtyi, xl, yl, zl, eta, omega_partitions, dty_partitions, sinomega_bins, cosomega_bins, idx_buf, ydist_buf, sel_buf, ystep=2.0, y0=0.0, ymin=-2.0, minpks=1000, hkl_tol=0.1, ds_tol=0.005, cosine_tol=np.float64(0.0017453283658982615), forgen=None, hmax=-1, uniqcut=0.75, relax_mask=False, uniqueness=0.5)#
Indexing function called at one point in space.
Selects peaks from the sinogram and attempts to index.
- Parameters:
si – Voxel indices in step space
sj – Voxel indices in step space
omega – Columnfile columns, already permuted to partition order
sinomega – Columnfile columns, already permuted to partition order
cosomega – Columnfile columns, already permuted to partition order
dty – Columnfile columns, already permuted to partition order
dtyi – Columnfile columns, already permuted to partition order
xl – Columnfile columns, already permuted to partition order
yl – Columnfile columns, already permuted to partition order
zl – Columnfile columns, already permuted to partition order
eta – Columnfile columns, already permuted to partition order
omega_partitions – omega_partitions[i] is the index of the first (sorted) peak in omega bin i
dty_partitions – dty_partitions[i,j] is the index of the first (sorted) peak in omega bin i and dty bin j
sinomega_bins – For speed
cosomega_bins – For speed
idx_buf – Buffer - will be filled with the indices of the peaks that put (si, sj) in the beam
ydist_buf – Buffer - will be filled with the ydist of the peaks that put (si, sj) in the beam
sel_buf – Buffer - used if relax_mask=False to select the peaks that put (si, sj) in the beam and satisfy the stricter predicate
ystep – Passed to fill_voxel_idx()
y0 – Passed to fill_voxel_idx()
ymin – Passed to fill_voxel_idx()
minpks – number of peaks to find with rings, by default 1000
optional – number of peaks to find with rings, by default 1000
hkl_tol – ImageD11 tolerance of indexed == | h-int(h) | < hkl_tol, by default 0.1
optional – ImageD11 tolerance of indexed == | h-int(h) | < hkl_tol, by default 0.1
ds_tol – Ring assignment tolerance, by default 0.005
optional – Ring assignment tolerance, by default 0.005
cosine_tol – Cosine tolerance for finding pairs of peaks, by default np.cos(np.radians(90 - 0.1))
optional – Cosine tolerance for finding pairs of peaks, by default np.cos(np.radians(90 - 0.1))
forgen – Rings to generate orientations, by default None
optional – Rings to generate orientations, by default None
hmax – Maximum hkl value, by default -1
optional – Maximum hkl value, by default -1
uniqcut – Unique peaks cutoff (uniq> ucut * max are returned), by default 0.75
optional – Unique peaks cutoff (uniq> ucut * max are returned), by default 0.75
relax_mask – Use previously-used stricter predicate for ydist, by default False
optional – Use previously-used stricter predicate for ydist, by default False
uniqueness – indexer.uniqueness: an orientation is kept only if more than this fraction of its peaks are not already claimed by an orientation accepted earlier at this point. 0.5 (default) rejects duplicates, but a Sigma3 twin shares ~1/3 of its reflections with the parent, so it can reject the second member of a twin pair too.
optional – indexer.uniqueness: an orientation is kept only if more than this fraction of its peaks are not already claimed by an orientation accepted earlier at this point. 0.5 (default) rejects duplicates, but a Sigma3 twin shares ~1/3 of its reflections with the parent, so it can reject the second member of a twin pair too.
- Return type:
list of (npks, nuniq, ubi)
- Raises:
ValueError – If peak buffer too small for this point. This shouldn’t happen if max_canidates was computed correctly
- ImageD11.sinograms.point_by_point.initializer(parfile, phase_name, symmetry, colfile, loglevel=3)#
- ImageD11.sinograms.point_by_point.nb_choose_best(i, j, u, n, NY, ubiar, minpeaks=6)#
- ImageD11.sinograms.point_by_point.nb_inv(mats, imats)#
- ImageD11.sinograms.point_by_point.nb_inv_3d(mats, imats)#
- ImageD11.sinograms.point_by_point.proxy(args)#
Wrapper function for multiprocessing
- ImageD11.sinograms.point_by_point.select_point_peaks(si, sj, ystep, y0, ymin, omega_partitions, dty_partitions, sinomega, cosomega, dty, dtyi, sinomega_bins, cosomega_bins, idx_buf, ydist_buf, out, relax)#
Peaks that put step-space point (si, sj) in the beam.
Wraps fill_voxel_idx() but with an optional stricter predicate (relax=False) The original geometry.dtyimask_from_step_sincos() predicate is exact equality of the dtyi bin The voxel_mask predicate is |.| <= ystep, which is the two nearest rows – exactly 2x the peaks
- relax=False reproduces geometry.dtyimask_from_step_sincos exactly:
dty_to_dtyi(y0 - sx sin(w) - sy cos(w)) == dtyi
Fills idx_buf, ydist_buf and out (sel_buf) inplace
- Parameters:
si – Sample indices in step space
sj – Sample indices in step space
ystep – Passed to fill_voxel_idx()
y0 – Passed to fill_voxel_idx()
ymin – Passed to fill_voxel_idx()
omega_partitions – See VoxelSinoMasker documentation
dty_partitions – See VoxelSinoMasker documentation
sinomega – Columnfile columns, needed for the stricter predicate when relax=False
cosomega – Columnfile columns, needed for the stricter predicate when relax=False
dty – Columnfile columns, needed for the stricter predicate when relax=False
dtyi – Columnfile columns, needed for the stricter predicate when relax=False
sinomega_bins – See VoxelSinoMasker documentation
cosomega_bins – See VoxelSinoMasker documentation
idx_buf – Buffers for fill_voxel_idx() to write into
ydist_buf – Buffers for fill_voxel_idx() to write into
out – sel_buf: stricter version of idx_buf when relax=False
relax – Use voxel_mask predicate (|.| <= ystep) instead of exact equality of the dtyi bin
- Returns:
Number of peaks written into out, or -1 if nothing was written because the buffers were too small
- Return type:
m