def mc_replicate_jvb(R0,U0,pVec0,detectorGeom,planeData,omeMin,omeMax,stdev = rad(.1),tweak = False): import detector import spotFinder import grain_wrap_precession as gw import grain as G import valUnits angles = MC_make_angles_jvb(R0,U0,pVec0,detectorGeom, planeData,omeMin,omeMax,stdev = stdev, tweak = tweak) spotsForFit = spotFinder.Spots(planeData, angles.T, detectorGeom, (omeMin, omeMax)) grain = G.Grain(spotsForFit, rMat=R0, pVec=pVec0, etaTol=valUnits.valWUnit('etaTol', 'angle', 1.0, 'degrees'), omeTol=valUnits.valWUnit('omeTol', 'angle', 1.0, 'degrees')) grain_wrap = gw.grainStrainAnalysis(grain) grain_wrap.assignUncertainties_angles(1e-4,1e-4,1e-2,1e-5,1e-5,1e-3) return grain_wrap, grain, angles
def mc_replicate(R0,U0,pVec0,detectorGeom,planeData,omeMin,omeMax,stdev = rad(.1),tweak = False): import detector import spotFinder import grain_wrap_precession as gw import grain as G import valUnits angles = MC_make_angles_(R0,U0,pVec0,detectorGeom, planeData,omeMin,omeMax,stdev = stdev, tweak = tweak) all_angs = [] for key in angles.keys(): angsol, unc = angles[key] all_angs.append(angsol) all_angs_ = num.array(all_angs) spotsForFit = spotFinder.Spots(planeData, all_angs_, detectorGeom, (omeMin, omeMax)) grain = G.Grain(spotsForFit, rMat=R0, pVec=pVec0, etaTol=valUnits.valWUnit('etaTol', 'angle', 1.0, 'degrees'), omeTol=valUnits.valWUnit('omeTol', 'angle', 1.0, 'degrees')) grain_wrap = gw.grainStrainAnalysis(grain) grain_wrap.assignUncertainties_angles(1e-4,1e-4,1e-2,1e-5,1e-5,1e-3) return grain_wrap, grain, all_angs_
def mc_replicate_nrb(R0,U0,pVec0,detectorGeom,planeData,omeMin,omeMax,tweak = False, stdev = rad(.1),angle_stdev_fact = 10): import detector import spotFinder import grain_wrap_precession as gw import grain as G import valUnits print 'making angles' angles,ang_dev = MC_make_angles_nrb(R0,U0,pVec0,detectorGeom, planeData,omeMin,omeMax,stdev = stdev, tweak = tweak) spotsForFit = spotFinder.Spots(planeData, angles, detectorGeom, (omeMin, omeMax)) grain = G.Grain(spotsForFit, rMat=R0, pVec=pVec0, etaTol=valUnits.valWUnit('etaTol', 'angle', 1.0, 'degrees'), omeTol=valUnits.valWUnit('omeTol', 'angle', 1.0, 'degrees')) grain_wrap = gw.grainStrainAnalysis(grain) #grain_wrap.assignUncertainties_angles(1e-4,1e-4,1e-2,1e-5,1e-5,1e-3) an1 = angle_stdev_fact*stdev an2 = angle_stdev_fact*stdev an3 = angle_stdev_fact*10*stdev st1 = .1*an1 st2 = .1*an2 st3 = .1*an3 grain_wrap.assignUncertainties_angles(an1,an2,an3,st1,st2,st3) return grain_wrap, grain, angles
def MC_make_angles_jvb(R,U,pVec,detectorGeom,planeData,omeMin,omeMax,tweak = False, stdev = rad(0.1)): wlen = planeData.get_wavelength() refCell = planeData.getLatticeOperators()['dparms'] refBmat = planeData.getLatticeOperators()['B'] laueGroup = 'd3d' tThMax = valUnits.valWUnit('tThMax', 'angle', detectorGeom.getTThMax(), 'radians') # set exclusions and strain mag in planeData planeData.exclusions = num.where(planeData.getTTh() > tThMax.getVal('radians'))[0] planeData.strainMag = 1e-2 # full set of symmetric HKLs subject to exclusions fHKLs = num.hstack(planeData.getSymHKLs()) bMat = refBmat qVec, qAng0, qAng1 = planeData.makeScatteringVectors(fHKLs, R, bMat, wlen) validAng0 = num.zeros(qVec.shape[1], dtype='bool') validAng1 = num.zeros(qVec.shape[1], dtype='bool') if hasattr(omeMin, '__len__'): for j in range(len(omeMin)): validAng0 = validAng0 | ( ( qAng0[2, :] >= omeMin[j].getVal('radians') ) & ( qAng0[2, :] <= omeMax[j].getVal('radians') ) ) validAng1 = validAng1 | ( ( qAng1[2, :] >= omeMin[j].getVal('radians') ) & ( qAng1[2, :] <= omeMax[j].getVal('radians') ) ) else: validAng0 = ( qAng0[2, :] >= omeMin.getVal('radians') ) & ( qAng0[2, :] <= omeMax.getVal('radians') ) validAng1 = ( qAng1[2, :] >= omeMin.getVal('radians') ) & ( qAng1[2, :] <= omeMax.getVal('radians') ) tmpAngs = num.hstack( [ qAng0[:, validAng0], qAng1[:, validAng1] ] ) tmpDG = detector.DetectorGeomGE(detectorGeom, pVec=pVec) tmpX, tmpY, tmpO = tmpDG.angToXYO(tmpAngs[0, :], tmpAngs[1, :], tmpAngs[2, :]) tmpTTh, tmpEta, tmpOme = detectorGeom.xyoToAng(tmpX, tmpY, tmpO) tmpAngs = num.vstack([tmpTTh, tmpEta, tmpOme]) if tweak: pert = numpy.random.normal(num.zeros(tmpAngs.shape), num.zeros(tmpAngs.shape)+stdev) tmpAngs = tmpAngs+pert spotAngs = tmpAngs return spotAngs