def pull_spots(self, grain_id, grain_params, iteration): # need to calc panel dims on the fly xdim = self._p['pixel_pitch'][1] * self._p['ncols'] ydim = self._p['pixel_pitch'][0] * self._p['nrows'] panel_dims = [(-0.5*xdim, -0.5*ydim), ( 0.5*xdim, 0.5*ydim)] return pullSpots( self._p['plane_data'], self._p['detector_params'], grain_params, self._reader, distortion=self._p['distortion'], eta_range=self._p['eta_range'], ome_period=self._p['omega_period'], eta_tol=self._p['eta_tol'][iteration], ome_tol=self._p['omega_tol'][iteration], tth_tol=self._p['tth_tol'][iteration], pixel_pitch=self._p['pixel_pitch'], panel_dims=panel_dims, panel_buff=self._p['panel_buffer'], npdiv=self._p['npdiv'], threshold=self._p['threshold'], doClipping=False, filename=self._p['spots_stem'] % grain_id, )
def pull_spots(self, grain_id, grain_params, iteration): return pullSpots( self._p['plane_data'], self._p['detector_params'], grain_params, self._reader, distortion=self._p['distortion'], eta_range=self._p['eta_range'], ome_period=self._p['omega_period'], eta_tol=self._p['eta_tol'][iteration], ome_tol=self._p['omega_tol'][iteration], tth_tol=self._p['tth_tol'][iteration], panel_buff=self._p['panel_buffer'], npdiv=self._p['npdiv'], threshold=self._p['threshold'], doClipping=False, filename=self._p['spots_stem'] % grain_id, )
def pull_spots(self, grain_id, grain_params, iteration, output_hdf5=False): # need to calc panel dims on the fly xdim = self._p['pixel_pitch'][1] * self._p['ncols'] ydim = self._p['pixel_pitch'][0] * self._p['nrows'] panel_dims = [(-0.5 * xdim, -0.5 * ydim), (0.5 * xdim, 0.5 * ydim)] return pullSpots(self._p['plane_data'], self._p['detector_params'], grain_params, self._reader, distortion=self._p['distortion'], eta_range=self._p['eta_range'], ome_period=self._p['omega_period'], eta_tol=self._p['eta_tol'][iteration], ome_tol=self._p['omega_tol'][iteration], tth_tol=self._p['tth_tol'][iteration], pixel_pitch=self._p['pixel_pitch'], panel_dims=panel_dims, panel_buff=self._p['panel_buffer'], npdiv=self._p['npdiv'], threshold=self._p['threshold'], doClipping=False, filename=self._p['spots_stem'] % grain_id, output_hdf5=output_hdf5)
phi, n = rot.angleAxisOfRotMat(rot.rotMatOfQuat(qbar)) if have_progBar: widgets = [Bar('>'), ' ', ETA(), ' ', ReverseBar('<')] pbar = ProgressBar(widgets=widgets, maxval=len(qbar.T)).start() pass print "pulling spots for %d orientations..." % len(qbar.T) for iq, quat in enumerate(qbar.T): if have_progBar: pbar.update(iq) exp_map = phi[iq] * n[:, iq] grain_params = np.hstack( [exp_map.flatten(), 0., 0., 0., 1., 1., 1., 0., 0., 0.]) sd = xrdutil.pullSpots(pd, detector_params, grain_params, reader, filename=pull_filename % iq, eta_range=etaRange, ome_period=ome_period, eta_tol=eta_tol, ome_tol=ome_tol, threshold=pthresh, tth_tol=tth_tol, distortion=distortion) pass if have_progBar: pbar.finish() pass pass # condidional on pull spots pass
use_tth_max = parser.get('pull_spots', 'use_tth_max') if use_tth_max.strip() == '1' or use_tth_max.strip().lower() == 'true': excl = np.zeros_like(pd.exclusions, dtype=bool) pd.exclusions = excl excl = pd.getTTh() > detector.getTThMax() pd.exclusions = excl pass phi, n = rot.angleAxisOfRotMat(rot.rotMatOfQuat(qbar)) if have_progBar: widgets = [Bar('>'), ' ', ETA(), ' ', ReverseBar('<')] pbar = ProgressBar(widgets=widgets, maxval=len(qbar.T)).start() pass print "pulling spots for %d orientations..." %len(qbar.T) for iq, quat in enumerate(qbar.T): if have_progBar: pbar.update(iq) exp_map = phi[iq]*n[:, iq] grain_params = np.hstack([exp_map.flatten(), 0., 0., 0., 1., 1., 1., 0., 0., 0.]) sd = xrdutil.pullSpots(pd, detector_params, grain_params, reader, filename=pull_filename %iq, eta_range=etaRange, ome_period=ome_period, eta_tol=eta_tol, ome_tol=ome_tol, threshold=pthresh, tth_tol=tth_tol, distortion=distortion) pass if have_progBar: pbar.finish() pass pass # condidional on pull spots pass
"tVec_c[0]\ttVec_c[1]\ttVec_c[2]\t" + \ "vInv_s[0]\tvInv_s[1]\tvInv_s[2]\tvInv_s[4]*sqrt(2)\tvInv_s[5]*sqrt(2)\tvInv_s[6]*sqrt(2)\t" + \ "ln(V[0,0])\tln(V[1,1])\tln(V[2,2])\tln(V[1,2])\tln(V[0,2])\tln(V[0,1])" # loop over grains from previous fit for grainID in range(n_grains): start = time.clock() # time this print "fitting %d" %grainID # grain_params = gp_table[grainID, 3:15] # fid = open(filename %grainID, 'w') sd = xrdutil.pullSpots(pd, detector_params, grain_params, reader, distortion=(dFunc, dParams), eta_range=etaRange, ome_period=ome_period, tth_tol=tth_tol, eta_tol=eta_tol, ome_tol=ome_tol, panel_buff=[10, 10], npdiv=2, threshold=threshold, doClipping=False, filename=fid) fid.close() # strain fitting for i in range(2): gtable = np.loadtxt(filename %grainID) # load pull_spots output table idx0 = gtable[:, 0] >= 0 # select valid reflections # pred_ome = gtable[:, 6] if np.sign(ome_delta) < 0: idx_ome = np.logical_and(pred_ome < d2r*(ome_start + 2*ome_delta), pred_ome > d2r*(ome_stop - 2*ome_delta)) else: