Exemplo n.º 1
0
def main10():
    amp = 16385
    Tao = 10E-6
    Ts = 1E-8
    m1 = 297
    m2 = 0.297  #0.0515
    noi = 0

    t, s = Signal(Ts, Tao, amp=amp)
    snoise = noise(s, noi)

    spz = poleZero(snoise, Tao, Ts)
    rn, sn = trapez(spz, m1, m2)
    max_ = PHA(sn)

    print np.floor(sn[0:100])

    print max_

    import biggles
    p = biggles.FramedPlot()
    p.add(biggles.Curve(np.arange(sn.shape[0])[20:70], sn[20:70],
                        color='blue'))
    p.add(biggles.Slope(0, color='green'))
    p.show()
Exemplo n.º 2
0
    def test_example2(self):
        p = biggles.FramedPlot()
        p.xrange = 0, 100
        p.yrange = 0, 100
        p.aspect_ratio = 1

        x = numpy.arange(0, 100, 5)
        yA = numpy.random.normal(40, 10, size=len(x))
        yB = x + numpy.random.normal(0, 5, size=len(x))

        a = biggles.Points(x, yA, type="circle")
        a.label = "a points"

        b = biggles.Points(x, yB)
        b.label = "b points"
        b.style(type="filled circle")

        l = biggles.Slope(1, type="dotted")
        l.label = "slope"

        k = biggles.PlotKey(.1, .9)
        k += a
        k += b, l

        p.add(l, a, b, k)

        _write_example(2, p)
Exemplo n.º 3
0
def add_curves(ax,
               x,
               y,
               lp,
               i,
               set_points=True,
               lock_levels=True,
               intervals=True,
               slopes=True,
               insets=True):
    if set_points and lp.haskey('lock_x'):
        ax.add(biggles.LineX(lp['lock_x'][i] * scale))
    if lock_levels and lp.haskey('lock_y'):
        ax.add(biggles.LineY(lp['lock_y'][i] * scale))
    if intervals and lp.haskey('left_x'):
        ax.add(biggles.LineX(lp['left_x'][i] * scale, type='dashed'))
    if intervals and lp.haskey('right_x'):
        ax.add(biggles.LineX(lp['right_x'][i] * scale, type='dashed'))
    if slopes:
        for d in ['up', 'dn']:
            if not lp.haskey('lock_%s_sl' % d): continue
            m, x0, y0 = [
                lp['lock_%s' % (e)][i]
                for e in ['%s_sl' % d, '%s_x' % d, 'y']
            ]
            ax.add(biggles.Slope(m, (x0 * scale, y0 * scale), type='dashed'))
Exemplo n.º 4
0
def draw(t, in_, out):

    import biggles

    p = biggles.FramedPlot()
    p.add(biggles.Curve(t, out, color='blue'))
    p.add(biggles.Curve(t, in_, color='red'))
    p.add(biggles.Slope(0, color='green'))
    p.show()
Exemplo n.º 5
0
    def test_labels(self):
        import numpy
        from numpy import linspace

        key = biggles.PlotKey(0.1, 0.9, halign='left')

        plt = biggles.FramedPlot(key=key, aspect_ratio=1)

        err = 0.1
        x = numpy.arange(10)
        y = numpy.arange(10)**2

        err = numpy.zeros(x.size) + 2
        ydata = y + numpy.random.normal(size=x.size) * err

        color = 'red'
        pts = biggles.Points(x,
                             ydata,
                             color=color,
                             type='filled diamond',
                             label='data')
        errpts = biggles.SymmetricErrorBarsY(x,
                                             ydata,
                                             err,
                                             color=color,
                                             label='data')

        model = biggles.Curve(x, y, label='model')

        plt += biggles.Polygon([0, 8, 4], [0, 0, 30],
                               color='grey20',
                               label='triangle')

        plt += [model, pts, errpts]

        plt += biggles.Point(4,
                             4,
                             type='filled circle',
                             color='cyan',
                             label='other')

        # Go from light blue to intense red.
        np = 30
        xp = linspace(0.5, 4, np)
        yp = 20 + 5 * xp.copy()
        minColor = [0.6, 0.9, 1.0]
        maxColor = [1.0, 0.2, 0.2]

        colors = numpy.zeros((np, 3))
        colors[:, 0] = numpy.interp(xp, xp,
                                    linspace(minColor[0], maxColor[0], np))
        colors[:, 1] = numpy.interp(xp, xp,
                                    linspace(minColor[1], maxColor[1], np))
        colors[:, 2] = numpy.interp(xp, xp,
                                    linspace(minColor[2], maxColor[2], np))

        plt += biggles.ColoredPoints(
            xp,
            yp,
            colors,
            type='cross',
            size=1,
            label='grad',
        )

        plt += biggles.LineX(5, color='green', label='lineY')
        plt += biggles.LineY(5, color='magenta', type='dashed', label='lineX')

        plt += biggles.Slope(-3, (0, 40), color='Hot Pink', label='slope')

        plt += biggles.DataBox([5.5, 70], [6.5, 80],
                               color='Dodger Blue',
                               label='box')

        # label doesn't work, nor does ellipses.  fundamental perhaps
        #plt += Circle(6.0, 75.0, 1,  color='yellow', label='circle')

        # not even sure how DataArc works
        #plt += DataArc(6.0, 75.0, 1,  color='yellow', label='circle')

        _write_example('labels', plt)
