Ejemplo n.º 1
0
 def _fitRotation_lsq(Rparams, gI_spots, U,wavelength):
     
     out = []
     Rmat = Rotations.rotMatOfExpMap(Rparams)
     Fmat = dot(Rmat,U)
     for gI,spot in gI_spots:
         try:
             angCOM, angCOM_unc = spot.angCOM(useFit=True, getUncertainties=True)
         except RuntimeError:
             continue
         r_i = _fitR_residual(angCOM.flatten(),gI, Fmat, wavelength)
         if weighting:
             weight = uncertainty_analysis.propagateUncertainty(_fitR_residual, angCOM_unc, 1e-8,angCOM.flatten(),gI,Fmat,wavelength)
             #print 'Rotation using weight', weight, r_i, r_i/weight, angCOM_unc
         else:
             weight = 1.
         out.append(r_i/weight)
     return num.array(out)
Ejemplo n.º 2
0
        def _fitC(Cparams,gI_spots,wavelength):
            Cmat = vec_to_sym(Cparams)
            invCmat = inv(Cmat)
            out = []
            for gI, spot in gI_spots:
                try:
                    angCOM, angCOM_unc = spot.angCOM(useFit=True, getUncertainties=True)
                except RuntimeError:
                    continue
                r_i = _fitC_residual(angCOM.flatten(),gI, invCmat, wavelength)
                if weighting:

                    weight = uncertainty_analysis.propagateUncertainty(_fitC_residual, angCOM_unc, 1e-8,angCOM.flatten(),gI,invCmat,wavelength)
                    #print 'using weight', weight, r_i, r_i/weight, angCOM_unc
                else:
                    weight = 1
                out.append(r_i/weight)
            return num.array(out)
Ejemplo n.º 3
0
 def associateRecipVectors_w_Uncertainty(self, forceReRead = False):
     """
     pairs up gI from B.[h,k,l] to the measured rI for that [h,k,l].
     For use with rotation/strain refinement functions.
     stores results in self.gI_rIs
     """
     if self.vecs_associated_w_uncertainty == True and forceReRead == False:
         return self.gI_rIs_u_rIs
     'else do the association'
     self.fitGrainSpotUncertainties()
     wavelength = self.planeData.wavelength
     
     masterReflInfo = self.grainSpots
     hitRelfId = num.where(masterReflInfo['iRefl'] >= 0)[0]
     measHKLs = masterReflInfo['hkl'][hitRelfId, :]
     gIs = num.dot(self.bMat, measHKLs.T)
     
     gI_rIs_u_rIs=[]
     for i in range(len(hitRelfId)):
         Id = hitRelfId[i]
         spotId = masterReflInfo['iRefl'][Id]
         spot = self.spots._Spots__spots[spotId]
         try:
             angCOM, angCOM_unc = spot.angCOM(useFit=True, getUncertainties=True)
         except RuntimeError:
             continue
         mus     = num.hstack(angCOM).flatten()
         mu_uncs = num.hstack(angCOM_unc).flatten()
         
         meas_tth, meas_eta, meas_ome = mus
         rI = makeARecipVector([meas_tth,meas_eta,meas_ome], wavelength)
         u_rI = uncertainty_analysis.propagateUncertainty(makeARecipVector, mu_uncs, 1e-8, mus,wavelength )
         gI = gIs[:,i]
         gI_rIs_u_rIs.append([gI, rI, u_rI])
     
     self.vecs_associated_w_uncertainty = True
     self.gI_rIs_u_rIs = gI_rIs_u_rIs
     return gI_rIs_u_rIs