Exemplo n.º 1
0
  def test_smap(self):

    target = 'SMAP'

    et0 = spice.utc2et( '2016-06-01T12:00:00' )

    dpr = spice.dpr()

    a,b,c = [spice.gdpool('BODY399_RADII',i,1)[1] for i in range(3)]

    ods = []

    for deltatime in [0.1 * i for i in range(1080)]:
      et = et0 + deltatime
      stSmap,lsSmap = spice.spkezr( target, et, 'IAU_EARTH', 'NONE', 'EARTH' )
      posn, veloc = stSmap[:3], stSmap[3:]
      stSun,lsSun = spice.spkezr( 'SUN', et0, 'IAU_EARTH', 'LT', 'EARTH' )
      mtx = spice.pxform( 'SMAP_REFLECTOR', 'IAU_EARTH', et)
      boreEbf = spice.mxv( mtx, [1.0,0,0] )
      point = spice.surfpt( posn, boreEbf, a, b, c)
      rsurfpt,lon,lat = spice.reclat( point )
      utc = spice.et2utc( et, 'ISOC', 3 )

      ods += [ OD(deltatime=deltatime,posn=posn,veloc=veloc,boreEbf=boreEbf
                 ,utc=utc,point=point,rsurfpt=rsurfpt
                 ,rsmap=spice.vnorm(posn),lat=lat,lon=lon 
                 ,raynge=spice.vnorm(spice.vsub(point,posn))
                 ,sunsep=spice.vsep( spice.ucrss(posn,veloc), stSun[:3] )
                 )
             ]

    try:
      ### Moved matplotlib import to here so test runs to here at least
      from matplotlib import pyplot as plt
      plt.figure(1)
      keys = 'lat lon raynge'.split()
      secs = [od['deltatime'] for od in ods]
      for idx in range(len(keys)):
        scal = 1.0 if keys[idx] in 'rsurfpt rsmap raynge sunsep rp ecc t0 mu a P eccmean amean Pmean'.split() else dpr
        ordinate = [od[keys[idx]]*scal for od in ods]
        plt.subplot( 221+idx )
        plt.plot( secs, ordinate )
        plt.plot( secs, ordinate, '.')
        plt.title( keys[idx] )
        plt.ylabel( '%s%s' % (keys[idx],'' if scal==1.0 else ', deg') )
        if idx>1: plt.xlabel( 'T-T0, s' )

      abscissa = [od['lon']*dpr for od in ods]
      ordinate = [od['lat']*dpr for od in ods]
      plt.subplot( 221+idx+1 )
      plt.title( 'lon vs. lat' )
      plt.plot( abscissa, ordinate )
      plt.xlabel( 'lon, deg' )
      plt.ylabel( 'lat, deg' )
      plt.show()

    except:
      print( "Bypassed, or failed, matplotlib tests" )
Exemplo n.º 2
0
Catalog numbers may be omitted to save space if they are monotonically
increasing integers. Proper motions may be omitted if they are not known.
There may be up to 10 magnitudes.

