예제 #1
0
 def __init__(self):
     self.jpv=[ ( 'JD %s TDT' % (jdtt,)
              , ( spice.convrt(float(x),'AU','KM'), spice.convrt(float(y),'AU','KM'), spice.convrt(float(z),'AU','KM'), )
              , ( spice.convrt(float(xdot),'AU','KM')/spice.spd(), spice.convrt(float(ydot),'AU','KM')/spice.spd(), spice.convrt(float(zdot),'AU','KM')/spice.spd(), )
              , )
              for nm,jdtt,x,y,z,xdot,ydot,zdot
              in [ i.strip().split() for i in self.__doc__.split('\n') if i[:9]=='CK12S010 ' ]
              ]
예제 #2
0
파일: check_02.py 프로젝트: drbitboy/Sclk9P
def convertDiffs(diXDiffs):
  if isinstance(diXDiffs, timediffs.didiff):
    diVTC = diXDiffs.imFracSec
    diSCLK = '%010.0f:%03.0f' % (int(diVTC),256 * (diVTC%1.0),)
    diET = spice.scs2e(-70,diSCLK)
    diDoy = 185 + ((diET - et) / spice.spd())
    return diDoy,diXDiffs.imFbDiff
  else:
    rtnDoys = []
    rtnDiffs = []
    for diXDiff in diXDiffs:
      diDoy,diDiff = convertDiffs(diXDiff)
      rtnDoys.append(diDoy)
      rtnDiffs.append(diDiff)

  return (rtnDoys,rtnDiffs,)
예제 #3
0
def convertDiffs(diXDiffs):
    if isinstance(diXDiffs, timediffs.didiff):
        diVTC = diXDiffs.imFracSec
        diSCLK = '%010.0f:%03.0f' % (
            int(diVTC),
            256 * (diVTC % 1.0),
        )
        diET = spice.scs2e(-70, diSCLK)
        diDoy = 185 + ((diET - et) / spice.spd())
        return diDoy, diXDiffs.imFbDiff
    else:
        rtnDoys = []
        rtnDiffs = []
        for diXDiff in diXDiffs:
            diDoy, diDiff = convertDiffs(diXDiff)
            rtnDoys.append(diDoy)
            rtnDiffs.append(diDiff)

    return (
        rtnDoys,
        rtnDiffs,
    )
예제 #4
0
파일: check_01.py 프로젝트: drbitboy/Sclk9P
found, et = spice.gdpool('ETSTART', 0, 1)

### S/C IDs
scids = [-70, -140]
n = len(scids)
rn = range(len(scids))

### for 15 days leading up to TOI
for i in range(16):
    ### Convert
    ### - ET to ISO Calendar and DOY UTCs
    ### - ET to DII and DIF SCLKs
    ### - SCLKs to encoded SCLK, scale by 1/256 to get s past J2k epoch
    utcs = [spice.et2utc(et, 'isoc', 3), spice.et2utc(et, 'isod', 3)]
    sclks = [spice.sce2s(scids[i], et) for i in rn]
    encds = [spice.scencd(scids[i], sclks[i]) / 256e0 for i in rn]
    ### Build and print output
    f3 = ' %.3f'
    sencds = (f3 * n).strip() % tuple(
        [spice.scencd(scids[i], sclks[i]) / 256e0 for i in rn])
    diff3 = (f3 * (n + 1)).strip() % tuple([encds[0] - encds[1]] +
                                           [et - encds[i] for i in rn])
    print((
        utcs,
        sclks,
        sencds,
        diff3,
    ))
    ### Increment ET by 1d (spice.spd() = seconds/day)
    et += spice.spd()
예제 #5
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" )
예제 #6
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")
예제 #7
0
파일: check_01.py 프로젝트: drbitboy/Sclk9P
import pprint


print(__doc__.replace('\b','\\b'))
spice.furnsh(__file__)

### ET of TOI-15d
found,et = spice.gdpool( 'ETSTART', 0, 1 )

### S/C IDs
scids = [-70,-140]
n = len(scids)
rn = range(len(scids))

### for 15 days leading up to TOI
for i in range(16):
  ### Convert
  ### - ET to ISO Calendar and DOY UTCs
  ### - ET to DII and DIF SCLKs
  ### - SCLKs to encoded SCLK, scale by 1/256 to get s past J2k epoch
  utcs = [ spice.et2utc( et, 'isoc', 3), spice.et2utc( et, 'isod', 3) ]
  sclks = [ spice.sce2s(scids[i],et) for i in rn ]
  encds = [ spice.scencd(scids[i],sclks[i])/256e0 for i in rn ]
  ### Build and print output
  f3 = ' %.3f'
  sencds = (f3*n).strip() % tuple([ spice.scencd(scids[i],sclks[i])/256e0 for i in rn ])
  diff3 = (f3*(n+1)).strip() % tuple( [encds[0] - encds[1]] + [ et-encds[i] for i in rn ])
  print( (utcs,sclks,sencds,diff3,) )
  ### Increment ET by 1d (spice.spd() = seconds/day)
  et += spice.spd()
