Ejemplo n.º 1
1
 def draw_Q(self, a, b, da):
     t = Task1(a, b)
     x1 = []
     y1 = []
     x2 = []
     y2 = []
     while a < b:
         x1.append(a)
         x2.append(a)
         y1.append(t.calculate_q())
         y2.append(t.calculate_qx())
         a += da
         t.reload(a, b)
     gp.s([x1, y1], filename='tmp1.dat')
     gp.s([x2, y2], filename='tmp2.dat')
     gp.c('set xlabel "Значение а"')
     gp.c('set ylabel "Значение функции"')
     gp.c(
         'set title "Графики зависимостей показателей Q и Q* от значений a"'
     )
     gp.c('set yrange [0:5]')
     gp.c(
         'plot "tmp1.dat" u 1:2 w i title "VarN(a)", "tmp2.dat" u 1:2 w i title "VarN*(a)"'
     )
     gp.pdf("Q.pdf")
def main(*args):
    try:

        dv_file = int(sys.argv[1])
        cxn = labrad.connect()
        dv = cxn.data_vault
        dv.cd(['', 'he_level'])
        dv.open(dv_file)
        x, y = dv.get_ex_t()
        x = np.array(x)
        xp = np.zeros(len(x))
        y = np.array(y)
        for k in range(0, len(x)):
            structtime = time.localtime(x[k])
            xp[k] = structtime.tm_hour + float(structtime.tm_min) / 60

        gp.s(
            [xp, y]
        )  #,filename='"C:\\Users\\Feldman Lab\\code\\Setup_BF122019\\LabRAD-Device-Electrical_Measurement-ONline_Software-pyqt5\\DEMONS GUI\\Scripts\\tmp.dat"')
        title = time.strftime("%a, %d %b %Y", time.localtime(x[0]))
        time.sleep(2)
        gp.c(
            'set terminal wxt size 500,500 position -1900,400 enhanced persist'
        )
        gp.c('set title ' + '"' + title + '"')
        gp.c('set xlabel "hours"')
        gp.c('set ylabel "percent"')
        gp.c('plot "tmp.dat" w lp')

    except Exception as e:
        print(e)