Last updated 24 September 2012 [...]
"""

import os
import sys
import math
import struct

try:
    import spice
    b2jMtx = spice.pxform('B1950', 'J2000', 0.0)
    dpr = spice.dpr()
    vdot = spice.vdot
    mxv = spice.mxv
    recrad = spice.recrad
    radrec = spice.radrec
    vhat = spice.vhat
    vscl = spice.vscl
    ucrss = spice.ucrss
    vadd = spice.vadd

except:

    if "DEBUG" in os.environ:
        import traceback
        traceback.print_exc()
Exemplo n.º 3
0
  def test_horizons(self):
    import horizons

    target = 'C/2013 S1'
    target = 'C/2011 L4'

    spkFilename,spiceId,status = horizons.gomain(target)

    spice.furnsh( spkFilename )
    self.kernels += [spkFilename]

    target_ = '_'.join( target.split() )

    et0 = spice.utc2et( '2013-01-10T12:00:00' )

    ls2au = spice.convrt( spice.clight(), 'KM', 'AU' )
    dpr = spice.dpr()
    spd = spice.spd()

    deltatime = None

    while deltatime is None or abs(deltatime) > 5e-7:
      stS2I,lsS2I = spice.spkgeo( spiceId, et0, 'J2000', 10 )
      posn, veloc = stS2I[:3], stS2I[3:]
      deltatime = - spice.vdot( posn, veloc ) / spice.vdot( veloc, veloc )
      et0 += deltatime


    valarrs = [ ]
    print( (deltatime,spice.et2utc(et0,'ISOC',3),) )

    deltatime = 1.0
    sixmonths = spice.pi() * 1e7

    while deltatime < sixmonths:
      for pmdet in (-deltatime,deltatime):
        et = et0 + pmdet
        utc = spice.et2utc(et,'ISOC',1)

        stD2I,lsD2I = spice.spkgeo( spiceId, et, 'J2000', -140)
        stI2S,lsI2S = spice.spkgeo( 10, et, 'J2000', spiceId )
        stD2S,lsD2S = spice.spkgeo( 10, et, 'J2000', -140 )

        rD2I, rI2S = [ ls * ls2au for ls in [lsD2I,lsI2S] ]
        aDIS, aSDI = [ ang * dpr for ang in 
                       [ spice.vsep( spice.vminus(stD2I[:3]), stI2S[:-3] )
                       , spice.vsep( stD2S[:3], stD2I[:-3] )
                       ]
                     ]
        valarrs += [ (et,pmdet,rD2I,rI2S,aDIS,aSDI,utc,) ]

      deltatime *= 1.2

    valarrs.sort()
    for valarr in valarrs:
      print( '%12.1f %9.3f %9.3f %7.2f %7.2f %s' % valarr[1:] )

    days = [i[1]/spd for i in valarrs]

    titles = [ i % (target_,) for i in """
    Range, %s-DI, AU
    Range, %s-Sun, AU
    Phase, DI-%s-Sun, deg
    Elongation, Sun-DI-%s, deg
    """.strip().split('\n')]

    try:
      ### Moved matplotlib import to here so test runs to here at least
      from matplotlib import pyplot as plt
      plt.figure(1)
      for idx in range(len(titles)):
        ordinate = [i[idx+2] for i in valarrs]
        plt.subplot( 221+idx )
        plt.plot( days, ordinate )
        plt.plot( days, ordinate, '.')
        plt.title( titles[idx] )
        plt.ylabel( titles[idx] )
        if idx>1: plt.xlabel( 'T-Tperi, d' )

      plt.show()

    except:
      print( "Bypassed, or failed, matplotlib tests" )
Exemplo n.º 4
0
    def test_horizons(self):
        import horizons

        target = 'C/2013 S1'
        target = 'C/2011 L4'

        spkFilename, spiceId, status = horizons.gomain(target)

        spice.furnsh(spkFilename)
        self.kernels += [spkFilename]

        target_ = '_'.join(target.split())

        et0 = spice.utc2et('2013-01-10T12:00:00')

        ls2au = spice.convrt(spice.clight(), 'KM', 'AU')
        dpr = spice.dpr()
        spd = spice.spd()

        deltatime = None

        while deltatime is None or abs(deltatime) > 5e-7:
            stS2I, lsS2I = spice.spkgeo(spiceId, et0, 'J2000', 10)
            posn, veloc = stS2I[:3], stS2I[3:]
            deltatime = -spice.vdot(posn, veloc) / spice.vdot(veloc, veloc)
            et0 += deltatime

        valarrs = []
        print((
            deltatime,
            spice.et2utc(et0, 'ISOC', 3),
        ))

        deltatime = 1.0
        sixmonths = spice.pi() * 1e7

        while deltatime < sixmonths:
            for pmdet in (-deltatime, deltatime):
                et = et0 + pmdet
                utc = spice.et2utc(et, 'ISOC', 1)

                stD2I, lsD2I = spice.spkgeo(spiceId, et, 'J2000', -140)
                stI2S, lsI2S = spice.spkgeo(10, et, 'J2000', spiceId)
                stD2S, lsD2S = spice.spkgeo(10, et, 'J2000', -140)

                rD2I, rI2S = [ls * ls2au for ls in [lsD2I, lsI2S]]
                aDIS, aSDI = [
                    ang * dpr for ang in [
                        spice.vsep(spice.vminus(stD2I[:3]), stI2S[:-3]),
                        spice.vsep(stD2S[:3], stD2I[:-3])
                    ]
                ]
                valarrs += [(
                    et,
                    pmdet,
                    rD2I,
                    rI2S,
                    aDIS,
                    aSDI,
                    utc,
                )]

            deltatime *= 1.2

        valarrs.sort()
        for valarr in valarrs:
            print('%12.1f %9.3f %9.3f %7.2f %7.2f %s' % valarr[1:])

        days = [i[1] / spd for i in valarrs]

        titles = [
            i % (target_, ) for i in """
    Range, %s-DI, AU
    Range, %s-Sun, AU
    Phase, DI-%s-Sun, deg
    Elongation, Sun-DI-%s, deg
    """.strip().split('\n')
        ]

        try:
            ### Moved matplotlib import to here so test runs to here at least
            from matplotlib import pyplot as plt
            plt.figure(1)
            for idx in range(len(titles)):
                ordinate = [i[idx + 2] for i in valarrs]
                plt.subplot(221 + idx)
                plt.plot(days, ordinate)
                plt.plot(days, ordinate, '.')
                plt.title(titles[idx])
                plt.ylabel(titles[idx])
                if idx > 1: plt.xlabel('T-Tperi, d')

            plt.show()

        except:
            print("Bypassed, or failed, matplotlib tests")
Exemplo n.º 5
0
Catalog numbers may be omitted to save space if they are monotonically
increasing integers. Proper motions may be omitted if they are not known.
There may be up to 10 magnitudes.

Last updated 24 September 2012 [...]
"""

