Exemplo n.º 1
0
    def test_simple_density(self):
        x = num.linspace(0., 2.*math.pi, 50)
        y = num.linspace(0., 2.*math.pi, 50)

        x2 = num.tile(x, y.size)
        y2 = num.repeat(y, x.size)
        z2 = num.sin(x2) * num.sin(y2)

        for version in gmtpy.all_installed_gmt_versions():
            for method in ['surface', 'triangulate', 'fillcontour']:
                plot = gmtpy.Simple(gmtversion=version, with_palette=True)
                plot.density_plot((x2, y2, z2), method=method)
                fname = 'gmtpy_test_simple_density_%s.png' % method
                fpath = self.fpath(fname)
                plot.save(fpath)
Exemplo n.º 2
0
    def test_simple(self):

        x = num.linspace(0., 2*math.pi)
        y = num.sin(x)
        y2 = num.cos(x)

        for version in gmtpy.all_installed_gmt_versions():
            for ymode in ['off', 'symmetric', 'min-max', 'min-0', '0-max']:
                plot = gmtpy.Simple(gmtversion=version, ymode=ymode)
                plot.plot((x, y), '-W1p,%s' % gmtpy.color('skyblue2'))
                plot.plot((x, y2), '-W1p,%s' % gmtpy.color(
                    gmtpy.color_tup('scarletred2')))
                plot.text((3., 0.5, 'hello'), size=20.)
                fname = 'gmtpy_test_simple_%s.png' % ymode
                fpath = self.fpath(fname)
                plot.save(fpath)
Exemplo n.º 3
0
def plot(func, filename, **kwargs):
    nlats, nlons = 91, 181
    lats = num.linspace(-90., 90., nlats)
    lons = num.linspace(-180.,180., nlons)
        
    vecfunc = num.vectorize( func, [ num.float ] )
    latss, lonss = num.meshgrid(lats, lons)         
    thickness = vecfunc(latss, lonss)
    
    import gmtpy
    cm = gmtpy.cm
    marg = (1.5*cm, 2.5*cm, 1.5*cm, 1.5*cm)
    p = gmtpy.Simple(width=20*cm, height=10*cm, margins=marg, 
        with_palette=True, **kwargs)
    
    p.density_plot(gmtpy.tabledata(lons,lats, thickness.T))
    p.save(filename)
Exemplo n.º 4
0
def mktrace(n):
    tmin = 1234567890.
    t = trace.Trace(tmin=tmin, deltat=0.05, ydata=num.empty(n,dtype=num.float))
    return t
    
def bandpass(t):
    t.bandpass(4, 0.1, 5.)
    
def lowpass_highpass(t):    
    t.lowpass(4,  5.)
    t.highpass(4, 0.1)

def bandpass_fft(t):
    t.bandpass_fft(0.1, 5.)
    
tab = []
for n in range(1,22):
    a = timeit(lambda: bandpass(mktrace(2**n)))
    b = timeit(lambda: lowpass_highpass(mktrace(2**n)))
    c = timeit(lambda: bandpass_fft(mktrace(2**n)))
    print 2**n, a, b, c
    tab.append((2**n, a,b,c))
   
a = num.array(tab).T
p = gmtpy.Simple()

for i in range(1,4):
    p.plot((a[0],a[i]), '-W1p,%s' % gmtpy.color(i))

p.save('speed_filtering.pdf')