def simulateGrain(self, rMat=numpy.eye(3), vMat=numpy.r_[1., 1., 1., 0., 0., 0.], planeData=None, detector=None, omegaRanges=[OMEGA_PERIOD], output=None): """ Simulate a grain with choice of active material """ if planeData is None: planeData = self.activeMaterial.planeData if detector is None: detector = self.detector dummySpots = SPT.Spots(planeData, None, detector, omegaRanges) sg = G.Grain(dummySpots, rMat=rMat, vMat=vMat) if output is not None: if isinstance(output, file): fid = output elif isinstance(output, str): fid = open(output, 'w') else: raise RuntimeError("output must be a file object or string") sg.findMatches(filename=fid) return sg
def makeRandGrains(numGrains, omegaMM, detectorGeom): spotsDummy = Spots(planeData, None, detectorGeom, omegaMM) if numGrains == 1: rMats = num.atleast_3d(num.eye(3)).T else: quats = num.atleast_2d(ors.Quat.getRandQuat(n=numGrains)).T rMats = ors.quatToMat(quats) gList = [] for rMat in rMats: g = grain.Grain(spotsDummy, rMat=rMat) gList.append(g) return gList
def refine_grains(self, minCompl, nSubIter=3, doFit=False, etaTol=valunits.valWUnit('etaTol', 'angle', 1.0, 'degrees'), omeTol=valunits.valWUnit('etaTol', 'angle', 1.0, 'degrees'), fineDspTol=5.0e-3, fineEtaTol=valunits.valWUnit('etaTol', 'angle', 0.5, 'degrees'), fineOmeTol=valunits.valWUnit('etaTol', 'angle', 0.5, 'degrees')): """ refine a grain list """ # refine grains formally using a multi-pass refinement nGrains = self.rMats.shape[0] grainList = [] for iG in range(nGrains): #indexer.progress_bar(float(iG) / nGrains) grain = G.Grain(self.spots_for_indexing, rMat=self.rMats[iG, :, :], etaTol=etaTol, omeTol=omeTol, claimingSpots=False) if grain.completeness > minCompl: for i in range(nSubIter): grain.fit() s1, s2, s3 = grain.findMatches(etaTol=etaTol, omeTol=omeTol, strainMag=fineDspTol, updateSelf=True, claimingSpots=False, doFit=doFit, testClaims=True) if grain.completeness > minCompl: grainList.append(grain) pass pass pass self.grainList = grainList self._fitRMats = numpy.array( [self.grainList[i].rMat for i in range(len(grainList))]) return
def makeRandGrains(numGrains, omegaMM, detectorGeom): spotsDummy = Spots(planeData, None, detectorGeom, omegaMM) if numGrains == 1: import orientations as ors r = ors.RotInv(3.08805198 - num.pi, 0., 1., 0.).toMatrix() # r = num.eye(3) rMats = num.atleast_3d(r).T else: quats = num.atleast_2d(ors.Quat.getRandQuat(n=numGrains)).T rMats = ors.quatToMat(quats) gList = [] for rMat in rMats: g = grain.Grain(spotsDummy, rMat=rMat) gList.append(g) return gList
hklListForIndex, iPhase=planeData.phaseID, nsteps=720, minCompleteness=0.70, minPctClaimed=0.75, friedelOnly=False, dspTol=None, etaTol=etaTol, omeTol=omeTol, debug=True, doMultiProc=opts.doMultiProc, doRefinement=False) print 'found %d grains' % (rMat.shape[0]) # etaTol = valunits.valWUnit("etaTol","ANGLE",0.0625,"degrees") # omeTol = valunits.valWUnit("omeTol","ANGLE",0.2500,"degrees") firstGrain = grain.Grain(spotsForFit, rMat=rMat[0, :, :], etaTol=etaTol, omeTol=omeTol) firstGrain.fit() reflInfo, fPairs, completeness = firstGrain.findMatches( updateSelf=True) print 'after fit, completeness is %g' % (completeness) ###################################################################### # add more tests here as see fit # return