import os
import sys
import math
import struct

try:
  import spice
  b2jMtx = spice.pxform('B1950','J2000',0.0)
  dpr = spice.dpr()
  vdot = spice.vdot
  mxv = spice.mxv
  recrad = spice.recrad
  radrec = spice.radrec
  vhat = spice.vhat
  vscl = spice.vscl
  ucrss = spice.ucrss
  vadd = spice.vadd
  
except:

  if "DEBUG" in os.environ:
    import traceback
    traceback.print_exc()
Exemplo n.º 6
0
import sys
import spice

rpd, dpr = spice.rpd(), spice.dpr()

if __name__ == "__main__":

    spice.furnsh(__file__)

    ### Earth equatorial and polar radii calculate flattening
    re = spice.gdpool('BODY399_RADII', 0, 1)[1]
    rp = spice.gdpool('BODY399_RADII', 2, 1)[1]
    f = (re - rp) / re

    for line in sys.stdin:

        ### Read one line of input at a time; only use lines that start with data:
        if line[:5] != "data:": continue

        linestrip = line[5:].strip()

        linetoks = linestrip.split()  ### Break line into tokens

        toms_alt_m, toms_lon_deg, toms_lat_deg, sX, sY, sZ, surf_lon_deg, surf_lat_deg = map(
            float, linetoks[:-1])
        utc = linetoks[-1]

        uvEarth2Sun = spice.vhat((
            sX,
            sY,
            sZ,
Exemplo n.º 7
0
    def test_smap(self):

        target = 'SMAP'

        et0 = spice.utc2et('2016-06-01T12:00:00')

        dpr = spice.dpr()

        a, b, c = [spice.gdpool('BODY399_RADII', i, 1)[1] for i in range(3)]

        ods = []

        for deltatime in [0.1 * i for i in range(1080)]:
            et = et0 + deltatime
            stSmap, lsSmap = spice.spkezr(target, et, 'IAU_EARTH', 'NONE',
                                          'EARTH')
            posn, veloc = stSmap[:3], stSmap[3:]
            stSun, lsSun = spice.spkezr('SUN', et0, 'IAU_EARTH', 'LT', 'EARTH')
            mtx = spice.pxform('SMAP_REFLECTOR', 'IAU_EARTH', et)
            boreEbf = spice.mxv(mtx, [1.0, 0, 0])
            point = spice.surfpt(posn, boreEbf, a, b, c)
            rsurfpt, lon, lat = spice.reclat(point)
            utc = spice.et2utc(et, 'ISOC', 3)

            ods += [
                OD(deltatime=deltatime,
                   posn=posn,
                   veloc=veloc,
                   boreEbf=boreEbf,
                   utc=utc,
                   point=point,
                   rsurfpt=rsurfpt,
                   rsmap=spice.vnorm(posn),
                   lat=lat,
                   lon=lon,
                   raynge=spice.vnorm(spice.vsub(point, posn)),
                   sunsep=spice.vsep(spice.ucrss(posn, veloc), stSun[:3]))
            ]

        try:
            ### Moved matplotlib import to here so test runs to here at least
            from matplotlib import pyplot as plt
            plt.figure(1)
            keys = 'lat lon raynge'.split()
            secs = [od['deltatime'] for od in ods]
            for idx in range(len(keys)):
                scal = 1.0 if keys[
                    idx] in 'rsurfpt rsmap raynge sunsep rp ecc t0 mu a P eccmean amean Pmean'.split(
                    ) else dpr
                ordinate = [od[keys[idx]] * scal for od in ods]
                plt.subplot(221 + idx)
                plt.plot(secs, ordinate)
                plt.plot(secs, ordinate, '.')
                plt.title(keys[idx])
                plt.ylabel('%s%s' %
                           (keys[idx], '' if scal == 1.0 else ', deg'))
                if idx > 1: plt.xlabel('T-T0, s')

            abscissa = [od['lon'] * dpr for od in ods]
            ordinate = [od['lat'] * dpr for od in ods]
            plt.subplot(221 + idx + 1)
            plt.title('lon vs. lat')
            plt.plot(abscissa, ordinate)
            plt.xlabel('lon, deg')
            plt.ylabel('lat, deg')
            plt.show()

        except:
            print("Bypassed, or failed, matplotlib tests")