def getMohoEvePA(t): moho = tk.Moho.eph(t)[0][:2] eve = tk.Eve.eph(t)[0][:2] moho = moho / norm(moho) eve = eve / norm(eve) return degrees(arccos(moho.dot(eve)))
def getMohoKerbinPA(t): moho = tk.Moho.eph(t)[0][:2] kerbin = tk.Kerbin.eph(t)[0][:2] moho = moho / norm(moho) kerbin = kerbin / norm(kerbin) return degrees(arccos(moho.dot(kerbin)))
def view_filter(h, fp=None, fs=None): '''view filter''' w, H = signal.freqz(h, 1) H_phase = pl.unwrap([pl.degrees(cmath.phase(H[i])) for i in range(len(H))], 180) H = 20 * pl.log10(abs(H[:])) x = range(0, len(h)) step = pl.cumsum(h) pl.figure(figsize=(16, 6.6), dpi=80) pl.subplot(221) pl.stem(x, h) pl.ylabel('Amplitude') pl.xlabel(r'n (samples)') pl.title(r'Impulse response') pl.text(0.2, 0.7, 'N_taps = {0}'.format(len(h))) pl.subplot(222) pl.stem(x, step) pl.ylabel('Amplitude') pl.xlabel(r'n (samples)') pl.title(r'Step response') pl.subplot(223) pl.plot(w / (2.0 * pl.pi), H) pl.ylabel('Magnitude (db)') pl.xlabel(r'Normalized Frequency (x$\pi$rad/sample)') pl.title(r'Frequency response') if fp != None: pl.axvline(fp, linewidth=1, color='k', ls='-') if fs != None: pl.axvline(fs, linewidth=1, color='k', ls='-') pl.subplot(224) pl.plot(w / (2.0 * pl.pi), H_phase) pl.ylabel('Phase (radians)') pl.xlabel(r'Normalized Frequency (Hz)') pl.title(r'Phase response')
def view_filter(h, fp=None, fs=None): '''view filter''' w, H = signal.freqz(h,1) H_phase = pl.unwrap([pl.degrees(cmath.phase(H[i])) for i in range(len(H))], 180) H = 20 * pl.log10 (abs(H[:])) x = range(0,len(h)) step = pl.cumsum(h) pl.figure(figsize=(16, 6.6), dpi=80) pl.subplot(221) pl.stem(x, h) pl.ylabel('Amplitude') pl.xlabel(r'n (samples)') pl.title(r'Impulse response') pl.text(0.2, 0.7, 'N_taps = {0}'.format(len(h))) pl.subplot(222) pl.stem(x, step) pl.ylabel('Amplitude') pl.xlabel(r'n (samples)') pl.title(r'Step response') pl.subplot(223) pl.plot(w/(2.0*pl.pi), H) pl.ylabel('Magnitude (db)') pl.xlabel(r'Normalized Frequency (x$\pi$rad/sample)') pl.title(r'Frequency response') if fp != None: pl.axvline(fp, linewidth=1, color='k', ls='-') if fs != None: pl.axvline(fs, linewidth=1, color='k', ls='-') pl.subplot(224) pl.plot(w/(2.0*pl.pi), H_phase) pl.ylabel('Phase (radians)') pl.xlabel(r'Normalized Frequency (Hz)') pl.title(r'Phase response')
def __init__(self,celestialFrom,celestialTo,timeRange,multiplier=86400.0): self.figure = figure(figsize=(8,8)) self.axis = self.figure.gca(projection="rectilinear")#,aspect='equal') X = [] Y = [] for t in timeRange: t *= multiplier ephFrom = celestialFrom.eph(t) ephTo= celestialTo.eph(t) pFrom = ephFrom[0] / norm(ephFrom[0]) pTo = ephTo[0] / norm(ephTo[0]) print pFrom print pTo print "ye",t angle = degrees(arccos(pFrom.dot(pTo))) X.append(t/multiplier) Y.append(angle) self.axis.plot(X,Y)
def generate_datafile(name,departures,depart_planet,arrive_planet,errors=0): f = open(name,'w') last = departures[-1] lasty = int(last[0] / 60.0 / 60.0 / 24.0 / 365.0) inacc = 0.0 for departure in departures: if departure[1]: inacc += 1.0 f.write("// Phase angles for the next %i years for %s - %s Hohmann transfers\n"%(lasty,depart_planet.name,arrive_planet.name)) f.write("// Calculated using the KSP Mission Control toolkit\n") f.write("// Angles are valid for Kerbal Space Program 0.19\n") f.write("// Total windows: %i\n"%len(departures)) f.write("// Inaccuracies during calculation: %i (%i%%)\n\n"%(inacc,inacc / len(departures) * 100)) f.write("UT Departure\tPhase angle\tDate time\tAccurate (Error in seconds)\n") for departure in departures: accurate = departure[1] if accurate == 0: accurate = "Yes" else: accurate = str(accurate) departure = departure[0] e1 = depart_planet.eph(departure)[0] e2 = arrive_planet.eph(departure)[0] e1 /= norm(e1) e2 /= norm(e2) PA = degrees(arccos(e1.dot(e2))) * sign(cross(e1,e2)[2]) years = floor(departure/60.0/60.0/24.0/365.0)+1 days = floor((departure/60.0/60.0/24.0)%365.0)+1 f.write("%f\t%f\tYear %i, Day %i\t%s\n"%(departure,PA,years,days,accurate)) f.close()
crystal=reflectivity.Sample(Sub, layer1) crystal.set_Miller(R) crystal.calc_g0_gH(Energy) thBragg= float(layer1.calc_Bragg_angle(Energy).subs(layer1.structure.subs).evalf()) angle=pl.linspace(0.988, 1.012,501)*thBragg crystal.calc_reflectivity(angle, Energy) layer1.calc_amplitudes(angle, Energy) Sub.calc_amplitudes(angle, Energy) XRl = layer1.XR XRs = Sub.XR XT = layer1.XT crystal.print_values(angle, Energy) pl.plot(data[:,0], data[:,1], label='GID_sl', color='red') # pl.plot(angle-thBragg,abs(XT)**2-1) pl.plot(pl.degrees(angle-thBragg),abs(XRl)**2, label='dynXRD', color='black') # pl.plot(angle-thBragg,1 - abs(XT)**2 - abs(XRl)**2) pl.xlabel('Angle (degrees)') pl.ylabel('Reflectivity') pl.xlim(-0.1,0.1) pl.yscale('log') pl.rc('font', size=18) pl.legend(loc="upper left", prop={'size':19}) pl.savefig('pics/test7.eps') pl.show()
thBragg = float( layer1.calc_Bragg_angle(Energy).subs(layer1.structure.subs).evalf()) angle = pl.linspace(0.9955, 1.0045, 501) * thBragg crystal.calc_reflectivity(angle, Energy) layer1.calc_amplitudes(angle, Energy) Sub.calc_amplitudes(angle, Energy) XRl = layer1.XR XRs = Sub.XR XT = layer1.XT crystal.print_values(angle, Energy) pl.plot(data[:, 0], data[:, 1], label='GID_sl', color='red') # pl.plot(angle-thBragg,abs(XT)**2-1) pl.plot(pl.degrees(angle - thBragg), abs(XRl)**2, label='dynXRD', color='black') # pl.plot(angle-thBragg,1 - abs(XT)**2 - abs(XRl)**2) pl.xlabel('Angle (degrees)') pl.ylabel('Reflectivity') pl.xlim(-0.1, 0.1) pl.yscale('log') pl.rc('font', size=18) pl.legend(loc="upper left", prop={'size': 19}) pl.savefig('pics/test9.eps') pl.show()
Sub.calc_orientation(v_par, v_perp) layer1 = reflectivity.Epitaxial_Layer(struct, thickness) layer1.calc_orientation(v_par, v_perp) crystal = reflectivity.Sample(Sub, layer1) crystal.set_Miller(R) crystal.calc_g0_gH(Energy) thBragg = float( layer1.calc_Bragg_angle(Energy).subs(layer1.structure.subs).evalf()) angle = pl.linspace(0.99, 1.01, 501) * thBragg crystal.calc_reflectivity(angle, Energy) layer1.calc_amplitudes(angle, Energy) Sub.calc_amplitudes(angle, Energy) XRl = layer1.XR XRs = Sub.XR XT = layer1.XT crystal.print_values(angle, Energy) pl.plot(data[:, 0], data[:, 1]) # pl.plot(angle-thBragg,abs(XT)**2) pl.plot(pl.degrees(angle - thBragg), abs(XRl)**2) # pl.plot(angle-thBragg,1 - abs(XT)**2 - abs(XRl)**2) pl.xlabel('Angle (degrees)') pl.ylabel('Reflectivity') pl.xlim(-0.2, 0.2) pl.ylim(1e-9, 1e-2) pl.yscale('log') pl.show()
def eph2D(self,epoch): if self.ref == None: return ([0,0,0],[0,0,0]) dt = epoch-self.epoch #print "dT",dt # Step 1 - Determine mean anomaly at epoch if self.e == 0: M = self.M0 + dt * sqrt(self.ref.mu / self.a**3) M %= PI2 E = M ta = E r3 = (self.h**2/self.ref.mu) rv = r3 * array([cos(ta),sin(ta),0]) v3 = self.ref.mu / self.h vv = v3 * array([-sin(ta),self.e+cos(ta),0]) return (rv,vv) if self.e < 1: if epoch == self.epoch: M = self.M0 else: M = self.M0 + dt * sqrt(self.ref.mu / self.a**3) M %= PI2 # Step 2a - Eccentric anomaly try: E = so.newton(lambda x: x-self.e * sin(x) - M,M) except RuntimeError: # Debugging a bug here, disregard print "Eccentric anomaly failed for",self.obj.name print "On epoch",epoch print "Made error available at self.ERROR" self.ERROR = [lambda x: x-self.e * sin(x) - M,M] raise # Step 3a - True anomaly, method 1 ta = 2 * arctan2(sqrt(1+self.e)*sin(E/2.0), sqrt(1-self.e)*cos(E/2.0)) #print "Ta:",ta # Method b is faster cosE = cos(E) ta2 = arccos((cosE - self.e) / (1-self.e*cosE)) #print "e",self.e #print "M",M #print "E",E #print "TA:",ta #print "T2:",ta2 # Step 4a - distance to central body (eccentric anomaly). r = self.a*(1-self.e * cos(E)) # Alternative (true anomaly) r2 = (self.a*(1-self.e**2) / (1.0 + self.e * cos(ta))) # Things get crazy #h = sqrt(self.a*self.ref.mu*(1-self.e**2)) r3 = (self.h**2/self.ref.mu)*(1.0/(1.0+self.e*cos(ta))) #print "R1:",r #print "R2:",r2 #print "R3:",r3 rv = r3 * array([cos(ta),sin(ta),0]) #v1 = sqrt(self.ref.mu * (2.0/r - 1.0/self.a)) #v2 = sqrt(self.ref.mu * self.a) / r v3 = self.ref.mu / self.h #meanmotion = sqrt(self.ref.mu / self.a**3) #v2 = sqrt(self.ref.mu * self.a)/r #print "v1",v1 #print "v2",v2 #print "v3",v3 #print "mm",meanmotion # Velocity can be calculated from the eccentric anomaly #vv = v1 * array([-sin(E),sqrt(1-self.e**2) * cos(E),0]) # Or from the true anomaly (this one has an error..) #vv = sqrt(self.ref.mu * self.a)/r * array([-sin(ta),self.e+cos(ta),0]) vv = v3 * array([-sin(ta),self.e+cos(ta),0]) #print "rv",rv #print "vv",vv #print "check",E,-sin(E),v1*-sin(E) #print "V1:",vv #print "V2:",vv2 return (rv,vv) elif self.e > 1: # Hyperbolic orbits # Reference: Stephen Kemble: Interplanetary Mission Analysis and Design, Pg 220-221 M = self.M0 + dt * sqrt(-(self.ref.mu / self.a**3)) #print "M0",self.M0 #print "M",M #print "M",M #print "M0",self.M0 # Step 2b - Hyperbolic eccentric anomaly #print "Hyperbolic mean anomaly:",M F = so.newton(lambda x: self.e * sinh(x) - x - M,M,maxiter=1000) #F = -F H = M / (self.e-1) #print "AAAA"*10 #print "F:",F #print "H:",H #F=H #print "Hyperbolic eccentric anomaly:",F # Step 3b - Hyperbolic true anomaly? # This is wrong prooobably #hta = arccos((cosh(F) - self.e) / (1-self.e*cosh(F))) #hta = arccos((self.e-cosh(F)) / (self.e*cosh(F) - 1)) # TÄSSÄ ON BUGI hta = arccos((cosh(F) - self.e) / (1 - self.e*cosh(F))) hta2 = 2 * arctan2(sqrt(self.e+1)*sinh(F/2.0),sqrt(self.e-1)*cosh(F/2.0)) hta3 = 2 * arctan2(sqrt(1+self.e)*sinh(F/2.0),sqrt(self.e-1)*cosh(F/2.0)) hta4 = 2 * arctan2(sqrt(self.e-1)*cosh(F/2.0),sqrt(1+self.e)*sinh(F/2.0)) #print "Hyperbolic true anomaly:",degrees(hta) # This is wrong too #hta2 = 2 * arctan2(sqrt(1+self.e)*sin(F/2.0), sqrt(1-self.e)*cos(F/2.0)) if M == self.M0: print "HTA1:",degrees(hta) print "HTA2:",degrees(hta2) print "HTA3:",degrees(hta3) print "HTA4:",degrees(hta4) # According to http://mmae.iit.edu/~mpeet/Classes/MMAE441/Spacecraft/441Lecture17.pdf # this is right.. hta = hta2 #print cos(hta) #print cosh(hta) #####hta = arctan(sqrt((self.e-1.0)/self.e+1.0) * tanh(F/2.0)) / 2.0 #print "Mean anomaly:",M #print "Hyperbolic eccentric anomaly:",F #print "HTA:",hta #raise # Step 4b - Distance from central body? # Can calculate it from hyperbolic true anomaly.. #p = self.a*(1-self.e**2) #r = p / (1+self.e * cos(hta)) r3 = (self.h**2/self.ref.mu)*(1.0/(1.0+self.e*cos(hta))) v3 = self.ref.mu / self.h # But it's faster to calculate from eccentric anomaly #r = self.a*(1-self.e * cos(F)) #print "Hyper r1:",r #print "Hyper r2:",r2 rv = r3 * array([cos(hta),sin(hta),0]) #http://en.wikipedia.org/wiki/Hyperbola #rv = array([ r * sin(hta),-self.a*self.e + r * cos(hta), 0]) #sinhta = sin(hta) #coshta = cos(hta) #print self.ref.mu,r,self.a,hta #vv = sqrt(self.ref.mu *(2.0/r - 1.0/self.a)) * array([-sin(hta),self.e+cos(hta),0]) vv = v3 * array([-sin(hta),self.e+cos(hta),0]) return (rv,vv)
def initFromStateVectors(self,epoch,pV,vV): self.epoch = epoch # 1) Calculate auxilary vector h hV = cross(pV,vV) # 2) Normalize position,velocity, specific angular momentum, calculate radial velocity p = linalg.norm(pV) v = linalg.norm(vV) h = linalg.norm(hV) print "H:",h radv = pV.dot(vV) / p hVu = hV / h pVu = pV / p nV = cross(array([0,0,1]),hV) n = linalg.norm(nV) if n == 0: nVu = array([0,0,0]) else: nVu = nV/n # 3) Calculate inclination #self.i = arccos(hV[2]/h) self.i = arcsin(linalg.norm(cross(array([0,0,1]),hVu))) print "i1",self.i print "RADVEL",radv self.i = arccos(array([0,0,1]).dot(hV)/h) #if radv < 0: # self.i = PI2 - self.i print "i2",self.i # 4) Calculate node line # 5) Calculate longitude of ascending node = right ascension of ascending node ''' if self.i == 0: self.lan=0 elif nV[1] >= 0: self.lan = arccos(nV[0] / n) else: self.lan = PI2 - arccos(nV[0] / n) ''' if self.i == 0: self.lan = 0 else: self.lan = arcsin(cross(array([1,0,0]),nVu).dot(array([0,0,1]))) print "lan1",self.lan self.lan = arccos(array([1,0,0]).dot(nV)/n) if nV[1] < 0: self.lan = PI2-self.lan print "lan2",self.lan # 6) Eccentricity vector #eV = (1.0 / self.ref.mu)*((v**2 - (self.ref.mu / p))*pV - radv*vV) #eV2 = (1.0 / self.ref.mu) * ( hV - self.ref.mu * (pV/p)) #eV3 = hV/self.ref.mu - (pV/p) # Source: cdeagle eV = cross(vV,hV)/self.ref.mu - pVu #print "eV1:",eV,linalg.norm(eV) #print "eV2:",eV2,linalg.norm(eV2) #print "eV3:",eV3,linalg.norm(eV3) print "eV3:",eV,linalg.norm(eV) self._e = linalg.norm(eV) #eVu = eV / self.e print "h",h print "u",self.ref.mu print "v",v print "r",p print "alte:",sqrt(1+(h**2/self.ref.mu**2)*(v**2-(2*self.ref.mu)/p)**2) # 7) Argument of perigree ''' if self.e == 0: self.aop = 0 elif self.i == 0: self.aop = arccos(eV[0] / self.e) elif eV[2] >= 0: print "AOP AOP AOP" #self.aop = arccos(nV.dot(eV) / (n*self.e)) print cross(nV,eV).dot(hV) self.aop = arcsin(cross(nVu,eVu).dot(hVu)) #self.aop = arccos(n*self.e) else: self.aop = PI2 - arccos(nV.dot(eV) / (n*self.e)) ''' #CDEagle method # TODO CHECK how KSP handles this. if self.e == 0: self.aop = 0 elif self.i == 0 and self.e != 0: #self.aop = arccos(eV[0] / self.e) #self.aop = arctan2(eV[1],eV[0]) self.aop = arccos(array([1,0,0]).dot(eV) / self.e) print eV if eV[2] < 0: #self.aop = -self.aop self.aop = PI2-self.aop #print "BOOM",eV #if eV[2] < 0: # print "BAM N***A" # self.aop = PI2 - self.aop elif self.i == 0 and self.e == 0: #raise AttributeError("Perfectly circular orbits are not supported atm") self.aop = 0 else: #self.aop = arcsin(cross(nVu,eVu).dot(hVu)) self.aop = arccos(nV.dot(eV)/(n*self.e)) if eV[2] < 0: self.aop = PI2-self.aop # 8) Semi major axis aE = v**2/2.0 - self.ref.mu / p self._a = -self.ref.mu / (2*aE) print "Old method for semi-major",self.a self._a = h**2 / (self.ref.mu * (1-self.e**2)) print "New method for semi-major",self.a #if self.e > 1: # self._a = h**2 / (self.ref.mu * (self.e**2 - 1)) if self.e == 0: if self.i == 0: #TODO update document to this print "JEA JEA JEA JEA"*10 ta = arccos(array([1,0,0]).dot(pV) / p) if pV[1] < 0: # Vallado pg. 111 ta = PI2 - ta else: #TODO VERIFY THIS CASE ta = arccos((nV.dot(pV))/(n*p)) if pV[2] < 0: # Vallado pg. 110 ta = PI2 - ta E = ta self.M0 = E elif self.e < 1: # 9) True anomaly, eccentric anomaly and mean anomaly if radv >= 0: ta = arccos((eV / self.e).dot(pV/p)) else: ta = PI2 - arccos((eV / self.e).dot(pV/p)) E = arccos((self.e+cos(ta))/(1+ self.e*cos(ta))) if radv < 0: E = PI2 - E self.M0 = E - self.e * sin(E) elif self.e > 1: # 9) Hyperbolic True anomaly, eccentric anomaly and mean anomaly # http://scienceworld.wolfram.com/physics/HyperbolicOrbit.html V = arccos((abs(self.a)*(self.e**2 - 1)) /(self.e * p) - 1/self.e) ta = arccos((eV / self.e).dot(pV/p)) if radv < 0: #TODO: Should affect F too? # Negative = heading towards periapsis print "PI2" V = PI2 - V ta = PI2-ta print "V",V print "TA",ta # http://www.bogan.ca/orbits/kepler/orbteqtn.html In you I trust # Hyperbolic eccentric anomaly cosV = cos(V) F = arccosh((self.e+cosV)/(1+self.e*cosV)) if radv < 0: F = -F F2 = arcsinh((sqrt(self.e-1)*sin(V))/(1+self.e*cos(V))) ##F1 = F2 print "F1:",F print "F2:",F2 self.M0 = self.e * sinh(F) - F self.h = h print "Semi-major:",self.a print "Eccentricity:",self.e print "Inclination:",degrees(self.i),"deg" print "LAN:",degrees(self.lan),"deg" print "AoP:",degrees(self.aop),"deg" print "Mean anomaly:",self.M0 print "Specific angular momentum:",self.h if self.e < 1: print "Eccentric anomaly",E print "True anomaly",ta else: print "Hyperbolic eccentric anomaly",F print "Hyperbolic true anomaly",degrees(V) print "Distance from object:",p print "Velocity:",v
layer1.calc_orientation_from_angle(psi, v_perp) crystal=reflectivity.Sample(Sub, layer1) #crystal.calc_layer_Miller() crystal.set_Miller(R) crystal.calc_g0_gH(Energy) thBragg= float(Sub.calc_Bragg_angle(Energy).subs(Sub.structure.subs).evalf()) angle=pl.linspace(0.987, 1.013,501)*thBragg #XRl = layer1.calc_reflection_amplitude(angle, Energy) #XRs = Sub.calc_reflection_amplitude(angle, Energy) # XT = layer1.calc_transmission_amplitude(angle, Energy) XR=crystal.calc_reflectivity(angle, Energy) crystal.print_values(angle, Energy) pl.plot(data[:,0], data[:,1] , label='GID_sl', color='red') # pl.plot(angle-thBragg,abs(XT)**2) # pl.plot(angle-thBragg,abs(XRl)**2) # pl.plot(angle-thBragg,1 - abs(XT)**2 - abs(XRl)**2) pl.plot(pl.degrees(angle-thBragg),abs(XR)**2, label='dynXRD', color='black') #pl.plot(angle-thBragg,abs(XRs)**2) #pl.plot(angle-thBragg,abs(XRl)**2) pl.yscale('log') pl.xlabel('Angle (degrees)') pl.ylabel('Reflectivity') pl.xlim(-0.2,0.2) pl.rc('font', size=18) pl.legend(loc="upper left", prop={'size':19}) pl.locator_params(axis = 'x', nbins=4) pl.savefig('pics/test14.eps') pl.show()
crystal.calc_reflectivity(angle, Energy) layer1.calc_amplitudes(angle, Energy) layer2.calc_amplitudes(angle, Energy) layer3.calc_amplitudes(angle, Energy) Sub.calc_amplitudes(angle, Energy) XR1 = layer1.XR XR2 = layer2.XR XR3 = layer3.XR XRs = Sub.XR #XT = layer1.XT crystal.print_values(angle, Energy) #pl.plot(data[:,0], data[:,1], label='GID_sl', color='red') # pl.plot(angle-thBragg,abs(XT)**2-1) pl.plot(pl.degrees(angle-thBragg),abs(XRs)**2, label='$\infty$', color='black') pl.plot(pl.degrees(angle-thBragg),abs(XR1)**2, label='$500$ nm', color='red') pl.plot(pl.degrees(angle-thBragg),abs(XR2)**2, label='$1000$ nm', color='blue') pl.plot(pl.degrees(angle-thBragg),abs(XR3)**2, label='$2000$ nm', color='green') # pl.plot(angle-thBragg,1 - abs(XT)**2 - abs(XRl)**2) pl.xlabel('Angle (degrees)') pl.ylabel('Reflectivity') pl.xlim(-0.005,0.008) #pl.yscale('log') pl.legend(loc="upper left", title="Thickness", prop={'size':11}) pl.savefig('pics/dynamical.eps') pl.show()
layer1.calc_orientation(v_par, v_perp) crystal = reflectivity.Sample(Sub, layer1) crystal.set_Miller(R) crystal.calc_g0_gH(Energy) thBragg = float(layer1.calc_Bragg_angle(Energy).subs(layer1.structure.subs).evalf()) angle = pl.linspace(0.99, 1.01, 501) * thBragg crystal.calc_reflectivity(angle, Energy) layer1.calc_amplitudes(angle, Energy) Sub.calc_amplitudes(angle, Energy) XRl = layer1.XR XRs = Sub.XR XT = layer1.XT crystal.print_values(angle, Energy) pl.plot(data[:, 0], data[:, 1]) # pl.plot(angle-thBragg,abs(XT)**2) pl.plot(pl.degrees(angle - thBragg), abs(XRl) ** 2) # pl.plot(angle-thBragg,1 - abs(XT)**2 - abs(XRl)**2) pl.xlabel("Angle (degrees)") pl.ylabel("Reflectivity") pl.xlim(-0.2, 0.2) pl.ylim(1e-9, 1e-2) pl.yscale("log") pl.show()
#show() vx = array([1.0,0.0,0.0]).reshape(-1,1) vy = array([0.0,1.0,0.0]).reshape(-1,1) vz = array([0.0,0.0,1.0]).reshape(-1,1) error_angles_x = empty((l,)) error_angles_y = empty((l,)) error_angles_z = empty((l,)) for i in range(l): q1 = imu_quaternions[i] q2 = original_quaternions[i] v1x = transpose(q1.rotateVector(vx)) v2x = transpose(q2.rotateVector(vx)) ax = degrees(angle(v1x[0],v2x[0])) v1y = transpose(q1.rotateVector(vy)) v2y = transpose(q2.rotateVector(vy)) ay = degrees(angle(v1y[0],v2y[0])) v1z = transpose(q1.rotateVector(vz)) v2z = transpose(q2.rotateVector(vz)) az = degrees(angle(v1z[0],v2z[0])) error_angles_x[i] = ax error_angles_y[i] = ay error_angles_z[i] = az figure() plot(error_angles_x,label='x') plot(error_angles_y,label='y') plot(error_angles_z,label='z')