def iteration(self): weights_distance = self.distanceLine.text() weights_direc = self.directionLine.text() Pob = Weights(weights_distance, weights_direc) L, Lnames = getL(self.provisionals, self.obs, self.control) A = getA(self.provisionals, self.obs, self.control, self.unknowns) self.P = Pob.matrix(self.obs, A) X = (A.T * self.P * A)**-1 * A.T * self.P * L Xdict = Points("Solutions Dictionary") j = 0 for i in self.unknowns: Xdict[i] = X[j] j += 1 self.Xdict = Xdict self.V, posteriori, covarience_mat, precisi = precisions( A, X, self.P, L, self.obs, self.unknowns) self.provis = adjustProvisional(Xdict, self.provisionals, self.obs, self.unknowns) k = 0 for i in range(self.iterations): k += 1 provis = adjustProvisional(Xdict, self.provis, self.obs, self.unknowns) A, Xdict, provis, obs, control, unknowns, L = Iterate( provis, self.obs, self.control, self.unknowns, self.P) X = ((A.T * self.P * A)**-1) * A.T * self.P * L Xdict = Points("Solutions Dictionary") j = 0 for i in unknowns: Xdict[i] = X[j] j += 1 V, posteriori, self.covarience_mat, precisi = precisions( A, X, self.P, L, self.obs, unknowns) self.XOdict = Points("Orientations Dictionary") j = 0 for i in self.unknowns: if i[-1] == "o": self.XOdict[i] = X[j] j += 1 for i, o in self.XOdict.iteritems(): print i print o self.A = A self.L = L self.posterioriValue = posteriori self.V = V self.vtpv = float(self.V.T * self.P * self.V) self.covarience_mat = covarience_mat self.precisi = precisi
def iteration(self): weights_distance= self.distanceLine.text() weights_direc= self.directionLine.text() Pob= Weights(weights_distance, weights_direc) L,Lnames=getL(self.provisionals,self.obs,self.control) A=getA(self.provisionals,self.obs,self.control,self.unknowns) self.P=Pob.matrix(self.obs,A) X=(A.T*self.P*A)**-1*A.T*self.P*L Xdict=Points("Solutions Dictionary") j=0 for i in self.unknowns: Xdict[i]=X[j] j+=1 self.Xdict=Xdict self.V,posteriori,covarience_mat,precisi=precisions(A,X,self.P,L,self.obs,self.unknowns) self.provis=adjustProvisional(Xdict,self.provisionals,self.obs, self.unknowns) k=0 for i in range (self.iterations): k+=1 provis=adjustProvisional(Xdict,self.provis, self.obs, self.unknowns) A,Xdict,provis,obs,control,unknowns,L=Iterate(provis, self.obs, self.control, self.unknowns,self.P) X=((A.T*self.P*A)**-1)*A.T*self.P*L Xdict=Points("Solutions Dictionary") j=0 for i in unknowns: Xdict[i]=X[j] j+=1 V,posteriori,self.covarience_mat,precisi=precisions(A,X,self.P,L,self.obs,unknowns) self.XOdict=Points("Orientations Dictionary") j=0 for i in self.unknowns: if i[-1]=="o": self.XOdict[i]=X[j] j+=1 for i,o in self.XOdict.iteritems(): print i print o self.A=A self.L=L self.posterioriValue=posteriori self.V=V self.vtpv=float(self.V.T*self.P*self.V) self.covarience_mat=covarience_mat self.precisi=precisi
def writeOut(self): fileName = QFileDialog.getSaveFileName(self, "Open Points File", "", "Text File (*.txt);;", "") file = open(fileName, "w") file.write("________CONTROL POINTS________\n\n") for i, j in self.control.iteritems(): file.write(i + ":\n" + str(j) + "\n") file.write("________UNKNOWNS________\n\n") file.write(str(self.unknowns) + '\n\n') file.write( "_______________________________________ CALCULATIONS _______________________________________ \n\n\n\n" ) k = 0 for i in range(self.iterations): k += 1 provis = adjustProvisional(self.Xdict, self.provis, self.obs, self.unknowns) A, Xdict, provis, obs, control, unknowns, L = Iterate( provis, self.obs, self.control, self.unknowns, self.P) X = ((A.T * self.P * A)**-1) * A.T * self.P * L Xdict = Points("Solutions Dictionary") j = 0 for i in unknowns: Xdict[i] = X[j] j += 1 V, posteriori, covarience_mat, precisi = precisions( A, X, self.P, L, obs, unknowns) file.write("________ITERATION: " + str(k) + " ________\n\n") if float(round(float((A.T * self.P * V).T * (A.T * self.P * V)), 6)) == 0.: file.write( "____________________________________________________\n\nCalculation check 'A.tPV' successful\n---------------------------------------------\n" ) else: file.write( "Calculation check 'A.tPV' unsuccessful to 6 dec places\n\n" ) # V,posteriori,covarience_mat,precisions file.write("________'V.TPV'________\n\n") file.write(str(V.T * self.P * V) + '\n\n') file.write("________Posteriori________\n\n") file.write(str(posteriori) + '\n\n') # file.write("________Covarience Matrix________\n\n") # COVARIENCE MATRIX # file.write(str(covarience_mat)+'\n\n') file.write("________Precisions of Unknowns ________\n\n") for i, j in precisi.iteritems(): file.write(i + ":\n" + str(round(float(j), 3)) + "\n\n") check = globalCheck(provis, control, V, obs, unknowns, Xdict) file.write("________Global Check________\n\n") for i, j in check.iteritems(): file.write(i + ":\n" + str(j) + "\n") file.write("________________---- END OF ITERATION " + str(k) + " ----____________\n\n") file.write( "_______________________________________________________________________\n\n" ) # showGraph(N,provisionals,control) file.write("________FINAL COORDINATES________\n\n") for i, j in provis.iteritems(): file.write(i + ":\n" + str(j) + "\n\n") file.write( "________X Solution Vector, With distances in meters and directions in seconds ________\n\n" ) for i, j in Xdict.iteritems(): file.write(i + ":\n" + str(round(float(j), 3)) + "\n\n")
def writeOut(self): fileName = QFileDialog.getSaveFileName(self, "Open Points File", "", "Text File (*.txt);;", "") file = open(fileName, "w") file.write("________CONTROL POINTS________\n\n") for i,j in self.control.iteritems(): file.write(i +":\n"+ str(j)+"\n") file.write("________UNKNOWNS________\n\n") file.write(str(self.unknowns)+'\n\n') file.write("_______________________________________ CALCULATIONS _______________________________________ \n\n\n\n") k=0 for i in range (self.iterations): k+=1 provis=adjustProvisional(self.Xdict,self.provis, self.obs, self.unknowns) A,Xdict,provis,obs,control,unknowns,L=Iterate(provis, self.obs, self.control, self.unknowns,self.P) X=((A.T*self.P*A)**-1)*A.T*self.P*L Xdict=Points("Solutions Dictionary") j=0 for i in unknowns: Xdict[i]=X[j] j+=1 V,posteriori,covarience_mat,precisi=precisions(A,X,self.P,L,obs,unknowns) file.write("________ITERATION: "+str(k)+" ________\n\n") if float(round(float((A.T*self.P*V).T*(A.T*self.P*V)),6))==0.: file.write("____________________________________________________\n\nCalculation check 'A.tPV' successful\n---------------------------------------------\n") else: file.write("Calculation check 'A.tPV' unsuccessful to 6 dec places\n\n") # V,posteriori,covarience_mat,precisions file.write("________'V.TPV'________\n\n") file.write(str(V.T*self.P*V)+'\n\n') file.write("________Posteriori________\n\n") file.write(str(posteriori)+'\n\n') # file.write("________Covarience Matrix________\n\n") # COVARIENCE MATRIX # file.write(str(covarience_mat)+'\n\n') file.write("________Precisions of Unknowns ________\n\n") for i,j in precisi.iteritems(): file.write(i +":\n"+ str(round(float(j),3))+"\n\n") check=globalCheck(provis,control,V,obs,unknowns,Xdict) file.write("________Global Check________\n\n") for i,j in check.iteritems(): file.write(i +":\n"+ str(j)+"\n") file.write("________________---- END OF ITERATION "+str(k)+" ----____________\n\n") file.write("_______________________________________________________________________\n\n") # showGraph(N,provisionals,control) file.write("________FINAL COORDINATES________\n\n") for i,j in provis.iteritems(): file.write(i +":\n"+ str(j)+"\n\n") file.write("________X Solution Vector, With distances in meters and directions in seconds ________\n\n") for i,j in Xdict.iteritems(): file.write(i +":\n"+ str(round(float(j),3))+"\n\n")