Skip to content

Commit ee844bf

Browse files
author
Joel Bernier
committed
added overlap testing to fitgrains
1 parent f72f7db commit ee844bf

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

hexrd/findorientations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ def find_orientations(cfg, hkls=None, clean=False, profile=False):
478478
fmt="%.18e",
479479
delimiter="\t"
480480
)
481-
481+
pass
482+
pass # close conditional on grid search
483+
482484
# generate the completion maps
483485
logger.info("Running paintgrid on %d trial orientations", quats.shape[1])
484486
if profile:

hexrd/fitgrains.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def get_data(cfg, show_progress=False, force=False, clean=False):
126126
'omega_step': cfg.image_series.omega.step,
127127
'omega_stop': cfg.image_series.omega.stop,
128128
'omega_tol': cfg.fit_grains.tolerance.omega,
129+
'overlap_table': os.path.join(cfg.analysis_dir, 'overlap_table.npz'),
129130
'panel_buffer': cfg.fit_grains.panel_buffer,
130131
'pixel_pitch': instrument_cfg['detector']['pixels']['size'],
131132
'plane_data': pd,
@@ -327,6 +328,22 @@ def fit_grains(self, grain_id, grain_params, refit_tol=None):
327328
idx = np.logical_and(valid_refl_ids, unsat_spots)
328329
pass # end if edge case
329330

331+
# if an overlap table has been written, load it and use it
332+
overlaps = np.zeros(len(refl_table), dtype=bool)
333+
try:
334+
ot = np.load(self._p['overlap_table'])
335+
for key in ot.keys():
336+
for this_table in ot[key]:
337+
these_overlaps = np.where(
338+
this_table[:, 0] == grain_id)[0]
339+
if len(these_overlaps) > 0:
340+
mark_these = np.array(this_table[these_overlaps, 1], dtype=int)
341+
overlaps[mark_these] = True
342+
idx = np.logical_and(idx, ~overlaps)
343+
except IOError, IndexError:
344+
#print "no overlap table found"
345+
pass
346+
330347
# completeness from pullspots only; incl saturated
331348
completeness = sum(valid_refl_ids)/float(len(valid_refl_ids))
332349

hexrd/xrd/crystallography.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,6 @@ def getMergedRanges(self, cullDupl=False):
870870
tThLoIdx = 0
871871
tThHiCur = 0.
872872
for iHKL, nonoverlapNext in enumerate(nonoverlapNexts):
873-
print tThLoIdx
874873
tThHi = tThRanges[iHKL, -1]
875874
if not nonoverlapNext:
876875
if cullDupl and abs(tThs[iHKL] - tThs[iHKL+1]) < sqrt_epsf:

hexrd/xrd/indexer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def paintGrid(quats, etaOmeMaps,
753753
# omeIndices = mapIndices[1].T.flatten()
754754
# etaIndices = num.tile(range(numEtas), (numOmes))
755755
# omeIndices = num.tile(range(numOmes), (numEtas))
756-
# j_eta, i_ome = np.meshgrid(range(numEtas), range(numOmes))
756+
# j_eta, i_ome = num.meshgrid(range(numEtas), range(numOmes))
757757
# etaIndices = j_eta.flatten()
758758
# omeIndices = i_ome.flatten()
759759
etaIndices = num.r_[range(numEtas)]
@@ -851,7 +851,7 @@ def paintGrid(quats, etaOmeMaps,
851851

852852
def _meshgrid2d(x, y):
853853
"""
854-
A special-cased implementation of np.meshgrid, for just
854+
A special-cased implementation of num.meshgrid, for just
855855
two arguments. Found to be about 3x faster on some simple
856856
test arguments.
857857
"""
@@ -877,7 +877,7 @@ def _normalize_ranges(starts, stops, offset, ccw=False):
877877
if ccw:
878878
starts, stops = stops, starts
879879

880-
# results are in the range of [0, 2*np.pi]
880+
# results are in the range of [0, 2*num.pi]
881881
if not num.all(starts < stops):
882882
raise ValueError('Invalid angle ranges')
883883

hexrd/xrd/xrdutil.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,7 +4143,7 @@ def pullSpots(pd, detector_params, grain_params, reader,
41434143
f1 = rdr.read(nframes=len(oidx1), nskip=oidx1[0])
41444144
r2 = rdr.makeNew()
41454145
f2 = r2.read(nframes=len(oidx2), nskip=oidx2[0])
4146-
frames = num.zeros(sdims, dtype=f1.dtype)
4146+
frames = num.zeros((sdims[0], reader.get_nrows(), reader.get_ncols()), dtype=f1.dtype)
41474147
frames[:len(oidx1), :, :] = f1
41484148
frames[len(oidx1):, :, :] = f2
41494149
else:
@@ -4281,7 +4281,7 @@ def pullSpots(pd, detector_params, grain_params, reader,
42814281
# output dictionary
42824282
if save_spot_list:
42834283
w_dict = {}
4284-
w_dict['peakID'] = peakID
4284+
w_dict['peakId'] = peakId
42854285
w_dict['hkl'] = hkl
42864286
w_dict['dims'] = sdims
42874287
w_dict['points'] = ( angs[2] + d2r*ome_del,
@@ -4291,7 +4291,7 @@ def pullSpots(pd, detector_params, grain_params, reader,
42914291
w_dict['crd'] = xy_eval
42924292
w_dict['con'] = conn
42934293
w_dict['refl_ang_com'] = com_angs
4294-
if peakID >= 0:
4294+
if peakId >= 0:
42954295
w_dict['refl_xyo'] = (new_xy[0], new_xy[1], com_angs[2])
42964296
else:
42974297
w_dict['refl_xyo'] = tuple(num.nan*num.ones(3))
@@ -4321,7 +4321,7 @@ def pullSpots(pd, detector_params, grain_params, reader,
43214321
pass
43224322
iRefl += 1
43234323
pass
4324-
fid.close()
4324+
if filename is not None: fid.close()
43254325

43264326
return spot_list
43274327

0 commit comments

Comments
 (0)