Esempio n. 1
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")
Esempio n. 2
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" )
Esempio n. 3
0

# # create MarsSpicer object
mspice = MarsSpicer()
utc1 = '2011-05-24T00:58:08.402'
utc2 = '2011-05-31T05:01:50.854'
mspice.utc = utc2

mspice.obs = 'MRO'
mspice.instrument = 'MRO_HIRISE'
mspice.set_spoint_by('sincpt')
phase = np.zeros_like(dem.data)

emissions = []
incidences = []
rev_srfvec = spice.vminus(mspice.srfvec)
for sample in xrange(phase.shape[0]):
    if sample % 10 == 0:
        print('Sample {0}'.format(sample))
    for line in xrange(phase.shape[1]):
        slope = float(slopes.data[sample, line])
        aspect = float(aspects.data[sample, line])
        # newPoint = Point(sample, line)
        # newPoint.pixel_to_lonlat(dem.geotransform, dem.projection)
        # mspice.set_spoint_by(lat = newPoint.lat, lon = newPoint.lon)

        mspice.tilt = slope
        mspice.aspect = aspect
        trnormal = mspice.tilted_rotated_normal
        incidence = spice.vsep(trnormal, mspice.sun_direction)
        emission = spice.vsep(trnormal, rev_srfvec)