How to use the spacepy.time.tickrange function in spacepy

To help you get started, we’ve selected a few spacepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github drsteve / LANLGeoMag / Python / scripts / lgm_dipole_verify.py View on Github external
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)))
github drsteve / LANLGeoMag / Python / scripts / lgm_dipole_verify.py View on Github external
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)