예제 #8
0
파일: check_02.py 프로젝트: drbitboy/Sclk9P
  ### Convert ET to SCLKs and Vehicle Time Codes (=Encoded SCLK/256)
  sclks = [ spice.sce2s(scids[i],et) for i in scidrn ]
  vtcs = [ spice.scencd(scids[i],sclks[i])/256e0 for i in scidrn ]
  ### Calculate differences
  diffs[iDay] = [vtcs[0] - vtcs[1]] + [ et-vtcs[i] for i in scidrn ]
  ### Output UTCs, SCLKs, and ET-SCLK differences for every ninth day
  if (iDay%9) == 0:
    utcs = [spice.et2utc( et, 'isoc', 3), spice.et2utc( et, 'isod', 3)]
    svtcs = f3(n) % tuple([ spice.scencd(scids[i],sclks[i])/256e0
                            for i in scidrn
                          ])
    sdiffs = f3(n+1) % tuple( diffs[iDay] )
    print( (utcs,sclks,svtcs,sdiffs,) )

  ### Increment ET by 1d
  et += spice.spd()

et -= spice.spd()

print(__doc__.strip().replace('\b','\\b'))

### Get DII & DIF time correlation data for approach, suspect point,
### and TOI times

def convertDiffs(diXDiffs):
  if isinstance(diXDiffs, timediffs.didiff):
    diVTC = diXDiffs.imFracSec
    diSCLK = '%010.0f:%03.0f' % (int(diVTC),256 * (diVTC%1.0),)
    diET = spice.scs2e(-70,diSCLK)
    diDoy = 185 + ((diET - et) / spice.spd())
    return diDoy,diXDiffs.imFbDiff
예제 #9
0
파일: vj.py 프로젝트: drbitboy/vj
### https://github.com/drbitboy/PySPICE
import spice

dot = '.'

### Load kernels using this source as SPICE meta-kernel
spice.furnsh(dot.join(__file__.split(dot)[:-1] + ['py']))

### Set arguments for Geometry Finder call
### - Times when VENUS crosses equator of Jupiter (Zjup = 0)
### - abcorr='LT+S' - correct for light time and stellar aberration
### - Timestep of 10 days (spice.spd() = seconds per day)
### - nintvls - 450 seems to work here
target, frame, abcorr, obsrvr = 'VENUS', 'IAU_JUPITER', 'LT+S', 'JUPITER'
relate, crdsys, coord = '=', 'RECTANGULAR', 'Z'
refval, adjust, step, nintvls = 0.0, 0.0, spice.spd()*10, 450

### Range of ETs to test
etlo,ethi = [spice.gdpool(s,0,1)[1] for s in 'ETLO ETHI'.split()]
cnfine = spice.wninsd( etlo, ethi, spice.objects.Cell(spice.DataType.SPICE_DP,2))

### Create DP window to receive results
result = spice.objects.Cell(spice.DataType.SPICE_DP,500)

### Make the call to the generic Geometry Finder call
cnfine, result = spice.gfposc( target, frame, abcorr, obsrvr, crdsys, coord, relate, refval, adjust, step, nintvls, cnfine, result )

### Output results as four columns
### - Crossing ordinal
### - UTC of crossing as ISO calendar time
### - TDB of crossing as calendar time (no leapseconds)
예제 #10
0
    diffs[iDay] = [vtcs[0] - vtcs[1]] + [et - vtcs[i] for i in scidrn]
    ### Output UTCs, SCLKs, and ET-SCLK differences for every ninth day
    if (iDay % 9) == 0:
        utcs = [spice.et2utc(et, 'isoc', 3), spice.et2utc(et, 'isod', 3)]
        svtcs = f3(n) % tuple(
            [spice.scencd(scids[i], sclks[i]) / 256e0 for i in scidrn])
        sdiffs = f3(n + 1) % tuple(diffs[iDay])
        print((
            utcs,
            sclks,
            svtcs,
            sdiffs,
        ))

    ### Increment ET by 1d
    et += spice.spd()

et -= spice.spd()

print(__doc__.strip().replace('\b', '\\b'))

### Get DII & DIF time correlation data for approach, suspect point,
### and TOI times


def convertDiffs(diXDiffs):
    if isinstance(diXDiffs, timediffs.didiff):
        diVTC = diXDiffs.imFracSec
        diSCLK = '%010.0f:%03.0f' % (
            int(diVTC),
            256 * (diVTC % 1.0),