Пример #1
0
def visualizePlot(areaMat,
                  pos_symbol='circle',
                  neg_symbol='circle',
                  pos_color='red',
                  neg_color='blue',
                  label=None,
                  posRange=None):
    plots = []

    ## get grid lines
    plots = plotLines(models, ref=(1, 1))

    ## get color points
    pos, neg = categorize(areaMat, posRange)

    for r in range(shape(areaMat)[0]):
        for l in range(shape(areaMat)[1]):
            plots += [ biggles.Point( r+1, l+1, color=pos_color, size=pos[r][l], \
                                       type=pos_symbol ) ]
            plots += [ biggles.Point( r+1, l+1, color=neg_color, size=neg[r][l], \
                                       type=neg_symbol ) ]

    ## get labels
    if label:
        plots += plotMatrixLabels(areaMat, color='dark slate grey')

    return plots
Пример #2
0
    def ramachandran(self):
        """
        Create all the ramachandran plot points.

        @return: list of biggles.Point objects (all the points of the
                 plot)and a biggles.Inset object (property scale).
        @rtype: [ biggles.Point ], biggles.Inset
        """
        p = []

        ## calculate colors and create a legend if a property is given
        if self.profileName:
            palette = CS('plasma', 0, 100)
            col = palette.color_array(self.prof)

            legend = Legend(palette.legend())
            inset = biggles.Inset((1.1, 0.60), (1.2, .97), legend)

        else:
            col = ['black'] * len(self.phi)
            inset = None

        ## add data points to plot
        for i in range(len(self.phi)):
            ## don't add termini - has missing angles
            if self.phi[i] and self.psi[i]:
                if i in self.gly:
                    p += [
                        biggles.Point(self.psi[i],
                                      self.phi[i],
                                      type="star",
                                      size=1,
                                      color=col[i])
                    ]
                elif i in self.pro:
                    p += [
                        biggles.Point(self.psi[i],
                                      self.phi[i],
                                      type="filled square",
                                      size=1,
                                      color=col[i])
                    ]
                else:
                    p += [
                        biggles.Point(self.psi[i],
                                      self.phi[i],
                                      type="filled circle",
                                      size=1,
                                      color=col[i])
                    ]
        return p, inset
Пример #3
0
def contourPlot( data, inverse=0, symbol='filled circle', label=None,
                 maxContour=None ):
    plots = []
    
    ## get grid lines
    plots = plotLines( len(data) )

    ## get data points
    cutoffs = [ 0.01, .1, .2, .3, .4, .5, .6, .7, .8, .9 ]
    if inverse:
        cutoffs = 1./array([ 15, 10, 8, 6, 5, 4, 3, 2, 1 ])
    data = moreDockingInfo( data, levels=cutoffs )

    ## callculate symbol size
    if maxContour:
        max_data = maxContour*1.
    else:
        max_data = max( ravel(data) )*1.

    max_symbol_size = 15
    scale_factor = max_data/(max_symbol_size**2)

    def scaleCircle( value ):
        return int(round(sqrt(value/scale_factor)))
    
    ## colors
    col = colorSpectrum( len(cutoffs))
    col.reverse()
    col=['light grey'] + col[1:]
    label_col = ['dark grey'] + col[1:]

    range_max = []
    range_min = []

    for i in range(len(cutoffs)):
        range_max += [ max( ravel( data[:,:,i] ) ) ]
        range_min += [ min( ravel( data[:,:,i] ) ) ]

        for r in range( shape(data)[0] ):

            for l in range( shape(data)[1] ):
        
                plots += [ biggles.Point( r+1, l+1,
                                          color=col[i],
                                          size=scaleCircle(data[r][l][i]),
                                          type=symbol ) ]
        
    ## legend
    plots += [ biggles.PlotLabel( 1.04, .98, 'FNC>', size=2 ) ]         
    for i in range( len(cutoffs) ):
        if sum( take(data, (i,), 2) )>0:
##             plots += [ biggles.PlotLabel( 1.03, .95-i*0.03, str(i*.1),
##                                           color=label_col[i],size=2 ) ]
            plots += [ biggles.PlotLabel( 1.03, .95-i*0.03, '%.2f'%cutoffs[i],
                                          color=label_col[i],size=2 ) ]
            plots += [ biggles.PlotLabel( 1.03, .35-i*0.02,
                                          str(range_min[i])+'-'+str(range_max[i]),
                                          color=label_col[i],size=1 ) ]

    return plots
Пример #4
0
def test_1gauss_T_recovery(noise,
                           T=8.0,
                           counts=1.0,
                           ntrial=100,
                           show=True,
                           png=None):
    import biggles

    T_true=T

    T_meas=numpy.zeros(ntrial)
    for i in xrange(ntrial):
        while True:
            try:
                gm=test_1gauss(
                    noise=noise,
                    T=T_true,
                    counts=counts,
                    verbose=False,
                )
                T=gm.get_T()
                T_meas[i]=T
                break
            except GMixRangeError:
                pass
            except GMixMaxIterEM:
                pass

    mean=T_meas.mean()
    std=T_meas.std()
    print("<T>:",mean,"sigma(T):",std)
    binsize=0.2*std
    plt=biggles.plot_hist(T_meas, binsize=binsize, visible=False)
    p=biggles.Point(T_true, 0.0, type='filled circle', size=2, color='red')
    plt.add(p)
    plt.title='Flux: %g T: %g noise: %g' % (counts, T_true, noise)

    xmin=mean-4.0*std
    xmax=mean+4.0*std

    plt.xrange=[xmin, xmax]

    if show:
        plt.show()

    if png is not None:
        print(png)
        plt.write_img(800, 800, png)
Пример #5
0
    def ramachandran_background(self):
        """
        Creates a background (favoured regions) for a ramachandran plot.

        @return: list of biggles.Point objects
        @rtype: [ biggles.Point ]
        """
        bg = []
        mat = N0.loadtxt(T.dataRoot() + '/biggles/ramachandran_bg.dat')
        x, y = N0.shape(mat)
        for i in range(x):
            for j in range(y):
                if mat[i, j] < 200:
                    a = (360. / y) * j - 180
                    b = (360. / x) * (x - i) - 180
                    bg += [biggles.Point(a, b, type="dot")]
        return bg
Пример #6
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)