Example #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")
Example #2
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())
Example #3
0
def plot_graphs_modes_markers(agreg_step):
    '''Funkce vykreslí grafy podle dat ve vstupních souborech a uloží je ve formátu PDF do složky output/graphs'''

    agreguj_data_rezie_modes_markers(agreg_step)
    #priprav_data_pro_sloupcovy_graf_rezie_nizky_bitrate_modes_markers()
    #priprav_data_pro_sloupcovy_graf_rezie_vysoky_bitrate_modes_markers()
    '''# histogram rezie pro nizky bitrate
    pg.c('set xlabel "ZABEZPEČENÍ"; set ylabel "REŽIE ZABEZPEČENÍ [ % ]"')
    pg.c('unset key; set style data histogram; set style fill solid border; set style histogram clustered')
    pg.c("plot for [COL=2:3] 'output/graphs_data/agreg/histogram_nizky_bitrate_rezie_modes_markers.dat' using COL:xticlabels(1) title columnheader")
    pg.pdf('output/graphs/histogram_rezie_nizky_bitrate_modes_markers.pdf')

    # histogram rezie pro vysoky bitrate
    pg.c('set xlabel "ZABEZPEČENÍ"; set ylabel "REŽIE ZABEZPEČENÍ [ % ]"')
    pg.c('unset key; set style data histogram; set style fill solid border; set style histogram clustered')
    pg.c("plot for [COL=2:3] 'output/graphs_data/agreg/histogram_vysoky_bitrate_rezie_modes_markers.dat' using COL:xticlabels(1) title columnheader")
    pg.pdf('output/graphs/histogram_rezie_vysoky_bitrate_modes_markers.pdf')'''

    # Kolik % velikosti souboru zabírají markery v závislosti na bitrate
    pg.c('set xlabel "BITRATE"; set ylabel "REŽIE ZABEZPEČENÍ [ % ]"')
    pg.c('set yrange [0:65]; set xrange [0:2.5]; set key right top')
    pg.c("plot '" + str(graphs_data_bitrate_rezie_sop_eph_agreg_filename) +
         "' title 'SOP + EPH'  with lines lw 3")
    pg.c(
        "replot '" +
        str(graphs_data_bitrate_rezie_vsechny_mody_sop_eph_agreg_filename) +
        "' title 'Líné paralelní zpracování + SEGMARK + SOP + EPH'  with lines lw 3"
    )
    pg.pdf('output/graphs/bitrate_rezie_zabezpeceni_modes_markers.pdf')

    agreguj_data_nedekomprimovatelnych_souboru(
        graphs_data_failed_na_poskozeni_bez_ochrany_filename,
        graphs_data_failed_na_poskozeni_bez_ochrany_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(
        graphs_data_failed_na_poskozeni_vsechny_mody_sop_eph_filename,
        graphs_data_failed_na_poskozeni_vsechny_mody_sop_eph_agreg_filename)

    # Kolik % velikosti souboru zabírají markery v závislosti na bitrate a měnících se PRECINCTS a sop+eph pro layers=12
    pg.c(
        'set key right bottom; set xlabel "POŠKOZENÍ [ % ]"; set ylabel "POČET NEDEKOMPRIMOVATELNÝCH SOUBORŮ [ % ]"'
    )
    #pg.c('set yrange [0.5:1]; set xrange [0:0.1]; set key right')
    pg.c('set yrange [0:100]; set xrange [-0.00005:0.0205]; set key right')
    pg.c("plot '" + str(graphs_data_fails_mode_none_agreg_filename) +
         "' title 'Bez ochrany'  with lines lw 3")
    pg.c("replot '" +
         str(graphs_data_failed_na_poskozeni_sop_eph_agreg_filename) +
         "' title 'SOP + EPH'  with lines lw 3")
    #pg.c("replot '" + str(graphs_data_failed_na_poskozeni_sop_eph_segmark_agreg_filename) + "' title 'SOP, EPH, SEGMARK'  with lines linestyle 5")
    pg.c("replot '" +
         str(graphs_data_fails_mode_lazyparallelsegmark_agreg_filename) +
         "' title 'Líné paralelní zpracování + SEGMARK'  with lines lw 3")
    pg.c(
        "replot '" +
        str(graphs_data_failed_na_poskozeni_vsechny_mody_sop_eph_agreg_filename
            ) +
        "' title 'Líné paralelní zpracování + SEGMARK + SOP + EPH'  with lines lw 3"
    )
    pg.pdf('output/graphs/poskozeni_neuspesne_soubory_modes_markers.pdf')
Example #4
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'
Example #5
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)
Example #6
0
def plot_graphs_modes(agreg_step):
    '''Funkce vykreslí grafy podle dat ve vstupních souborech a uloží je ve formátu PDF do složky output/graphs'''

    #agreguj_data_rezie_modu(agreg_step)
    #priprav_data_pro_sloupcovy_graf_rezie_nizky_bitrate_modes()
    #priprav_data_pro_sloupcovy_graf_rezie_vysoky_bitrate_modes()
    '''# histogram rezie pro nizky bitrate
    pg.c('set xlabel "ZABEZPEČENÍ"; set ylabel "REŽIE ZABEZPEČENÍ [ % ]"')
    pg.c('unset key; set style data histogram; set style fill solid border; set style histogram clustered')
    pg.c("plot for [COL=2:3] 'output/graphs_data/agreg/histogram_nizky_bitrate_rezie_modes.dat' using COL:xticlabels(1) title columnheader")
    pg.pdf('output/graphs/histogram_rezie_nizky_bitrate_modes.pdf')

    # histogram rezie pro vysoky bitrate
    pg.c('set xlabel "ZABEZPEČENÍ"; set ylabel "REŽIE ZABEZPEČENÍ [ % ]"')
    pg.c('unset key; set style data histogram; set style fill solid border; set style histogram clustered')
    pg.c("plot for [COL=2:3] 'output/graphs_data/agreg/histogram_vysoky_bitrate_rezie_modes.dat' using COL:xticlabels(1) title columnheader")
    pg.pdf('output/graphs/histogram_rezie_vysoky_bitrate_modes.pdf')'''
    '''agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_all_filename,             graphs_data_fails_mode_all_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_none_filename,            graphs_data_fails_mode_none_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_bypass_filename,          graphs_data_fails_mode_bypass_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_parallel_filename,        graphs_data_fails_mode_parallel_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_lazyparallel_filename,    graphs_data_fails_mode_lazyparallel_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_ertermsegmark_filename,   graphs_data_fails_mode_ertermsegmark_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_segmark_filename,         graphs_data_fails_mode_segmark_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_bypasssegmark_filename,   graphs_data_fails_mode_bypasssegmark_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_parallelsegmark_filename, graphs_data_fails_mode_parallelsegmark_agreg_filename)
    agreguj_data_nedekomprimovatelnych_souboru(graphs_data_fails_mode_lazyparallelsegmark_filename, graphs_data_fails_mode_lazyparallelsegmark_agreg_filename)'''

    pg.c(
        'set key right bottom; set xlabel "POŠKOZENÍ [ % ]"; set ylabel "POČET NEDEKOMPRIMOVATELNÝCH SOUBORŮ [ % ]"'
    )
    # pg.c('set yrange [0.5:1]; set xrange [0:0.1]; set key right')
    pg.c('set yrange [0:100]; set xrange [-0.00005:0.0205]; set key right')

    pg.c("plot '" + str(graphs_data_fails_mode_none_agreg_filename) +
         "' title 'Žádný mód'  with lines lw 3")
    pg.c("replot '" + str(graphs_data_fails_mode_bypass_agreg_filename) +
         "' title 'Liné zpracování'  with lines lw 3")
    pg.c("replot '" + str(graphs_data_fails_mode_parallel_agreg_filename) +
         "' title 'Paralelní zpracování'  with lines lw 3")
    #pg.c("replot '" + str(graphs_data_fails_mode_lazyparallel_agreg_filename) + "' title 'Líné paralelní zpracování'  with lines linestyle 4")
    pg.c("replot '" +
         str(graphs_data_fails_mode_ertermsegmark_agreg_filename) +
         "' title 'ERTERM + SEGMARK'  with lines lw 3")
    #pg.c("replot '" + str(graphs_data_fails_mode_segmark_agreg_filename) + "' title 'SEGMARK'  with lines linestyle 6")
    #pg.c("replot '" + str(graphs_data_fails_mode_bypasssegmark_agreg_filename) + "' title 'BYPASS, SEGMARK'  with lines linestyle 7")
    #pg.c("replot '" + str(graphs_data_fails_mode_parallelsegmark_agreg_filename) + "' title 'Paralelní zpracování + SEGMARK'  with lines linestyle 8")
    pg.c("replot '" +
         str(graphs_data_fails_mode_lazyparallelsegmark_agreg_filename) +
         "' title 'Líné paralelní zpracování + SEGMARK' with lines lw 3")
    #pg.c("replot '" + str(graphs_data_fails_mode_all_agreg_filename) + "' title 'Všechny módy'  with lines linestyle 12")

    pg.pdf('output/graphs/poskozeni_neuspesne_soubory_modes.pdf')
