Exemplo n.º 1
0
def plot_snr_scatter(cv, foreground, background, lodm, hidm, marker_dms,
                     fallback):
    '''
    Add SNR versus DM scatter plot pulsetrain diagnostic plot.

    Note: for internal use, call the diagnostic.plot() function in stead.
    '''
    pc2 = PlotContainer(740, 150, 300, 600, data_padding=PADDING)
    pc2.right.hide_label()
    pc2.right.hide_tickmarklabels()
    pc2.left.hide_label()
    pc2.left.hide_tickmarklabels()
    pc2.bottom.hide_label()
    pc2.top.set_label('SNR')
    scp2 = ScatterPlotter([x[1] for x in foreground],
                          [x[0] for x in foreground], color='red')
    scp3 = ScatterPlotter([x[1] for x in background],
                          [x[0] for x in background], color='black')
    pc2.add(scp3, fallback)
    pc2.add(scp2, fallback)
    pc2.set_minimum_y_range(lodm, hidm)
    for m_dm in marker_dms:
        if lodm <= m_dm <= hidm:
            pc2.add(YLimitPlotter(m_dm, color='orange'))
    cv.add(pc2)
Exemplo n.º 2
0
def plot_count_histogram(cv, dms, foreground, background, lodm, hidm,
                         marker_dms):
    '''
    Add candidates per DM histogram to pulse train diagnostic.

    Note: for internal use, call the diagnostic.plot() function in stead.
    '''
    # Determine the brp style histogram bins:
    fg_bins, bg_bins, total_bins = \
        bin_candidates(dms, foreground, background, lodm, hidm)

    # Plot histogram of number of detections per DM trial
    pc3 = PlotContainer(950, 150, 300, 600, data_padding=PADDING)
    pc3.left.hide_label()
    pc3.left.hide_tickmarklabels()
    pc3.bottom.hide_label()
    pc3.top.set_label('N')
    pc3.add(HistogramPlotter(bg_bins, orientation='vertical', color='black'))
    pc3.add(HistogramPlotter(total_bins, orientation='vertical', color='gray'))
    pc3.add(HistogramPlotter(fg_bins, orientation='vertical', color='red'))
    pc3.right.set_label('DM')
    pc3.set_minimum_y_range(lodm, hidm)

    for m_dm in marker_dms:
        if lodm <= m_dm <= hidm:
            pc3.add(YLimitPlotter(m_dm, color='orange'))

    cv.add(pc3)
Exemplo n.º 3
0
def plot_main_panel(cv, foreground, background, lodm, hidm, marker_dms,
                    fallback):
    '''
    Add main panel to pulsetrain diagnostic plot.

    Note: for internal use, call the diagnostic.plot() function in stead.
    '''
    # Main panel, detections on the time-DM plane
    pc1 = PlotContainer(0, 150, 830, 600, data_padding=PADDING)
    pc1.right.hide_label()
    pc1.right.hide_tickmarklabels()
    pc1.bottom.hide_label()
    pc1.left.set_label('DM')
    pc1.top.set_label('Time (s)')
    pc1.add(DetectionPlotterTuples(background, color='black'), fallback)
    pc1.add(DetectionPlotterTuples(foreground, color='red'), fallback)
    pc1.set_minimum_y_range(lodm, hidm)

    for m_dm in marker_dms:
        if lodm <= m_dm <= hidm:
            pc1.add(YLimitPlotter(m_dm, color='orange'))

    cv.add(pc1)
Exemplo n.º 4
0
    c.top.hide_all()
    c.bottom.hide_all()
    c.left.hide_label()
    c.left.hide_tickmarklabels()
    c.right.set_label('Significance (sigma)')
    c.add_plotter(GradientPlotter(gr2))
    cv.add_plot_container(c)
    # ------------------------------------------------------
    # -- For debugging raster fallback ---------------------

    # Note: this also tests the 'new' shortcuts on SVGCanvas and PlotContainer

    # The raster fallback might still have some off-by-one problems.

    gr = RGBGradient((0, 25), (0, 0, 1), (1, 0, 0))
    gr2 = RGBGradient((0, 25), (1, 0, 0), (0, 0, 1))
    c = PlotContainer(100, 1900, 600, 400)
    xdata = list(range(25))
    c.add(ScatterPlotter(xdata, symbols=[RasterDebugSymbol]), True)
    c.add(ScatterPlotter(xdata, symbols=[RasterDebugSymbol]))
    xdata.reverse()
    colors = ['yellow' for x in xdata]
    c.add(ScatterPlotter(xdata, symbols=[BaseSymbol], colors=colors))
    c.add(ScatterPlotter(xdata, gradient=gr, gradient_i=0), True)
    cv.add(c)

    #
    # ------------------------------------------------------

    cv.draw(sys.stdout)
