コード例 #1
0
ファイル: va2014.py プロジェクト: drbitboy/ValladoAlfano2014
  def invE(self,offsetArcLength=None,arcLengthArg=None,rtnIter=False):
    """Find eccentric anomaly corresponding to the input arc length"""

    ### Parse arguments
    assert not (offsetArcLength is not None and arcLengthArg is not None)
    if arcLengthArg is None: arcLengthTarget = self.arcChf + offsetArcLength
    else                   : arcLengthTarget = float(arcLengthArg)

    ### Initial estimate of Eccentric Anomaly
    ### - highest positive or negative multiple of halfpi that gives
    ###   an arc length less than or equal to targetLength
    nQuad = int(arcLengthTarget / self.quadArc)
    arcLengthGuess = nQuad * self.quadArc
    if arcLengthGuess > arcLengthTarget:
      nQuad -= 1
      arcLengthGuess -= self.quadArc
    eaGuess0 = eaGuess = nQuad * halfpi
    eaGuess0PlusTwoPi = eaGuess0 + twopi

    deltaArc =  arcLengthTarget - arcLengthGuess
    tol = self.aChf * 1e-9
    itter = 0
    while abs(deltaArc) > tol:

      itter += 1
      ### Vector from primary focus to Ecc. Anom. guess
      cosea = math.cos(eaGuess)
      sinea = math.sin(eaGuess)
      x = self.aChf * cosea
      y = self.bChf * sinea

      ### Delta-[x,y] of tangent at (x,y) for distance of deltaArc
      delx = -self.aChf * sinea
      dely =  self.bChf * cosea
      fac = deltaArc / sp.vnorm(sp.vpack(delx,dely,0.))
      delx *= fac
      dely *= fac
   
      ### Delta-vector tangent at (x,y) for distance of deltaArc
      ### - [X,Y,Z] = [x+delx, y+dely, 0]
      ### - scale X by 1/a and Y by 1/b to get Eccentric Anomaly
      eaGuess = sp.recrad(sp.vpack((x+delx)/self.aChf
                                   ,(y+dely)/self.bChf
                                   ,0.
                                   )
                          )[iRA]
      while eaGuess0 > eaGuess: eaGuess += twopi
      while (eaGuess0PlusTwoPi) <= eaGuess: eaGuess -= twopi
      arcLengthGuess = self.E(eaGuess)
      deltaArc = arcLengthTarget - arcLengthGuess

    return rtnIter and (eaGuess,itter,) or eaGuess
コード例 #2
0
utcPRG = spice.et2utc(et,'ISOC',3,99)

mtxJ2kToBF = spice.tipbod('J2000', targetID, et)

velocityPRG_BF = spice.mxv(mtxJ2kToBF,state[3:])
V_prg,ra,Theta = spice.recrad(velocityPRG_BF)

Theta_deg = Theta * dpr

print((dt,dt/et,utcPRG,V_prg,Theta_deg))

import matplotlib.pyplot as plt

days = 7
hours = xrange(-24*days,24*days + 1)

speeds = [ spice.vnorm(spice.spkezr(spacecraft,et+(hour*3600.),'J2000','NONE',target)[0][3:]) for hour in hours]

Vmin = min(speeds)
plt.axhline(y=V_prg,label='V_prg = %.3fkm/s' % (V_prg,))
plt.axhline(y=Vmin,label='Vmin = %.3fkm/s' % (Vmin,))
plt.plot(hours,speeds,'r',label='%s-relative speed' % (target,))

plt.title('Perigee at %s (UTC); Theta=%.3fdeg' % (utcPRG,Theta_deg,))
plt.xlabel('t - T_prg, h')
plt.ylabel('%s-relative speed, km/s' % (target,))

plt.legend()

plt.show()