Exemplo n.º 1
0
 def testSaveLoadPickle(self):
     """savePickle should write a pickle to disk and loadPickle should load it"""
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_1.pkl'), self.D1)
     files = glob.glob(os.path.join(self.tempdir, '*.pkl'))
     self.assertTrue(os.path.join(self.tempdir, 'test_pickle_1.pkl') in files)
     DD = tb.loadpickle(os.path.join(self.tempdir, 'test_pickle_1.pkl'))
     self.assertEqual(self.D1, DD)
Exemplo n.º 2
0
 def testSaveLoadPickle(self):
     """savePickle should write a pickle to disk and loadPickle should load it"""
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_1.pkl'), self.D1)
     files = glob.glob(os.path.join(self.tempdir, '*.pkl'))
     self.assertTrue(os.path.join(self.tempdir, 'test_pickle_1.pkl') in files)
     DD = tb.loadpickle(os.path.join(self.tempdir, 'test_pickle_1.pkl'))
     self.assertEqual(self.D1, DD)
Exemplo n.º 3
0
def runQs():
    #make figure
    fig = plt.figure(figsize=(17, 21))
    
    #set up test runs
    nvals, rvals = 5, [2, 3, 4, 5, 6]
    dates = spt.tickrange('2001-04-22T12:00:00', '2001-04-23T23:00:00', 1/24)
    alpha = 45
    
    #loop over radial positions, dates and quality flags
    for rval in rvals:
        Lstar = [[]]*nvals
        for date, qual in itertools.product(dates.UTC, range(nvals)):
            pos = dm.dmarray([-1*rval, 0, 0], attrs={'sys': 'SM'})
            data = lgmpy.get_Lstar(pos, date, alpha=alpha, coord_system='SM', Bfield='Lgm_B_cdip', LstarThresh=20.0, extended_out=True, LstarQuality=qual)
            try:
                Lstar[qual].extend(data[alpha]['Lstar'])
            except TypeError:
                Lstar[qual].append(data[alpha]['Lstar'].tolist())
        print('Did [-%d,0,0] for all qualities' % rval)
        #make plots
        fstr = '%d1%d' % (len(rvals), rval-rvals[0]+1)
        ax = fig.add_subplot(fstr)
        ax.boxplot(Lstar)
        #ax = plt.gca()
        ax.set_title('LGM - Centred dipole [-%d, 0, 0]$_{SM}$; PA=%d$^{o}$' % (rval, alpha))
        ax.set_ylabel('L* (LanlGeoMag)')
        ax.set_xlabel('Quality Flag')
        ax.set_xticklabels([str(n) for n in range(5)])
        
        tb.savepickle('lgm_cdip_lstar%d_alpha%d.pkl' % (rval, alpha), {'Lstar': Lstar})
    
        plt.ylim([rval-0.04, rval+0.04])
        plt.savefig('lgm_cdip_verify%d.png' % alpha, dpi=300)
Exemplo n.º 4
0
def runQs():
    #make figure
    fig = plt.figure(figsize=(17, 21))

    #set up test runs
    nvals, rvals = 5, [2, 3, 4, 5, 6]
    dates = spt.tickrange('2001-04-22T12:00:00', '2001-04-23T23:00:00', 1 / 24)
    alpha = 45

    #loop over radial positions, dates and quality flags
    for rval in rvals:
        Lstar = [[]] * nvals
        for date, qual in itertools.product(dates.UTC, range(nvals)):
            pos = dm.dmarray([-1 * rval, 0, 0], attrs={'sys': 'SM'})
            data = lgmpy.get_Lstar(pos,
                                   date,
                                   alpha=alpha,
                                   coord_system='SM',
                                   Bfield='Lgm_B_cdip',
                                   LstarThresh=20.0,
                                   extended_out=True,
                                   LstarQuality=qual)
            try:
                Lstar[qual].extend(data[alpha]['Lstar'])
            except TypeError:
                Lstar[qual].append(data[alpha]['Lstar'].tolist())
        print('Did [-%d,0,0] for all qualities' % rval)
        #make plots
        fstr = '%d1%d' % (len(rvals), rval - rvals[0] + 1)
        ax = fig.add_subplot(fstr)
        ax.boxplot(Lstar)
        #ax = plt.gca()
        ax.set_title('LGM - Centred dipole [-%d, 0, 0]$_{SM}$; PA=%d$^{o}$' %
                     (rval, alpha))
        ax.set_ylabel('L* (LanlGeoMag)')
        ax.set_xlabel('Quality Flag')
        ax.set_xticklabels([str(n) for n in range(5)])

        tb.savepickle('lgm_cdip_lstar%d_alpha%d.pkl' % (rval, alpha),
                      {'Lstar': Lstar})

        plt.ylim([rval - 0.04, rval + 0.04])
        plt.savefig('lgm_cdip_verify%d.png' % alpha, dpi=300)
Exemplo n.º 5
0
 def test_assemble(self):
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_1.pkl'), self.D1)
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_2.pkl'), self.D2)
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_3.pkl'), self.D3)
     expected = self.all
     result = tb.assemble(os.path.join(self.tempdir, 'test_pickle_[1-3].pkl'), os.path.join(self.tempdir, 'test_all.pkl'), sortkey=None, verbose=False)
     for key in result:
         result[key] = result[key].tolist()
     self.assertEqual(expected, result)
Exemplo n.º 6
0
 def test_assemble(self):
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_1.pkl'), self.D1)
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_2.pkl'), self.D2)
     tb.savepickle(os.path.join(self.tempdir, 'test_pickle_3.pkl'), self.D3)
     expected = self.all
     result = tb.assemble(os.path.join(self.tempdir, 'test_pickle_[1-3].pkl'), os.path.join(self.tempdir, 'test_all.pkl'), sortkey=None, verbose=False)
     for key in result:
         result[key] = result[key].tolist()
     self.assertEqual(expected, result)