Example #7
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
Example #8
0
    def fitData(self, xmin: float, xmax: float, filename=""):
        # fun right here

        fitlog_del = open("fit.log", "w")
        fitlog_del.close()

        arrX = []
        arrY = []
        arrErrY = []

        for i in range(len(self.dataArray[0])):

            if xmin <= self.dataArray[0][i] <= xmax:
                arrX.append(self.dataArray[0][i])
                arrY.append(self.dataArray[1][i])
                arrErrY.append(self.dataArray[2][i])

        gp.s([arrX, arrY, arrErrY], "tmp.dat")

        gp.c("m=%f" % self.mpar)
        gp.c("b=%f" % self.bpar)
        gp.c("f_reta(x)=m*x+b")

        viaStr = "m, b, "
        gaussStr = ""
        paramNumber = 2
        for i in range(len(self.Apars)):
            gp.c("A%d=%f" % (i, self.Apars[i]))
            gp.c("mu%d=%f" % (i, self.mupars[i]))
            gp.c("sig%d=%f" % (i, self.sigpars[i]))

            if i != 0:
                gaussStr += "+"
                viaStr += ", "
            gaussStr += "A%d/(sqrt(2*pi)*sig%d) * exp( -0.5*((x-mu%d)/sig%d)**2)" % (
                i, i, i, i)
            viaStr += "A%d, mu%d, sig%d" % (i, i, i)
            paramNumber += 3

        gp.c("ftot(x)=" + gaussStr + "+m*x+b")
        gp.c("fit ftot(x) 'tmp.dat' u 1:2:3 yerrors via " + viaStr)

        gp.c(
            "plot 'tmp.dat' u 1:2:3 w yerrorbars t 'Data', ftot(x) t 'f({/Symbol b})'"
        )
        if len(filename) != 0:
            gp.pdf(filename)

        time.sleep(0.1)  # needed to create the fit.log file in time
        # then view file fit.log to get parameters

        fitlog = open("fit.log", "r")
        fileLines = fitlog.readlines()
        fitlog.close()

        if len(fileLines) == 0:
            time.sleep(0.3)
            fitlog = open("fit.log", "r")
            fileLines = fitlog.readlines()
            fitlog.close()

        chi2 = 0
        paramspos = 0
        paramStr = []
        paramVal = []
        paramErr = []
        for i in range(len(fileLines)):
            if "(reduced chisquare) = WSSR/ndf" in fileLines[i]:
                chi2 = float(fileLines[i].split(" : ")[1])

            if "Final set of parameters" in fileLines[i]:
                paramspos = i

            if paramspos != 0 and paramspos + 1 < i < paramspos + 2 + paramNumber:
                paramStr.append(fileLines[i].split(" ")[0])

                pars = fileLines[i].split(" = ")[1]
                paramVal.append(float(pars.split()[0]))
                paramErr.append(float(pars.split(" +/- ")[1].split()[0]))

        # print("chi2: ", chi2)
        # for i in range(len(paramStr)):
        #     print(paramStr[i], paramVal[i], paramErr[i])

        return [chi2, paramStr, paramVal, paramErr]