Ejemplo n.º 3
0
def plot_peaks(peaks, peaks_max, suffix, det):
    plot_name = '20_peaks'
    if len(peaks) == 0:
        return
    dummy, fname = tempfile.mkstemp(prefix='tmp_peaks_%03d' % det,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_name, det_feat = detector_name(det)
    os.makedirs(os.path.join(cfg.global_odir, det_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_name + ' ' + det_feat +
         ' - signal peaks" at graph 0, graph 1.04 noenhanced')
    gp.s([peaks, peaks_max], filename=fname)
    gp.c('set auto fix')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c('set log y')
    gp.c('set ylabel "Amplitude (V)"')
    gp.c('set xlabel "Time (h)"')
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot "' + fname + '"' +
             " u (hour($1)):($2) not w p pt 6 ps 0.125 lt 6")
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 4
0
def plot_amplitude(maxima, suffix, det):
    plot_name = '00_amplitude'
    dummy, fname = tempfile.mkstemp(prefix='tmp_amplitude_%03d' % det,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_name, det_feat = detector_name(det)
    xmin = cfg.cfg.getfloat("plot", "ampl_min", fallback=0.)
    xmax = cfg.cfg.getfloat("plot", "ampl_max", fallback=1.)
    xbin = cfg.cfg.getfloat("plot", "ampl_bin", fallback=1000)
    os.makedirs(os.path.join(cfg.global_odir, det_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    #values, edges = np.histogram(maxima, bins=1500, range=(xmin, xmax), density=False)
    values, edges = np.histogram(maxima, bins=1500, density=False)
    gp_set_defaults()
    gp.c('set label "' + det_name + ' ' + det_feat +
         ' - amplitude spectrum" at graph 0, graph 1.04 noenhanced')
    gp.c('set log y')
    gp.c('set log x')
    gp.c('set ylabel "Events / V"')
    gp.c('set xlabel "Amplitude (V)"')
    gp.s([edges[:-1], values], filename=fname)
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot [][0.5:] "' + fname + '" u 1:2 not w histep lt 6')
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 5
0
def plot_fft_rate(freq, power, suffix, det):
    plot_name = 'XX_fft_rate'
    dummy, fname = tempfile.mkstemp(prefix='tmp_fft_rate_%03d' % det,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_name, det_feat = detector_name(det)
    os.makedirs(os.path.join(cfg.global_odir, det_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_name + ' ' + det_feat +
         '" at graph 0, graph 1.04 noenhanced')
    gp.s([freq, power], filename=fname)
    gp.c('set auto fix')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c('set log y')
    gp.c('set ylabel ""')
    gp.c('set xlabel "Frequency (1/min)"')
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot [][] "' + fname + '" u ($1 * 60):2 not w l lt 6')
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 6
0
def plot_fft_data(freq, power, suffix, det):
    plot_name = '30_fft_data'
    dummy, fname = tempfile.mkstemp(prefix='tmp_fft_data_%03d' % det,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_name, det_feat = detector_name(det)
    os.makedirs(os.path.join(cfg.global_odir, det_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_name + ' ' + det_feat +
         '" at graph 0, graph 1.04 noenhanced')
    gp.s([freq, power], filename=fname)
    gp.c('set auto fix')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c('set log y')
    gp.c('set mytics 10')
    gp.c('set log x')
    gp.c('set mxtics 10')
    #gp.c('set ylabel "Power Spectral Density (V^2 / Hz)"')
    gp.c('set ylabel "Noise FFT (V / √Hz)"')
    gp.c('set format y "10^{%L}"')
    gp.c('set xlabel "Frequency (Hz)"')
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot [1:][] "' + fname + '" u 1:(sqrt($2)) not w l lt 6')
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 7
0
def plot_rate(rate, window, suffix, det):
    plot_name = 'XX_rate'
    dummy, fname = tempfile.mkstemp(prefix='tmp_rate_%03d' % det,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_name, det_feat = detector_name(det)
    os.makedirs(os.path.join(cfg.global_odir, det_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_name + ' ' + det_feat +
         '" at graph 0, graph 1.04 noenhanced')
    gp.s([rate], filename=fname)
    gp.c('set auto fix')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c('set ylabel "Rate (Hz)"')
    gp.c('set xlabel "Time (h)"')
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot [][] "' + fname + '" u ($0 / 3600.):($1/' + str(window) +
             ') not w l lt 6')
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 8
0
def plot_baseline(base, base_min, suffix, det):
    plot_name = '10_baseline'
    if len(base) == 0:
        return
    dummy, fname = tempfile.mkstemp(prefix='tmp_baseline_%03d' % det,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_name, det_feat = detector_name(det)
    os.makedirs(os.path.join(cfg.global_odir, det_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_name + ' ' + det_feat +
         ' - baseline" at graph 0, graph 1.04 noenhanced')
    gp.s([base, base_min], filename=fname)
    gp.c('set auto fix')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c('set ytics nomirror')
    gp.c('set ylabel "Amplitude (V)"')
    gp.c('set xlabel "Time (h)"')
    #gp.c('set yrange [%f:%f]' % (pmin, pmax))
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot "' + fname + '"' + " u (hour($1)):($2) not w l lt 6")
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 9
0
    def draw_D(self, a, b, da):
        t = Task1(a, b)
        x1 = []
        y1 = []
        x2 = []
        y2 = []
        while a < b:
            x1.append(a)
            x2.append(a)
            y1.append(t.calculate_Dw())
            y2.append(t.calculate_Dv())
            a += da
            t.reload(a, b)
        gp.s([x1, y1], filename='tmp1.dat')
        gp.s([x2, y2], filename='tmp2.dat')
        gp.c('set xlabel "Значение а"')
        gp.c('set ylabel "Значение функции"')
        gp.c(
            'set title "Графики зависимостей показателей Dw и Dv от значений a"'
        )
        gp.c('set yrange [0:5]')
        gp.c(
            'plot "tmp1.dat" u 1:2 w l title "Dw(a)", "tmp2.dat" u 1:2 w l title "Dv(a)"'
        )
        gp.pdf("D.pdf")


# g = Graphics()
# g.draw_D(0.1, 0.7, 0.001)
# t = Task1(0.3,0.4)
# print(t.calculate_VarN())
Ejemplo n.º 10
0
def plot(x, y, z, t):
    file = 'data.csv'
    output = 'data.pdf'
    pg.s([x, y, z], filename=file)
    pg.c('file="data.csv"')
    pg.c(
        'set boxwidth 0.4 absolute; set boxdepth 0.3; set style fill solid 1.00 border'
    )
    pg.c(
        'set grid nopolar xtics nomxtics ytics nomytics ztics nomztics nortics nomrtics \
            nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics')
    pg.c(
        'set grid vertical layerdefault lt 0 linecolor 0 linewidth 1.000, lt 0 linecolor 0 linewidth 1.000'
    )
    pg.c('unset key')
    pg.c(
        'set wall z0  fc  rgb "slategrey"  fillstyle  transparent solid 0.50 border lt -1'
    )
    pg.c('set view 59, 24, 1, 1')
    pg.c('set style data lines')
    pg.c('set xyplane at 0')
    #    pg.c('set title "Bandwidth (MB/s) of RAND READ')
    pg.c('set title "Latency (us) of READ')
    pg.c('set xlabel "Qdepth"; set ylabel "BlkSize"')
    pg.c('set autoscale x; set autoscale y; set logscale z')
    pg.c('set pm3d depthorder')
    pg.c('set pm3d interpolate 1,1 flush begin noftriangles border lt black \
            linewidth 1.000 dashtype solid corners2color mean')
    pg.c('rgbfudge(x) = x*51*32768 + (11-x)*51*128 + int(abs(5.5-x)*510/9.)')
    pg.c('ti(col) = sprintf("%d",col)')
    pg.c('set xtics ("1" 1, "2" 2, "4" 3, "8" 4, "16" 5, "32" 6, "64" 7)')
    pg.c(
        'set ytics ("4" 1, "8" 2, "16" 3, "32" 4, "64" 5, "128" 6, "256" 7, "512" 8, "1024" 9)'
    )
    pg.c('splot file u 1:2:3:(rgbfudge($1)) with boxes fc rgb variable')
Ejemplo n.º 11
0
def plotSNfit(result, vc, pidx, digi='D1'):
    ''' result : fitting results
        vc, variable carrier
        pidx power index
        digi = 'D1' or 'D2'
        '''
    vc.Tz = result.params['Tz'].value

    if digi == 'D1':
        f = vc.f1
        T = result.params['T1'].value
        G = result.params['G1'].value
        Tn = result.params['Tn1'].value
        data = np.array(vc.cPD1[pidx]) * 1.0

    if digi == 'D2':
        f = vc.f2
        T = result.params['T2'].value
        G = result.params['G2'].value
        Tn = result.params['Tn2'].value
        data = np.array(vc.cPD2[pidx]) * 1.0

    if digi == 'D12':
        f = vc.f1
        T = result.params['T12'].value
        G = result.params['G12'].value
        Tn = result.params['Tn12'].value
        data = np.array(vc.cPD3[pidx]) * 1.0

    if digi == 'D12c':
        f = vc.f1
        T = result.params['T12c'].value
        G = result.params['G12c'].value
        Tn = result.params['Tn12c'].value
        data = np.array(vc.cPD4[pidx]) * 1.0

    factor = f*h*vc.B*G  # factor to photon #
    SNf = fitfunc(G, Tn, T, f, vc)
    Amp = G*vc.B*kB*Tn

    title2 = (digi + ', RF-Drive ' + str(vc.d2.lin[pidx]) + ' G ' + str(np.round(G/1e7, 2)) +
              'e7 = ' + str(np.round(np.log10(G)*10.0, 2)) + 'dB  T ' + str(np.round(Tn, 2)) + 'K')
    dataname = digi + '_' + str(vc.d2.lin[pidx]) + '.dat'
    gp.c('')
    gp.figure()
    # gp.c('clear')
    gp.s([vc.I*1e6, (data)/factor, (SNf)/factor, np.ones_like(data)*Amp/factor],
         filename=vc.resultfolder+dataname)
    gp.c('set title "' + title2 + '"')
    gp.c('set xrange[-19:19]')
    gp.c('set key center top')
    gp.c('plot "' + dataname + '" u 1:2 w l t "Data" ')
    gp.c('replot "' + dataname + '" u 1:3 w l t "Fit" ')
    gp.c('replot "' + dataname + '" u 1:4 w l t "Amplifier Noise" ')
    gp.c('save "' + dataname[:-3] + 'gn"')
    gp.pdf(dataname[:-3]+'pdf')
    print dataname[:-3]+'pdf'
Ejemplo n.º 12
0
    def plotData(self, xmin=0, xmax=0, filename=''):

        if not xmin == xmax == 0:
            gp.c("set xrange [%f:%f]" % (xmin, xmax))

        gp.s(self.dataArray, "plot.dat")
        gp.c("plot 'plot.dat' u 1:2 w lp t 'Data'")

        if len(filename) > 0:
            gp.pdf(filename)
Ejemplo n.º 13
0
def plot_pygnuplot(x, y, filename, data_filename):

    import PyGnuplot as gnu

    gnu.s([x, y], data_filename)
    gnu.c('set terminal pngcairo size 350,262 enhanced font "Verdana,10"')
    gnu.c('set output "' + filename + '"')
    gnu.c('plot "' + data_filename + '" w lp pi -1')

    return
Ejemplo n.º 14
0
def plot3dMSR(uc_3):

    hyperPoints = cdf.getMSR_ND(uc_s, N=190)

    gp.s(np.transpose(hyperPoints), filename="plot3dMSR.dat")
    gp.c('set ticslevel 0')
    gp.c('unset key')
    gp.figure('0')
    c_plot = 'splot "plot3dMSR.dat" with lines ' 
    print c_plot                   
    gp.c(c_plot)
Ejemplo n.º 15
0
def graph(table):
    
    gp.c('set style data histogram')
    gp.c('set style histogram cluster gap 1')
    gp.c('set style fill solid border rgb "black"')
    gp.c('set auto x')
    gp.c('set boxwidth 1.4')
    gp.c('set yrange [0:*]')
    gp.s(table)
    gp.c('set xtics rotate')
    gp.c("plot 'tmp.dat' using 2:xtic(1) title col, '' using 3:xtic(1) title col, '' using 4:xtic(1) title col, '' using 5:xtic(1) title col, '' using 6:xtic(1) title col, '' using 7:xtic(1) title col, '' using 8:xtic(1) title col, '' using 9:xtic(1) title col, '' using 10:xtic(1) title col, '' using 11:xtic(1) title col")
def make_graph(x_input_list, prediction_list, unSeenData_List):
    pg.s([x_input_list, prediction_list, unSeenData_List],
         filename='CNN_output.out')  # save data into a file
    pg.c('set title "CNN Output"; set xlabel "x-axis"; set ylabel "y-axis"')
    #pg.c('set key center top')
    pg.c("plot 'CNN_output.out' u 1 w l t 'x\_input = Test Set'"
         )  # plot test set seen data
    pg.c("replot  'CNN_output.out' u 2 w l  t 'yhat = Predicted value'"
         )  # plot test set CNN predicted data
    pg.c("replot  'CNN_output.out' u 3 w l t 'unSeenData = Correct value'"
         )  # plot test set unseen actual data
Ejemplo n.º 17
0
def plot_graph(a, b):
    gp.c('set grid')
    gp.c(f'set xrange[{a}:{b}]')
    gp.c('set xzeroaxis')
    gp.c('set yzeroaxis')

    gp.c(f'plot "<echo 0 1" title "(0, 1)"')

    gp.s(points(), filename="arquivos.pts")

    gp.c('replot "arquivos.pts" with lp title "f(x) no intervalo [−6:6]"')
    gp.c('replot x*cos(x) + 1 title "f(x) = x*cos(x) + 1"')
Ejemplo n.º 18
0
def main():
    # X = np.arange(10)
    # Y = np.sin(X / (2 * np.pi))
    # Z = Y ** 2.0
    X = Y = np.array(list(range(10)))
    Z = np.array(X**3)
    Z2 = np.array(X**4)
    gp.s([X, Y, Z, Z2])
    gp.c('splot "tmp.dat" using 1:2:3 with lines')
    gp.c('replot "tmp.dat" u 1:2:4 w lines')
    # gp.c('splot "tmp.dat" using 1:2:3:($3+$4) with zerrorfill')
    # gp.c('replot "tmp.dat" u 1:3 w lp')
    gp.p('myfigure.ps')
Ejemplo n.º 19
0
def plot_graph_taylo(a, b):
    gp.c('set grid')
    gp.c(f'set xrange[{a}:{b}]')
    gp.c(f'set yrange[-10:10]')
    gp.c('set xzeroaxis')
    gp.c('set yzeroaxis')

    points_x = np.linspace(a, b, 100)
    points_y = [taylor(x) for x in points_x]
    gp.s([points_x, points_y], filename='taylor.pts')
    gp.c('plot "taylor.pts"')
    #gp.c(f'plot 1+(x**1)/{factorial(1)} + -3*x**3/{factorial(3)} + 5*x**5/{factorial(5)} + -7*x**7/{factorial(7)} title "taylor"')
    gp.c('replot x*cos(x) + 1 title "f(x) = x*cos(x) + 1"')
Ejemplo n.º 20
0
def plot_elo_ratings(elo_r):
    import numpy as np
    try:
        import PyGnuplot as gp
    except:
        print("Skip plotting the graph as PyGnuplot is not installed.")
        return
    import tempfile
    assert isinstance(elo_r, collections.OrderedDict)

    X = np.arange(len(elo_r))
    Y = np.array([r for r in elo_r.values()])

    with tempfile.NamedTemporaryFile() as fp:
        gp.s([X, Y], filename=fp.name)
        gp.c('plot "{}" u 1:2 notitle w lp'.format(fp.name))
        input('press any key to continue')
Ejemplo n.º 21
0
 def BacteriaHeading(self):
     gp.c("reset")
     gp.c("set ticslevel 0")
     gp.c("set view equal xyz")
     gp.c("set terminal pngcairo enhanced size 1600,1200 font 'ariel, 14'")
     for key in self.bacteria.bacterium.keys():
         output = os.path.join(self.graph_dir, key + '_heading.png')
         gp.c('set output "' + output + '"')
         plot_string = 'splot'
         for bact in self.bacteria.bacterium[key].keys():
             temp_out = self.bacteria.bacterium[key][bact].vectors_cartesian
             graph_out = np.swapaxes(temp_out, 0, 1)
             dat_name = os.path.join(self.plot_dir,
                                     str(key) + str(bact) + 'heading.dat')
             gp.s(graph_out, dat_name)
             plot_string = plot_string + ' "' + dat_name\
                 + '" u 1:2:3 with lines,'
         gp.c(plot_string)
Ejemplo n.º 22
0
def multiplot(rr_x, rr_y, rr_z, sr_x, sr_y, sr_z, rw_x, rw_y, rw_z, sw_x, sw_y,
              sw_z, t):
    output = 'data.pdf'

    if (t == "bandwidth"):
        pg.c('TITLE="fio-CONT1-NS1-QDs-BSs (Bandwidth MB/s)"')
        pg.c('set autoscale z')
    else:
        pg.c('TITLE="fio-CONT1-NS1-QDs-BSs (Latency us)"')
        pg.c('set logscale z')

    pg.s([rr_x, rr_y, rr_z], filename="randread.csv")
    pg.s([sr_x, sr_y, sr_z], filename="read.csv")
    pg.s([rw_x, rw_y, rw_z], filename="randwrite.csv")
    pg.s([sw_x, sw_y, sw_z], filename="write.csv")
    pg.c('ARR_JOB_TYPE="randread read randwrite write"')
    pg.c('set autoscale x; set autoscale y')
    pg.c(
        'set boxwidth 0.4 absolute; set boxdepth 0.3; set style fill solid 1.00 border'
    )
    pg.c(
        'set grid nopolar xtics nomxtics ytics nomytics ztics nomztics nortics nomrtics \
            nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics')
    pg.c(
        'set grid vertical layerdefault lt 0 linecolor 0 linewidth 1.000, lt 0 linecolor 0 linewidth 1.000'
    )
    pg.c('unset key')
    pg.c(
        'set wall z0  fc  rgb "slategrey"  fillstyle  transparent solid 0.50 border lt -1'
    )
    pg.c('set view 59, 24, 1, 1')
    pg.c('set style data lines')
    pg.c('set xyplane at 0')
    pg.c('set xlabel "Qdepth"; set ylabel "BlkSize (KB)"')
    pg.c('set pm3d depthorder')
    pg.c('set pm3d interpolate 1,1 flush begin noftriangles border lt black \
            linewidth 1.000 dashtype solid corners2color mean')
    pg.c('rgbfudge(x) = x*51*32768 + (11-x)*51*128 + int(abs(5.5-x)*510/9.)')
    pg.c('ti(col) = sprintf("%d",col)')
    pg.c('set xtics ("1" 1, "2" 2, "4" 3, "8" 4, "16" 5, "32" 6, "64" 7)')
    pg.c(
        'set ytics ("4" 1, "8" 2, "16" 3, "32" 4, "64" 5, "128" 6, "256" 7, "512" 8, "1024" 9)'
    )

    pg.c('set multiplot layout 2,2 title TITLE')
    pg.c('do for [job_id=1:words(ARR_JOB_TYPE)] {')
    pg.c('TITLE1=sprintf("%s",word(ARR_JOB_TYPE,job_id))')
    pg.c('set title TITLE1')
    pg.c('FILE=sprintf("%s.csv",word(ARR_JOB_TYPE,job_id))')
    pg.c('splot FILE u 1:2:3:(rgbfudge($1)) with boxes fc rgb variable')
    pg.c('}')
    pg.c('unset multiplot')
Ejemplo n.º 23
0
 def _draw(
         self,
         points,  # ([x1,y1],filename,functionname), ...
         xl='Значения a',
         yl='Значения функции',
         title='заголовок',
         yrange='[0:5]',
         xrange='[-1:1]',
         out_file='file.pdf'):
     gp.c('set xlabel "' + xl + '"')
     gp.c('set ylabel "' + yl + '"')
     gp.c('set title "' + title + '"')
     gp.c('set yrange ' + yrange)
     gp.c('set xrange ' + xrange)
     plotstr = 'plot '
     for q in points:
         gp.s([q[0][0], q[0][1]], filename=q[1])
         plotstr += '"' + q[1] + '" u 1:2 w l title "' + q[2] + '", '
     plotstr = plotstr.strip(', ')
     gp.c(plotstr)
Ejemplo n.º 24
0
def __fitExample__():

    customizeGraph()
    gp.s([[1, 2, 3], [4, 7, 13], [1, 1, 1]])
    gp.c("m = 1")
    gp.c("b = 1")
    gp.c("f(x) = m*x+b")
    gp.c("fit f(x) 'tmp.dat' u 1:2:3 yerrors via m,b")
    gp.c("set xrange [0:4]")
    gp.c("plot 'tmp.dat' u 1:2:3 w yerrorbars, f(x)")


#
# crystal = crystalNames[5]
# directory = "SPEC\\4D\\4D data files"
# crystalFiles = [join(directory, fname) for fname in listdir(directory)
#                 if crystal.casefold() in fname.casefold() and splitext(fname)[1] == ".txt"]
#
# crystalFilesname = [fname for fname in listdir(directory)
#                 if crystal.casefold() in fname.casefold() and splitext(fname)[1] == ".txt"]
# for i in range(len(crystalFiles)):
#     print(crystalFilesname[i], printFileParameters(crystalFiles[i]))
Ejemplo n.º 25
0
def plot_correlations(peaks_a, peaks_max_a, det_a, peaks_b, peaks_max_b, det_b,
                      suffix):
    plot_name = '40_corr_peaks'
    if len(peaks_a) == 0:
        return
    dummy, fname = tempfile.mkstemp(prefix='tmp_corr_peaks_%03d' % det_a,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_a_name, det_a_feat = detector_name(det_a)
    det_b_name, det_b_feat = detector_name(det_b)
    # the output directory corresponds to the detector on the x-axis
    os.makedirs(os.path.join(cfg.global_odir, det_a_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_a_name + ' ' + det_a_feat + ' (x-axis), ' +
         det_b_name + ' ' + det_b_feat +
         ' (y-axis)" at graph 0, graph 1.04 noenhanced')
    gp.s([peaks_max_a, peaks_max_b], filename=fname)
    gp.c('set auto fix')
    gp.c('set log x')
    gp.c('set log y')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c('set xlabel "Amplitude (V) - Detector: %s %s"' %
         (det_a_name, det_a_feat))
    gp.c('set ylabel "Amplitude (V) - Detector: %s %s"' %
         (det_b_name, det_b_feat))
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_a_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot [][:15e-6] "' + fname + '"' +
             " u ($1):($2) not w p lt 6 pt 7 ps 0.125")
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 26
0
def plot_correlation_deltat(det_a, det_b, deltat, suffix):
    plot_name = '41_corr_deltat'
    if len(deltat) == 0:
        return
    dummy, fname = tempfile.mkstemp(prefix='tmp_corr_deltat_%03d' % det_a,
                                    suffix='.dat',
                                    dir=cfg.tmpdir,
                                    text=True)
    det_a_name, det_a_feat = detector_name(det_a)
    det_b_name, det_b_feat = detector_name(det_b)
    # the output directory corresponds to the detector on the x-axis
    os.makedirs(os.path.join(cfg.global_odir, det_a_name,
                             '%s%s' % (plot_name, suffix)),
                exist_ok=True)
    gp_set_defaults()
    gp.c('set label "' + det_a_name + ' ' + det_a_feat + ', ' + det_b_name +
         ' ' + det_b_feat + '" at graph 0, graph 1.04 noenhanced')
    values, edges = np.histogram(np.multiply(deltat,
                                             1e3 / cfg.params.sampling_freq),
                                 bins=1500,
                                 density=False)  # convert deltat in ms
    gp.s([edges[:-1], values], filename=fname)
    gp.c('set log y')
    gp.c('set offsets graph 0.1, graph 0.1, graph 0.1, graph 0.1')
    gp.c(
        'set xlabel "Peak time %s %s - time of the closest peak of %s %s (ms)"'
        % (det_a_name, det_a_feat, det_b_name, det_b_feat))
    gp.c('set ylabel "Number of events"')
    for ext in cfg.cfg['plot']['output_format'].split():
        gp_set_terminal(ext)
        gp.c('set out odir."%s/%s%s/%s%s.%s"' %
             (det_a_name, plot_name, suffix, plot_name, suffix, ext))
        gp.c('plot [-15000:15000] "' + fname + '"' +
             " u 1:2 not w histep lt 6")
        gp.c('set out')
    fn_collector.append(fname)
    os.close(dummy)
Ejemplo n.º 27
0
def tangent_line_gp(f, a, b):
    x = np.linspace(a, b, 200)

    x0 = 1
    y_0 = f(x0)
    y_tan = derive(f, x0, 0.000000001) * (x - x0) + y_0
    gp.s([x, y_tan], filename="tangente.dat")

    x1 = (4 + sqrt(28)) / 6
    x2 = (4 - sqrt(28)) / 6

    gp.c('set grid')
    gp.c('set xrange[-1.5:2.5]')
    gp.c('set xzeroaxis')
    gp.c('set yzeroaxis')

    # Func Cubica
    gp.c('plot (x**3) - (2* (x**2)) - x + 2 title "função cúbica"')

    # Tangente x = 1
    #gp.c('replot "tangente.dat" with lines title "reta tangente em x = 1"')
    gp.c('replot -2*x + 2 with lines title "reta tangente em x = 1"')

    # 1, f(1))
    gp.c(f'replot "<echo 1 {f(1)}" title "(1, f(1))"')

    # PC1
    gp.c(f'replot "<echo {x1} {f(x1)}" title "PC1: {x1:.2f}"')
    # PC1 tangente
    y_0 = f(x1)
    y_tan = derive(f, x1, 0.000000001) * (x - x1) + y_0
    gp.s([x, y_tan], filename="tangente-pc1.dat")
    gp.c('replot "tangente-pc1.dat" with lines title "reta tangente PC1"')

    # PC2
    gp.c(f'replot "<echo {x2} {f(x2)}" title "PC2: {x2:.2f}"')
    # PC2 tangente
    y_0 = f(x2)
    y_tan = derive(f, x2, 0.000000001) * (x - x2) + y_0
    gp.s([x, y_tan], filename="tangente-pc2.dat")
    gp.c('replot "tangente-pc2.dat" with lines title "reta tangente PC2"')
Ejemplo n.º 28
0
import numpy as np
import PyGnuplot as pg

x = np.arange(1000) / 20.0
y1 = x - 25
y2 = y1 * np.sin(x - 25)

pg.s([x, y1, y2], filename='example.out')  # save data into a file t.out
pg.c('set title "example.pdf"; set xlabel "x-axis"; set ylabel "y-axis"')
pg.c('set yrange [-25:25]; set key center top')
pg.c("plot 'example.out' u 1:2 w l t 'y=x-25")  # plot fist part
pg.c("replot 'example.out' u 1:3 w l t 'y=(x-25)*sin(x-25)'")
pg.c("replot 'example.out' u 1:(-$2) w l t 'y=25-x'")
pg.pdf('example.pdf')  # export figure into a pdf file
Ejemplo n.º 29
0
        Experiments(matrix,run_bench).run()


#if gArg.filebench == 'varmail':

    plot_str = "plot"
    plot_str += " [:"+gArg.x_range + "]"
    plot_str += " [:"+gArg.y_range + "]"
    plot_str += " 'tmp.out' u 1:2"
    plot_value = " lc rgb \#000 t"


    if gArg.plot_type == 'dot':  
        x,y = parse_dmesg(0)
        pg.s([x,y], filename='tmp.out')
        pg.c('set title "Execution time for the number of access threads"; set xlabel "Access Thread Number"; set ylabel "Millisecond"')
        pg.c('set grid')
        plot_str += plot_value+" '"+gArg.plot_type+"'"
#pg.c(plot_str)
        pg.c("plot [:33] [:] 'tmp.out' u 1:2 lc rgb 'black' t 'dot'")

    elif gArg.plot_type == 'median':
        kernlog_filter = run_benchmark(1);
        y,z,average,max_t_updates = parse_dmesg(1,kernlog_filter)
        print ( 'average' , average )
        x = np.arange(max_t_updates)
        pg.s([x,z], filename='tmp.out')
        pg.c('set title "Execution time for the number of access threads"; set xlabel "Access Thread Number"; set ylabel "Millisecond"')
        pg.c('set grid')
        plot_str += " w l"+plot_value+" '"+gArg.plot_type+"'"
         previous_measurements['transcoder_no'])].append(
             after_measurements['qoe_sum'])
 metrics = [(labels[0], no_of_profiles_produced),
            (labels[1], percentage_of_gpu_users),
            (labels[2], mean_mos), (labels[3], transcoding_cost),
            (labels[4], qoe_sum_to_cost_rate)]
 for label, metric in metrics:
     diagram_label, file_label = label
     for key in metric.keys():
         filename = session_data.format(scenario_dir, run, key,
                                        file_label)
         if not os.path.exists(os.path.dirname(filename)):
             os.makedirs(os.path.dirname(filename))
         X = metric[key]
         Y = list(range(0, len(metric[key])))
         gp.s([Y, X], filename)
     filename = combined_data.format(scenario_dir, run, file_label)
     if not os.path.exists(os.path.dirname(filename)):
         os.makedirs(os.path.dirname(filename))
     X = metric['transcoder_1']
     Z = metric['transcoder_2']
     # len_x, len_z = len(X), len(Z)
     # X = X[:len_z] if len_x > len_z else X
     # Z = Z[:len_x] if len_z > len_x else Z
     # Y = list(range(0, len(X)))
     # gp.s([Y, X, Z], filename)
     # stacked_data_filename = stacked_run_data.format(scenario_dir, file_label)
     # all_stacked_data_filename = all_stacked_data.format(file_label)
     # if not os.path.exists(os.path.dirname(stacked_data_filename)):
     #     os.makedirs(os.path.dirname(stacked_data_filename))
     # print('{}/{}'.format(scenario_dir, run))
Ejemplo n.º 31
0
# print g
scale(x_cord)
scale(y_cord)
scale(cost)
finalCost = computeCost(X, Y, g)
# print(finalCost)

gp.c('set term pdfcairo')
gp.c('set output "output_2.pdf"')

fig, ax = plt.subplots()
ax.plot(np.arange(iters), cost, 'r')
ax.set_xlabel('Iterations')
ax.set_ylabel('Cost')
ax.set_title('Error vs. Training Epoch')
plt.show()

gp.s([x_cord, y_cord, cost], filename='3d_plot_data.dat')
gp.c('set key off')
gp.c(
    'splot "3d_plot_data.dat" using 1:2:3 with points palette pointsize 3 pointtype 7'
)

gp.c('set view map')
gp.c('set size ratio .9')
gp.c('set object 1 rect from graph 0, graph 0 to graph 1, graph 1 back')
gp.c('set object 1 rect fc rgb "black" fillstyle solid 1.0')
gp.c(
    'splot "3d_plot_data.dat" using 1:2:3 with points pointtype 5 pointsize 1 palette linewidth 30'
)
Ejemplo n.º 32
0
n_steps = 100
for i in range(n_steps):
    testSet.append(math.sin(raw_seq_SeedValue))
    raw_seq_SeedValue += 0.1
x_input = array(testSet)
x_input = x_input.reshape((1, n_steps, 1))
#print(x_input)

x_input_list = []
for i in x_input:
    for j in i:
        for k in j:
            x_input_list.append(k)
print(x_input_list)

pg.s([x_input_list], filename='example1.out')  # save data into a file
pg.c('set title "example1"; set xlabel "x-axis"; set ylabel "y-axis"')
pg.c('set key left top')
pg.c("plot 'example1.out'  t 'Test key'")  # plot first part




'''
pg.s([x, y1, y2], filename='example.out')  # save data into a file t.out
pg.c('set title "example.pdf"; set xlabel "x-axis"; set ylabel "y-axis"')
#pg.c('set yrange [-50.0:25.0]; set key center top')
pg.c('set key left top')

pg.c("plot 'example.out'  w l t 'Test title'")  # plot first part