Exemple #1
0
 def test_hypot(self):
     """hypot should have known output"""
     invals = [ [3, 4], list(range(3, 6)), list(range(3,10)), [-1,2,3] ]
     ans = [ 5, 7.0710678118654755, 16.73320053068151, 3.7416573867739413 ]
     for i, tst in enumerate(invals):
         self.assertAlmostEqual(ans[i], tb.hypot(*tst))
     for i, tst in enumerate(invals):
         self.assertAlmostEqual(ans[i], tb.hypot(tst))
     self.assertEqual(5.0, tb.hypot(5.0))
     if spacepy.lib.have_libspacepy:
         self.assertEqual(tb.hypot(numpy.array([3.,4.])), 5.0)
         self.assertEqual(tb.hypot(numpy.array([3,4])), 5.0)
Exemple #2
0
 def test_hypot(self):
     """hypot should have known output"""
     invals = [ [3, 4], list(range(3, 6)), list(range(3,10)), [-1,2,3] ]
     ans = [ 5, 7.0710678118654755, 16.73320053068151, 3.7416573867739413 ]
     for i, tst in enumerate(invals):
         self.assertAlmostEqual(ans[i], tb.hypot(*tst))
     for i, tst in enumerate(invals):
         self.assertAlmostEqual(ans[i], tb.hypot(tst))
     self.assertEqual(5.0, tb.hypot(5.0))
     if spacepy.lib.have_libspacepy:
         self.assertEqual(tb.hypot(numpy.array([3.,4.])), 5.0)
         self.assertEqual(tb.hypot(numpy.array([3,4])), 5.0)
Exemple #3
0
def runPAdungey(quality):
    #test for range of pitch angles
    ticks = spt.tickrange('2002-04-18', '2002-04-19', 1)
    loci = spc.Coords([[-4, 0, 0], [-5, 0, 0]], 'SM', 'car')
    vals = []
    for pp in range(1, 91):
        dum = lgmpy.get_Lstar(loci.data[1],
                              ticks.UTC[1],
                              alpha=pp,
                              coord_system='SM',
                              Bfield='Lgm_B_Dungey',
                              extended_out=True,
                              LstarQuality=quality)
        try:
            vals.extend(dum[pp]['Lstar'])
        except (IndexError,
                TypeError):  #get_Lstar returns a 0-D nan in some cases...
            vals.extend([dum[pp]['Lstar'].tolist()])
    fig = plt.figure()
    expect = dungeyLeq(tb.hypot(loci.data[1]))
    #print(expect)
    plt.plot(100 * (dm.dmarray(vals) - expect) / expect, drawstyle='steps-mid')
    plt.ylim([-0.01, 0.01])
    plt.xlabel('Pitch Angle')
    plt.ylabel('100*(L* - L*$_{exp}$)/L*$_{exp}$')
    plt.title('Dungey model [-5,0,0]$_{SM}$' +
              '; Quality ({0})'.format(str(quality)))
    figname = 'MagEphem_Dungey_test_q{0}'.format(
        str(quality))  #'LGM_L*_vs_PA_cdip_q{0}'.format(str(quality))
    plt.savefig(''.join([figname, '.png']), dpi=300)
    plt.savefig(''.join([figname, '.pdf']))
def runPA(quality):
    #test for range of pitch angles
    ticks = spt.tickrange('2002-04-18', '2002-04-19', 1)
    loci = spc.Coords([[-4,0,0], [-5,0,0]], 'SM', 'car')
    vals = []
    for pp in range(1,91):
        dum = lgmpy.get_Lstar(loci.data[1], ticks.UTC[1], alpha=pp, coord_system='SM', 
                              Bfield='Lgm_B_cdip', extended_out=True, LstarQuality=quality)
        try:
            vals.extend(dum[pp]['Lstar'])
        except (IndexError, TypeError): #get_Lstar returns a 0-D nan in some cases...
            vals.extend([dum[pp]['Lstar'].tolist()])
    fig = plt.figure()
    expect = float(tb.hypot(loci.data[1]))
    plt.plot(100*(dm.dmarray(vals)-expect)/expect, drawstyle='steps-mid')
    plt.ylim([-0.01, 0.01])
    plt.xlabel('Pitch Angle')
    plt.ylabel('100*(L* - L*$_{exp}$)/L*$_{exp}$')
    plt.title('Cent. dipole [-5,0,0]$_{SM}$'+'; Quality ({0})'.format(str(quality)))
    figname = 'MagEphem_CDIP_test_q{0}'.format(str(quality))   #'LGM_L*_vs_PA_cdip_q{0}'.format(str(quality))
    plt.savefig(''.join([figname,'.png']), dpi=300)
    plt.savefig(''.join([figname,'.pdf']))
Exemple #5
0
def extension_t(n, data):
    #    ans = tb.hypot(data[0:n])
    ans = tb.hypot(data)
Exemple #6
0
def extension_t(n, data):
#    ans = tb.hypot(data[0:n])
    ans = tb.hypot(data)