Exemplo n.º 5
0
    c.top.hide_all()
    c.bottom.hide_all()
    c.left.hide_label()
    c.left.hide_tickmarklabels()
    c.right.set_label("Significance (sigma)")
    c.add_plotter(GradientPlotter(gr2))
    cv.add_plot_container(c)
    # ------------------------------------------------------
    # -- For debugging raster fallback ---------------------

    # Note: this also tests the 'new' shortcuts on SVGCanvas and PlotContainer

    # The raster fallback might still have some off-by-one problems.

    gr = RGBGradient((0, 25), (0, 0, 1), (1, 0, 0))
    gr2 = RGBGradient((0, 25), (1, 0, 0), (0, 0, 1))
    c = PlotContainer(100, 1900, 600, 400)
    xdata = list(range(25))
    c.add(ScatterPlotter(xdata, symbols=[RasterDebugSymbol]), True)
    c.add(ScatterPlotter(xdata, symbols=[RasterDebugSymbol]))
    xdata.reverse()
    colors = ["yellow" for x in xdata]
    c.add(ScatterPlotter(xdata, symbols=[BaseSymbol], colors=colors))
    c.add(ScatterPlotter(xdata, gradient=gr, gradient_i=0), True)
    cv.add(c)

    #
    # ------------------------------------------------------

    cv.draw(sys.stdout)
Exemplo n.º 6
0
    cv = SVGCanvas(1200, 1800)

# ------------------------------------------------------
# -- For debugging RADECSymbol raster fallback ---------

    NPULSARS = 100
    P = [random.uniform(0.001, 10) for i in range(NPULSARS)]
    DM = [random.uniform(1, 100) for i in range(NPULSARS)]
    RA = [random.uniform(0, 24) for i in range(NPULSARS)]
    DEC = [random.uniform(-90, 90) for i in range(NPULSARS)]
    SIGMA = [random.uniform(2, 15) for i in range(NPULSARS)]

    # plot
    pc = PlotContainer(0, 0, 600, 400)
    pc.add(ScatterPlotter(P, DM, RA, DEC, SIGMA, symbol=RADECSymbol))
    cv.add(pc)

    pc = PlotContainer(600, 0, 600, 400)
    pc.add(ScatterPlotter(P, DM, RA, DEC, SIGMA, symbols=[RADECSymbol]),
           raster=True)
    cv.add(pc)

# ------------------------------------------------------
# -- For debugging error bar raster fallback -----------

# LINEAR TRANSFORM CASE:

#    c = PlotContainer(0, 400, 600, 400, x_log=True, y_log=True)
    c = PlotContainer(600, 400, 600, 400)
    data_y = [10, 10, 20, 30, 40, 50, 40, 30, 20, 10, 10]
Exemplo n.º 7
0
from brp.svg.plotters.gradient import GradientPlotter
from brp.svg.plotters.line import LinePlotter

if __name__ == '__main__':

    x_data = [r() for i in range(1000)]
    y_data = [r() for i in range(1000)]

    cv = SVGCanvas(1200, 800)

    p = PlotContainer(0, 0, 600, 400)
    h = newhist2d.Histogram2dPlotter(x_data, y_data, x_bins=100)
    gr = h.get_gradient()
    collapsed_x, yvalues = h.collapse_x()
    xvalues, collapsed_y = h.collapse_y()
    p.add(h)
    cv.add(p)

    p = PlotContainer(800, 0, 160, 400)
    p.add(GradientPlotter(gr, 'vertical'))
    cv.add(p)

    p = PlotContainer(600, 0, 200, 400)
    p.add(LinePlotter(collapsed_x, yvalues))
    cv.add(p)

    p = PlotContainer(0, 400, 600, 200)
    p.add(LinePlotter(xvalues, collapsed_y))
    cv.add(p)

    cv.draw(sys.stdout)
Exemplo n.º 8
0
import sys
#sys.path.append('../')

from brp.svg.base import SVGCanvas, PlotContainer, TextFragment
from brp.svg.plotters.histogram import HistogramPlotter, merge_bins

if __name__ == '__main__':
    bins = [(0, 1, 10), (1, 2, 10), (2, 3, 11), (3, 4, 10), (4, 5, 10),
            (5, 6, 7)]

    cv = SVGCanvas(1200, 1200)

    # Histogram testing:
    c = PlotContainer(0, 0, 600, 400)
    c.add(HistogramPlotter(bins))
    cv.add(c)
    cv.add(TextFragment(100, 100, 'Unmerged bins', color='red'))

    merged = merge_bins(bins)

    c2 = PlotContainer(600, 0, 600, 400)
    c2.add(HistogramPlotter(merged))
    cv.add(c2)
    cv.add(TextFragment(700, 100, 'Merged bins', color='red'))

    cv.draw(sys.stdout)