示例#1
0
    def _fitRotation_lsq(Rparams, gIs,angles0, U,wavelength):
        out = []
        Rmat = Rotations.rotMatOfExpMap(Rparams)
        Fmat = dot(Rmat,U)
        for i in range(len(gIs)):
            gI,angles = gIs[i], angles0[i]
            r_i = _fitR_residual(angles,gI, Fmat, wavelength)
            if weighting:
                weight = uncertainty_analysis.propagateUncertainty(_fitR_residual, weighting[i], 1e-8,angles,gI,Fmat,wavelength)
                maxiter = 100
                ct = 0
                while weight==0:
                    weight = uncertainty_analysis.propagateUncertainty(_fitR_residual, weighting[i], 1e-8,angles,gI,Fmat,wavelength)
                    ct+=1
                    if ct>=maxiter:
                        print 'zero weight error, i = ',i
                        weight = 1
                        break
                    
            else:
                weight = 1.
            out.append(r_i/weight)
            if weight == 0:
                print 'wefiht0',i,weighting[i],Fmat
            

        out = num.array(out)

    #    print out
        return out
示例#2
0
 def _fitC(Cparams,gIs,angles,wavelength):
     Cmat = gw.vec_to_sym(Cparams)
     invCmat = inv(Cmat)
     out = []
     for i in range(len(gIs)):
         gI = gIs[i]
         angCOM = angles[i] #, spot in gI_spots:
         r_i = _fitC_residual(angCOM,gI, invCmat, wavelength)
         if weighting:
             weight = uncertainty_analysis.propagateUncertainty(_fitC_residual, weighting[i], 1e-8,angCOM,gI,invCmat,wavelength)
         else:
             weight = 1
         out.append(r_i/weight)
     return num.array(out)