예제 #1
0
 def distanceTo(self,epoch,obj):        
     if self.ref == obj:
         op,ov = ([0,0,0],[0,0,0])
     elif self.ref != obj.ref:
         print self.ref.name, "->", obj.ref.name , "(",obj.name,")"
         raise AttributeError("Coordinate conversion not implemented")
     else:
         op,ov = obj.eph(epoch)
     sp,sv = self.eph3D(self.eph2D(epoch))
     
     return linalg.norm(sp-op)    
예제 #2
0
파일: kinematics.py 프로젝트: burst/burst
    def testPixEstimateMany(self, camera_pitch=0.0, acceptable_error=1):
        """
        Return results that are incorrect - those that have an error in position
        larger then acceptable_error and should be visible.
        """
        from pylab import linalg, linspace, array

        results = [
            (self.testPixEstimateStraightForward(px, py, camera_pitch), px, py)
            for px, py in grid_points(linspace(200, 300, 20), linspace(-100, 100, 20))
        ]
        results = [(linalg.norm(array((px, py)) - (res[0].x, res[0].y)), res, px, py) for res, px, py in results]
        return [
            (err, est, pixel_x, pixel_y, px, py)
            for err, (est, pixel_x, pixel_y), px, py in results
            if err > acceptable_error and 0 <= pixel_x <= IMAGE_WIDTH and 0 <= pixel_y <= IMAGE_HEIGHT
        ]
예제 #3
0
from pylab import linalg

err_fft = [max(e, 1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]
plt.plot(np.log10(err_fft / linalg.norm(f)**2), linewidth=2)
plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1, n**2 / 50)
plt.ylim(-2.35, 0)

plt.show()
예제 #4
0
from pylab import linalg

err_fft = [max(e,1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]
plt.plot(np.log10(err_fft/linalg.norm(f)**2),linewidth=2)
plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1,n**2/50)
plt.ylim(-2.35,0)

plt.show()
예제 #5
0
 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
예제 #6
0
from pylab import linalg

cR = np.sort(np.ravel(abs(fL)))[::-1]
err_ldct = [max(e,1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]

plt.plot(np.log10(err_fft/linalg.norm(f)**2),linewidth=2, color = "red", label = "Fourier")
plt.plot(np.log10(err_wav/linalg.norm(f)**2),linewidth=2, color = "blue", label = "Wavelets")
plt.plot(np.log10(err_dct/linalg.norm(f)**2),linewidth=2, color = "purple", label = "DCT")
plt.plot(np.log10(err_ldct/linalg.norm(f)**2),linewidth=2, color = "orange", label = "Local DCT")

plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1,n**2/50)
plt.ylim(-2.35,0)
plt.legend()

plt.show()
from pylab import linalg

cR = np.sort(np.ravel(abs(fC)))[::-1]
err_dct = [max(e,1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]

plt.plot(np.log10(err_fft/linalg.norm(f)**2),linewidth=2, color = "red", label = "Fourier")
plt.plot(np.log10(err_wav/linalg.norm(f)**2),linewidth=2, color = "green", label = "DCT")

plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1,n**2/50)
plt.ylim(-2.35,0)
plt.legend()

plt.show()
예제 #8
0
from pylab import linalg

cR = np.sort(np.ravel(abs(fC)))[::-1]
err_dct = [max(e,1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]

plt.plot(np.log10(err_fft/linalg.norm(f)**2),linewidth=2, color = "red", label = "Fourier")
plt.plot(np.log10(err_wav/linalg.norm(f)**2),linewidth=2, color = "green", label = "DCT")

plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1,n**2/50)
plt.ylim(-2.35,0)
plt.legend()

plt.show()
예제 #9
0
from pylab import linalg

cR = np.sort(np.ravel(abs(fW)))[::-1]
err_wav = [max(e, 1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]

plt.plot(np.log10(err_fft / linalg.norm(f)**2),
         linewidth=2,
         color="red",
         label="Fourier")
plt.plot(np.log10(err_wav / linalg.norm(f)**2),
         linewidth=2,
         color="blue",
         label="Wavelets")

plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1, n**2 / 50)
plt.ylim(-2.35, 0)
plt.legend()

plt.show()
예제 #10
0
from pylab import linalg

cR = np.sort(np.ravel(abs(fW)))[::-1]
err_wav = [max(e,1e-10) for e in linalg.norm(f)**2 - np.cumsum(cR**2)]

plt.plot(np.log10(err_fft/linalg.norm(f)**2),linewidth=2, color = "red", label = "Fourier")
plt.plot(np.log10(err_wav/linalg.norm(f)**2),linewidth=2, color = "blue", label = "Wavelets")

plt.title("$\log_{10}(\epsilon^2[M]/ ||f||^2)$")
plt.xlim(1,n**2/50)
plt.ylim(-2.35,0)
plt.legend()

plt.show()