def NSSHT(bw,points, rdata, mode="COS_SIN", RSphere=1.0, #This is the sphere that the points would #would be on if they were not constrained #to a cylinder harmtype='_{n}^{m}', returnIntermediates=False): """ given a bandwidth, and some real data collected at a number of data points this should return the Spherical Harmonic Transform using the Pseudo-Inverse""" indicies=SHT.genindicies_top(bw) harms=UnityWeight_COSSIN_Harmonics(indicies, harmtype=harmtype, RSphere=RSphere) M=matrixbuilder(harms,points) Minv=p_inv(M) tmp=dot(Minv,rdata) # Since the result is in a form # T,Tprime,T,Tprime we reorganize it # to be like (T,Tprime),(T,Tprime),... Q=[] for i in range(len(tmp)): if is_odd(i): Q.append((tmp[i-1],tmp[i])) cos_sinresult=zip(indicies,Q) if mode=="COS_SIN": if returnIntermediates: return cos_sinresult,tmp,M,Minv else: return cos_sinresult else: print "I have not thought of this yet, maybe later" raise Exception
def radialaxisplot(rvect, # a list of the radial positions resultx, resulty, resultz, fieldunits): print "radialaxisplot" #print "rvect:" #pprint(rvect) numZ=len(resultz[0]) numR=len(resultz) print "resultsz:(",numR,",",numZ,")" if not is_odd(numZ): print numZ centralZ=int((numZ-1)/2) centralR=int((numR-1)/2) centralRalongR=[resultz[i][centralZ] for i in range(numZ)] if fieldunits=="teslas": centralRalongR=1000.0*array(centralRalongR) fieldunits="milliteslas" pylab.plot(rvect,centralRalongR) pylab.title("$B_{z}$ field on $r$-axis") pylab.ylabel("$B_{z}$ ("+fieldunits+")") pylab.xlabel("$r$ ("+radialunits+")") pylab.show() centralRalongR=[resultx[i][centralZ] for i in range(numZ)] if fieldunits=="teslas": centralRalongR=1000.0*array(centralRalongR) fieldunits="milliteslas" pylab.plot(rvect,centralRalongR) pylab.title("$B_{x}$ field on $x$-axis") pylab.ylabel("$B_{x}$ ("+fieldunits+")") pylab.xlabel("$x$ ("+radialunits+")") pylab.show() centralRalongR=[resulty[i][centralZ] for i in range(numZ)] if fieldunits=="teslas": centralRalongR=1000.0*array(centralRalongR) fieldunits="milliteslas" pylab.plot(rvect,centralRalongR) pylab.title("$B_{y}$ field on $x$-axis") pylab.ylabel("$B_{y}$ ("+fieldunits+")") pylab.xlabel("$x$ ("+radialunits+")") pylab.show()
def centralaxisplot(zvect,resultz,fieldunits): print "centralaxisplot" numR=len(resultz) if not is_odd(numR): print numR #raise Exception centralR=int((numR-1)/2) #print centralR numZ=len(resultz[0]) centralZalongZ=resultz[centralR] if fieldunits=="teslas": centralZalongZ=1000.0*array(centralZalongZ) fieldunits="milliteslas" pylab.plot(zvect,centralZalongZ) pylab.title("$B_{z}$ field on $z$-axis") pylab.ylabel("$B_{z}$ ("+fieldunits+")") pylab.xlabel("$z$ ("+axialunits+")") pylab.show()