Exemplo n.º 6
0
import biggles
import numpy
import numpy.random

p = biggles.FramedPlot()
p.xrange = 0, 100
p.yrange = 0, 100
p.aspect_ratio = 1

x = numpy.arange( 0, 100, 5 )
yA = numpy.random.normal( 40, 10, (len(x),) )
yB = x + numpy.random.normal( 0, 5, (len(x),) )

a = biggles.Points( x, yA, type="circle" )
a.label = "a points"

b = biggles.Points( x, yB )
b.label = "b points"
b.style( type="filled circle" )

l = biggles.Slope( 1, type="dotted" )
l.label = "slope"

k = biggles.PlotKey( .1, .9, [a,b,l] )

p.add( l, a, b, k )

#p.write_img( 400, 400, "example2.png" )
#p.write_eps( "example2.eps" )
p.show()
Exemplo n.º 7
0
def plot(
    x,
    y,
    y_rc,
    lock_points,
    plot_file,
    shape=(4, 2),
    img_size=None,
    scale=1. / 1000,
    title=None,
    xlabel=None,
    ylabel=None,
    titles=None,
    rows=None,
    cols=None,
    insets=None,
    lock_levels=True,
    set_points=False,
    intervals=False,
    slopes=False,
    scale_style='tight',
    label_style='row_col',
    format=None,
):

    nr, nc = y_rc
    cl, rl, rcl = False, False, False
    if label_style == 'col_only':
        cl = True
    elif label_style == 'row_col':
        rcl = True

    if slopes == True:

        def get(key, param):
            return lock_points.get('lock_%s%s' % (key, param), None)

        slopes = []
        for d in ['', 'up_', 'dn_']:
            m, x0, y0 = [get(d, p) for p in ['slope', 'x', 'y']]
            if m is not None:
                if y0 is None:
                    # Use default y-target if separate up/dn aren't there.
                    y0 = get('', 'y')
                slopes.append(zip(m, x0, y0))

    pl = util.plotGridder(y_rc,
                          plot_file,
                          title=title,
                          xlabel=xlabel,
                          ylabel=ylabel,
                          target_shape=shape,
                          img_size=img_size,
                          col_labels=cl,
                          rowcol_labels=rcl,
                          format=format)

    for r, c, ax in pl:
        if r >= nr or c >= nc: continue
        i = c + r * nc
        if set_points:
            ax.add(biggles.LineX(lock_points['lock_x'][i] * scale))
        if lock_levels:
            ax.add(biggles.LineY(lock_points['lock_y'][i] * scale))
        if intervals:
            ax.add(
                biggles.LineX(lock_points['left_x'][i] * scale, type='dashed'))
            ax.add(
                biggles.LineX(lock_points['right_x'][i] * scale,
                              type='dashed'))
        if slopes != False:
            for s in slopes:
                m, x0, y0 = s[i]
                ax.add(
                    biggles.Slope(m, (x0 * scale, y0 * scale), type='dashed'))
        if insets is not None:
            ax.add(
                biggles.PlotLabel(0.,
                                  0.,
                                  insets[i],
                                  halign='left',
                                  valign='bottom'))
        if x.shape == y.shape:
            ax.add(biggles.Curve(x[i] / 1000., y[i] / 1000.))
        else:
            ax.add(biggles.Curve(x / 1000., y[i] / 1000.))

        if scale_style == 'roll-off':
            # Prevent small signals from causing large tick labels
            hi, lo = amax(y[i]) / 1000, amin(y[i]) / 1000
            if hi - lo < 4:
                mid = (hi + lo) / 2
                ax.yrange = (mid - 2, mid + 2)
        elif scale_style == 'tight':
            hi, lo = amax(y[i]) / 1000., amin(y[i]) / 1000.
            dx = (hi - lo) * .1
            if dx <= 0:  # Never set a 0-size yrange.
                dx = 0.5
            ax.yrange = lo - dx, hi + dx
            if x.shape == y.shape:
                ax.xrange = x[i][0] / 1000., x[i][-1] / 1000.
            else:
                ax.xrange = x[0] / 1000., x[-1] / 1000.

    pl.cleanup()
    return {
        'plot_files': pl.plot_files,
    }