コード例 #1
0
ファイル: traceDist.py プロジェクト: gbottari/ESSenCe
def main():
    filename = '../tmp/config.txt'
    
    c = ConfigReader()
    c.parse(filename)
    cluster = c.readCluster()

    maxPerf = getMaxPerformance(cluster.availableServers)    
    
    outline = readOutlineFile('../tmp/outline.txt')
    trace = generateTrace(outline, maxPerf, 20)
        
    if Gnuplot is not None:
        data = Data(trace, with_='l')
        g = Gnuplot()
        g('set ytics 0, 100')
        g('set xtics 0, 20')
        g('set grid')
        g.plot(data)
        raw_input()
    
    file = open('../tmp/trace_gen.txt','w')
    for value in trace:
        file.write('%f\n' % value)
    file.close()
コード例 #2
0
ファイル: coevolution.py プロジェクト: neffmallon/pistol
def coevolution(n=200,nsteps=6000):
    fitness = [random() for i in range(n)]
    least_fit_sites = []

    for step in range(nsteps):
        # Determine the least fit site
        worst = fitness.index(min(fitness))
        left = (worst-1)%n
        right = (worst+1)%n
        # Add that site to the least_fit_sites list
        least_fit_sites.append(worst)
        # Reinitialize the site and its neighbors
        fitness[worst] = random()
        fitness[left] = random()
        fitness[right] = random()

    # Plot how the least fit site changes with time
    p = Gnuplot()
    p.title("Coevolution data for %d steps with %d species" % (nsteps,n))
    p.xlabel("Step")
    d = Data(range(nsteps),least_fit_sites)
    p.plot(d)
    raw_input("press any key to continue")

    # Plot the frequency of the sites in the least_fit_site list:
    p2 = Gnuplot()
    p2.title("Frequency of least fit site")
    d2 = Data(range(n),frequency(n,least_fit_sites))
    p2.plot(d2)
    return
コード例 #3
0
ファイル: forcefield.py プロジェクト: matthagy/pbd
 def do_plots(func, *pots, **kwds):
     try:
         persist = kwds.pop('kwds')
     except KeyError:
         persist = True
     gp = Gnuplot(persist=persist)
     gp.xlabel('Separation Distance (nm)')
     gp.plot(*list(func(pot, **kwds) for pot in pots))
     return gp
コード例 #4
0
ファイル: mvc.py プロジェクト: annefi/PUI-fun
class Plot:
    def __init__(self, fn=None):
        self.gp = Gnuplot()
        if fn:
            self.gp('load "%s"' % fn)
        self.items = []
        self.needs_update = False

    def markdirty(self, d=True):
        """ Update will be necessary. """
        self.needs_update = d

    def update(self):
        """ Update the plot, but only if it necessary. """
        if self.needs_update:
            # only items with 'only_append'?
            #            ao=all([i.only_append for i in self.items]) python2.5
            ao = sum([i.only_append for i in self.items]) == len(self.items)
            for i in self.items:
                if i.needs_init_plot:
                    ao = False
                    break

            if not ao:
                self.gp.plot()  # start with empty plot
            for i in self.items:
                if i.needs_update:
                    i.update()
                    i.needs_update = False
                if not ao and not i.empty():
                    self.gp.replot(i)
                    i.needs_init_plot = False
            if ao:
                self.gp.replot(
                )  # simply cause plot update (FIXME: is this true?)
            self.needs_update = False

    def add(self, item):
        if not item in self.items:
            self.items += [item]
            self.needs_update = True
            connect(self.markdirty, item.changed, weak=False)
            connect(item.mouseclick, self.mouseclick, weak=False)

    def remove(self, item):
        if item in self.items:
            self.items.remove(item)
            disconnect(self.markdirty, item.changed)
            disconnect(item.mouseclick, self.mouseclick)
            self.needs_update = True

    def mouseclick(self, x, y, btn):
        send(self.mouseclick, self, x, y, btn)
コード例 #5
0
 def plot(self, plot_idle=False, show=True, to_file=None):
     assert self.processed
     from Gnuplot import Gnuplot
     g= Gnuplot()
     g('set style data linespoints')
     all_pids= set([cs.pid for cs in self.trace])
     process_data= [filter(lambda s:s.pid==pid, self.trace) for pid in all_pids]
     data=[ [(state.clock, state.clocks_done) for state in states] for states in process_data]
     if not plot_idle:
         data[0]=[(0,0)]
     if show:
         g.plot(*data)
     if not to_file is None:
         g.hardcopy(to_file, enhanced=1, color=1)
     raw_input("Press any key to close...")
コード例 #6
0
ファイル: plot_tail_bulk.py プロジェクト: annefi/PUI-fun
                tailbulk = tmpsumme / sdata[ion][time][maxflux][12]
            else:
                tailbulk = 0.
        else:
            tailbulk = 0.
        tailbulkdisttmp.append([(279. + time * 5. * 0.00833), tailbulk])
    tailbulkdist.append(tailbulkdisttmp)
gptailbulkdist = []
for ion in range(len(sdata)):
    tmpgptailbulk = Data(tailbulkdist[ion])
    tmpgptailbulk.set_option_colonsep("using", "1:2")
    tmpgptailbulk.set_option_colonsep("title", "'%s'" % (ion_list[ion]))
    gptailbulkdist.append(tmpgptailbulk)

gp = Gnuplot()
gp("set autoscale")
gp("set yrange[0.00001:1.]")
gp("set logscale y")
gp("set xlabel 'DoY'")
gp("set ylabel 'tail/bulk ratio' ")

for ion in range(len(sdata)):
    if (first):
        gp.plot(gptailbulkdist[ion])
        first = 0
    else:
        gp.replot(gptailbulkdist[ion])

gp("set term postscript color 18 lw 2 eps")
gp.hardcopy("tailbulk.ps", color=True, fontsize=18)
コード例 #7
0
class vspec:
    def __init__(self, year, timeframe):
        self.year = year
        self.timeframe = timeframe
        self.hedata = loadswicsiondata("He2+", 720., self.year, self.timeframe,
                                       "/data/etph/ace/")
        self.odata = loadswicsiondata("O6+", 720., self.year, self.timeframe,
                                      "/data/etph/ace/")
        self.hdata = swicsdcrtcr("H1+", self.year, self.timeframe,
                                 "/data/etph/ace/pui/12mdata/")
        self.swedata = swepamdata(64., self.year, self.timeframe,
                                  "/data/etph/ace/swepam/")
        self.swedata.sync_h(self.hedata)
        self.mag = magdata(1., self.year, self.timeframe,
                           "/data/etph/ace/mag/")
        self.mag.sync_mag(self.hedata)
        self.theta = arccos(cos(self.mag.phi) * cos(self.mag.theta))
        self.valf = 21.8 / sqrt(self.swedata.dens) * (self.mag.magb)
        self.valf[isinf(self.valf)] = -1.
        self.valf[isnan(self.valf)] = -2.
        self.effh = zeros([58])
        self.effhe = zeros([58])
        self.effo = zeros([58])
        self.gp = Gnuplot()
        self.gp("set xr [-2:3]")
        self.gp("set yr [0:1]")
        self.gp("set xlabel '(v-v_{sw})/C_{A}'")
        self.stdhe = []
        self.stdo = []
        self.stdh = []
        self.skewhe = []
        self.skewo = []
        self.skewh = []
        self.kurthe = []
        self.kurto = []
        self.kurth = []
        self.meanvhe = []
        self.meanvo = []
        self.meanvh = []
        self.maxvhe = []
        self.maxvo = []
        self.maxvh = []
        self.time = []
        self.years = []
        self.valfs = []
        self.magb = []
        self.thetas = []
        self.sigtheta = []
        self.vsw = []
        self.dsw = []
        self.tsw = []
        self.load_eff()

    def load_eff(self):
        effh = loadtxt(open("/data/etph/ace/efficencies/H1+.eff", "r"))
        effhe = loadtxt(open("/data/etph/ace/efficencies/He2+.eff", "r"))
        effo = loadtxt(open("/data/etph/ace/efficencies/O6+.eff", "r"))
        self.effh = effh[:, 1]
        self.effhe = effhe[:, 1]
        self.effo = effo[:, 1]

    def moments(self, thetalist=[[0., pi / 18.], [pi - pi / 18., pi]]):
        thetamask = (self.theta >= thetalist[0][0]) * (self.theta <=
                                                       thetalist[0][1])
        if len(thetalist) > 1:
            for val in thetalist[1:]:
                thetamask += (self.theta >= val[0]) * (self.theta <= val[1])
        for step in where(thetamask)[0]:
            if self.valf[step] > 0.:
                self.years.append(self.hedata.year)
                self.time.append(self.hedata.time[step])
                self.valfs.append(self.valf[step])
                self.magb.append(self.mag.magb[step])
                self.thetas.append(self.mag.THETA[step])
                self.sigtheta.append(self.mag.sigTHETA[step])
                self.vsw.append(self.swedata.vel[step])
                self.dsw.append(self.swedata.dens[step])
                self.tsw.append(self.swedata.temp[step])
                # Protons
                il = where(self.hdata.time == self.hedata.time[step])[0]
                if il.shape[0] > 0 and amax(self.hdata.tcrspec[il[0], :] +
                                            self.hdata.dcrspec[il[0], :]) > 0.:
                    tmpspec = zeros([self.hdata.velspec.shape[0], 2])
                    tmpspec[:, 0] = self.hdata.velspec
                    tmpspec[:, 1] = 1. * self.hdata.tcrspec[
                        il[0]] + 1. * self.hdata.dcrspec[il[0]]
                    tmpspec[:, 1] = tmpspec[:, 1] / (
                        tmpspec[:, 0] * 0.03) / self.effh / tmpspec[:, 0]
                    il2 = where(tmpspec[:, 1] == amax(tmpspec[:, 1]))[0]
                    if (il2[0] > 0 and il2[0] < tmpspec[:, 1].shape[0] - 1):
                        maxvh = sum(
                            tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 0] *
                            tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 1]
                        ) / sum(tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 1])
                    else:
                        maxvh = tmpspec[il2[0], 0]
                    meanvh = sum(tmpspec[:, 0] * tmpspec[:, 1]) / sum(
                        tmpspec[:, 1])
                    if maxvh > 390.:
                        tmphvel = (tmpspec[:, 0] - maxvh) / self.valf[step]
                        tmphcts = (tmpspec[:, 1]) / sum(tmpspec[:, 1])
                        maskh = (tmphvel >= -3.) * (tmphvel <= 3.)
                        stdh = sqrt(sum((tmphvel[maskh]**2) * tmphcts[maskh]))
                        skewh = (sum(
                            (tmphvel[maskh]**3) * tmphcts[maskh])) / stdh**3.
                        kurth = (sum(
                            (tmphvel[maskh]**4) * tmphcts[maskh])) / stdh**4.
                        self.stdh.append(stdh)
                        self.skewh.append(skewh)
                        self.kurth.append(kurth)
                        self.meanvh.append(meanvh)
                        self.maxvh.append(maxvh)
                    else:
                        self.stdh.append(-999.)
                        self.skewh.append(-999.)
                        self.kurth.append(-999.)
                        self.meanvh.append(-999.)
                        self.maxvh.append(-999.)
                else:
                    self.stdh.append(-999.)
                    self.skewh.append(-999.)
                    self.kurth.append(-999.)
                    self.meanvh.append(-999.)
                    self.maxvh.append(-999.)

                # Alphas
                if (where(self.hedata.countspec[step, :, 1] > 0.)[0].shape[0]
                        >= 3):
                    tmpspec = 1. * self.hedata.countspec[step]
                    tmpspec[:, 1] = tmpspec[:, 1] / (
                        tmpspec[:, 0] * 0.03) / self.effhe / tmpspec[:, 0]
                    il2 = where(tmpspec[:, 1] == amax(tmpspec[:, 1]))[0]
                    if (il2[0] > 0 and il2[0] < tmpspec[:, 1].shape[0] - 1):
                        maxvhe = sum(
                            tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 0] *
                            tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 1]
                        ) / sum(tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 1])
                    else:
                        maxvhe = tmpspec[il2[0], 0]
                    meanvhe = sum(tmpspec[:, 0] * tmpspec[:, 1]) / sum(
                        tmpspec[:, 1])
                    tmphevel = (tmpspec[:, 0] - maxvhe) / self.valf[step]
                    tmphects = (tmpspec[:, 1]) / sum(tmpspec[:, 1])
                    maskhe = (tmphevel >= -3.) * (tmphevel <= 3.)
                    stdhe = sqrt(sum((tmphevel[maskhe]**2) * tmphects[maskhe]))
                    skewhe = (sum(
                        (tmphevel[maskhe]**3) * tmphects[maskhe])) / stdhe**3.
                    kurthe = (sum(
                        (tmphevel[maskhe]**4) * tmphects[maskhe])) / stdhe**4.
                    self.stdhe.append(stdhe)
                    self.skewhe.append(skewhe)
                    self.kurthe.append(kurthe)
                    self.meanvhe.append(meanvhe)
                    self.maxvhe.append(maxvhe)
                else:
                    self.stdhe.append(-999.)
                    self.skewhe.append(-999.)
                    self.kurthe.append(-999.)
                    self.meanvhe.append(-999.)
                    self.maxvhe.append(-999.)

                # O6+
                if (where(self.odata.countspec[step, :, 1] > 0.)[0].shape[0] >=
                        3):
                    tmpspec = 1. * self.odata.countspec[step]
                    tmpspec[:, 1] = tmpspec[:, 1] / (
                        tmpspec[:, 0] * 0.03) / self.effo / tmpspec[:, 0]
                    il2 = where(tmpspec[:, 1] == amax(tmpspec[:, 1]))[0]
                    if (il2[0] > 0 and il2[0] < tmpspec[:, 1].shape[0] - 1):
                        maxvo = sum(
                            tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 0] *
                            tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 1]
                        ) / sum(tmpspec[[il2[0] - 1, il2[0], il2[0] + 1], 1])
                    else:
                        maxvo = tmpspec[il2[0], 0]
                    meanvo = sum(tmpspec[:, 0] * tmpspec[:, 1]) / sum(
                        tmpspec[:, 1])
                    tmpovel = (tmpspec[:, 0] - maxvo) / self.valf[step]
                    tmpocts = (tmpspec[:, 1]) / sum(tmpspec[:, 1])
                    masko = (tmpovel >= -3.) * (tmpovel <= 3.)
                    stdo = sqrt(sum((tmpovel[masko]**2) * tmpocts[masko]))
                    skewo = (sum(
                        (tmpovel[masko]**3) * tmpocts[masko])) / stdo**3.
                    kurto = (sum(
                        (tmpovel[masko]**4) * tmpocts[masko])) / stdo**4.
                    self.stdo.append(stdo)
                    self.skewo.append(skewo)
                    self.kurto.append(kurto)
                    self.meanvo.append(meanvo)
                    self.maxvo.append(maxvo)
                else:
                    self.stdo.append(-999.)
                    self.skewo.append(-999.)
                    self.kurto.append(-999.)
                    self.meanvo.append(-999.)
                    self.maxvo.append(-999.)

        self.stdhe = array(self.stdhe)
        self.stdh = array(self.stdh)
        self.stdo = array(self.stdo)
        self.skewhe = array(self.skewhe)
        self.skewh = array(self.skewh)
        self.skewo = array(self.skewo)
        self.kurthe = array(self.kurthe)
        self.kurth = array(self.kurth)
        self.kurto = array(self.kurto)
        self.meanvhe = array(self.meanvhe)
        self.meanvh = array(self.meanvh)
        self.meanvo = array(self.meanvo)
        self.maxvhe = array(self.maxvhe)
        self.maxvh = array(self.maxvh)
        self.maxvo = array(self.maxvo)
        self.time = array(self.time)
        self.years = array(self.years)
        self.valfs = array(self.valfs)
        self.magb = array(self.magb)
        self.thetas = array(self.thetas)
        self.sigtheta = array(self.sigtheta)
        self.vsw = array(self.vsw)
        self.dsw = array(self.dsw)
        self.tsw = array(self.tsw)
        return

    def plot_vdist(self, thetalist=[[0., pi / 18.], [pi - pi / 18., pi]]):
        thetamask = (self.theta >= thetalist[0][0]) * (self.theta <=
                                                       thetalist[0][1])
        if len(thetalist) > 1:
            for val in thetalist[1:]:
                thetamask += (self.theta >= val[0]) * (self.theta <= val[1])
        print where(thetamask)
        for i in where(thetamask)[0]:
            self.plot_step(i)

    def plot_step(self, step):
        if self.valf[step] > 0.:
            self.gp("unset label")
            self.gp("set label 'v_{sw}=%f' at -1.5,0.95" %
                    (self.swedata.vel[step]))
            self.gp("set label 'C_{A}=%f' at -1.5,0.90" % (self.valf[step]))
            self.gp("set label '{/Symbol= Q}=%f' at -1.5,0.85" %
                    (self.theta[step] / pi * 180.))
            self.gp("set label '{/Symbol= dQ}=%f' at -1.5,0.8" %
                    (self.mag.sigTHETA[step] / pi * 180.))
            self.gp("set title '%.4i DoY %f'" %
                    (self.year, self.hedata.time[step]))
            if amax(self.hedata.countspec[step, :, 1]) > 0.:
                self.gp.plot(
                    Data((self.hedata.countspec[step, :, 0] -
                          self.swedata.vel[step]) / self.valf[step],
                         self.hedata.countspec[step, :, 1] /
                         amax(self.hedata.countspec[step, :, 1]),
                         with_="lp lt 3 lw 3",
                         title="He^{2+}"))
            if amax(self.odata.countspec[step, :, 1]) > 0.:
                self.gp.replot(
                    Data((self.odata.countspec[step, :, 0] -
                          self.swedata.vel[step]) / self.valf[step],
                         self.odata.countspec[step, :, 1] /
                         amax(self.odata.countspec[step, :, 1]),
                         with_="lp lt 4 lw 3",
                         title="O^{6+}"))
            il = where(self.hdata.time == self.hedata.time[step])[0]
            if il.shape[0] > 0 and amax(self.hdata.tcrspec[il[0], :] +
                                        self.hdata.dcrspec[il[0], :]) > 0.:
                self.gp.replot(
                    Data((self.hdata.velspec - self.swedata.vel[step]) /
                         self.valf[step],
                         (self.hdata.tcrspec[il[0], :] +
                          self.hdata.dcrspec[il[0], :]) /
                         amax(self.hdata.tcrspec[il[0], :] +
                              self.hdata.dcrspec[il[0], :]),
                         with_="lp lt 1 lw 3",
                         title="H^{1+}"))

            self.gp.hardcopy("vdistperp_%.4i_%.3i.%.6i.ps" %
                             (self.year, int(self.hedata.time[step]),
                              int((self.hedata.time[step] % 1) * 1e6)),
                             color=True)
            self.gp.sync()
コード例 #8
0
ファイル: factorials.py プロジェクト: neffmallon/pistol
# Often we need to take the factorials of small numbers over and over;
#  the cached values make this much faster.
fact_cache = [1,1,2,6,24,120,720,5040]

def fact(n):
    if n < len(fact_cache): return fact_cache[n]
    return n*fact(n-1)

def stirling(n): return sqrt(2*pi*n)*pow(n/e,n)

def plot_fact(n=6):
    from Gnuplot import Gnuplot,Data
    f = []
    s = []
    for i in range(n):
        f.append(fact(i))
        s.append(stirling(i))
    steps = range(len(s))
    d1 = Data(steps,f,title='Factorial',with='lines')
    d2 = Data(steps,s,title='Stirling',with='lines')
    g = Gnuplot()
    g.plot(d1,d2)
    raw_input('Press any key...')
    return
    

if __name__ == '__main__':
    plot_fact()

コード例 #9
0
class polar3D:
    def __init__(self, data, angular_bins, radial_bins):
        """
		Method: __init__(data,angular_bins,radial_bins)
		The polar3D class is used to creates a color contour plot using Gnuplot.py in polar coordinates. 
		The countour pixel will therefore be small fraction of a circles depending on the chosen angular bins and 
		radial bins. Typical application would be to show the angular dependence of a spectrum.

		INPUT: data - which should be a list or numpy array containing the bin intensity for each angular
			      bin and radial bin. Must have the dimension: [x: len(angular_bins), y: len(radial_bins)]
		       angular_bins - should be a list or numpy array of the linear-spaced angular bins used in 'data'
		       radial_bins - should be a list or numpy array of the linear-spaced radial bins used in 'data'

		Available Methods: (use help('method') in ipython to learn more)

		self.plot()    - Plots the data
		self.reset()   - Resets the plot
		self.save(filename) - saves the plot to an eps
		self.set_title(arg) - set the plot title
		self.set_label(arg) - set the plot xy label
		self.set_cblabel(arg) - set the plot colorbar label
		self.set_range(arg) - set the maximum r-range of the plot
		self.set_tics(ticlist,ticlabels=arg) - define your own tics
		self.add_2ddata(data) - This adds additional 2d date to the plot
		self.cbtics(cbtics,cb_labels=arg)  - define you own cb tics
		self.grid(trig,angles=arg,color=arg,solid=arg) - turn on the polar grid
		self.set_log(arg) -Turn on logarithmic cb

		AN EXAMPLE HOW TO USE THIS CLASS IS SHOWN AT THE END OF THIS FILE!
		"""
        self.data = array(data)
        self.angular_bins = array(angular_bins)
        self.radial_bins = array(radial_bins)
        self.data2d = []
        if len(self.data[:, 0]) != len(self.angular_bins) or len(
                self.data[0, :]) != len(self.radial_bins):
            print "--- Dimension of DATA %s differs from angular bins %s or radial bins %s! ---" % (
                self.data.shape, self.angular_bins.shape,
                self.radial_bins.shape)
            print "--- Press Enter to Exit! ---"
            raw_input()
            exit()
        self.log = 0
        self.gp = Gnuplot()
        self.gp("set terminal x11 enhanced")
        self.gp("set size square")
        self.gp("set xrange [-%s:%s]" %
                (self.radial_bins[-1], self.radial_bins[-1]))
        self.gp("set yrange [-%s:%s]" %
                (self.radial_bins[-1], self.radial_bins[-1]))
        self.gp("set xlabel ''")
        self.gp("set ylabel ''")
        self.gp("set xtics out autofreq")
        self.gp("set ytics out autofreq")
        self.gp("set mxtics")
        self.gp("set mytics")
        self.gp("unset title")
        self.gp("unset grid")
        self.gp("set angles degrees")

    def __polar_to_cart__(self, r, phi):
        """
		This routine transforms polar coordinates to carthesian coordiantes 
		INPUT: r, phi (polar coord (phi in degree from 0 to 360))
		OUTPUT: x, y in carth. coord
		"""
        phi = 360. - phi
        deg_to_arcsec = (2 * pi) / 360.
        x = r * cos(phi * deg_to_arcsec)
        y = r * sin(phi * deg_to_arcsec)
        return x, y

    def __det_rgb__(self, rgb_color):
        """
		This routine calculated the RGB from an rgb value (0-1020; calculated like i
		long(1020.*(counts-min_counts)/(max_counts-min_counts))).
		INPUT: rgb color value (0,1020)
		OUTPUT: r, g, b (0-255,0-255,0-255)
		"""
        if rgb_color >= 765:
            r = 255
            g = 1020 - rgb_color
            b = 0
        elif 765 > rgb_color > 510:
            r = rgb_color - 510
            g = 255
            b = 0
        elif 510 >= rgb_color > 255:
            r = 0
            g = rgb_color - 255
            b = 510 - rgb_color
        elif 255 >= rgb_color > 0:
            r, g = 0, 0
            b = rgb_color
        else:
            r, g, b = 0, 0, 0
        if rgb_color == -1: r, g, b = 0, 0, 1
        if rgb_color == 0: r, g, b = 255, 255, 255
        if rgb_color == 0: r, g, b = 1, 0, 0
        return r, g, b

    def __create_gpdata__(self):
        """
		This routine create a Gnuplot data object from the given data, angular bins and radial bins
		"""
        self.__det_cbtics__()
        if self.log:
            max_counts = log10(max(self.data[nonzero(self.data)]))
            min_counts = log10(min(self.data[nonzero(self.data)]))
        else:
            max_counts = max(self.data)
            min_counts = min(self.data[nonzero(self.data)])
        self.gparray = []
        for rindex, radius in enumerate(self.radial_bins):
            for aindex, angle in enumerate(self.angular_bins):
                counts = self.data[aindex, rindex]
                if counts > 0:
                    if self.log: counts = log10(counts)
                    rgb_color = long(1020. * (counts - min_counts) /
                                     (max_counts - min_counts))
                    r, g, b = self.__det_rgb__(rgb_color)
                    r_s = radius - (self.radial_bins[1] -
                                    self.radial_bins[0]) / 2.
                    r_e = radius + (self.radial_bins[1] -
                                    self.radial_bins[0]) / 2.
                    a_s = angle - (self.angular_bins[1] -
                                   self.angular_bins[0]) / 2.
                    a_e = angle + (self.angular_bins[1] -
                                   self.angular_bins[0]) / 2.
                    a_s = angle
                    a_e = angle + (self.angular_bins[1] - self.angular_bins[0])
                    bin_koord = []
                    x1, y1 = self.__polar_to_cart__(r_s, a_s)
                    x2, y2 = self.__polar_to_cart__(r_e, a_s)
                    x3, y3 = self.__polar_to_cart__(r_e, a_e)
                    x4, y4 = self.__polar_to_cart__(r_s, a_e)
                    bin_koord.append([x1, y1])
                    bin_koord.append([x2, y2])
                    bin_koord.append([x3, y3])
                    bin_koord.append([x4, y4])
                    bin_koord.append([x1, y1])
                    dataobj = Data(
                        bin_koord,
                        with_='filledcurves lc rgb "#%02X%02X%02X"' %
                        (r, g, b))
                    self.gparray.append(dataobj)

    def __det_cbtics__(self):
        """
		This routine determines the cb tics drawn onto the colorbar
		"""
        max_counts = max(self.data)
        min_counts = min(self.data[nonzero(self.data)])
        cbrange = max_counts - min_counts
        tic_interval = [1, 2, 5]
        tic_level = range(long(log10(min_counts) - 1),
                          long(log10(max_counts) + 1) + 1)
        ntic_tmp = 1e9
        for ti in tic_interval:
            for tl in tic_level:
                ntic = abs(round(cbrange / (ti * 10**tl)) - 10)
                if ntic < ntic_tmp:
                    cti, ctl = ti, tl
                    ntic_tmp = ntic
        if cti == 5: self.mtn = 5.
        if cti == 1: self.mtn = 10.
        if cti == 2: self.mtn = 4.
        if self.log:
            self.cb_tics = arange(tic_level[0], tic_level[-1])
        else:
            self.cb_tics = arange(10**tic_level[0], 10**tic_level[-1],
                                  cti * 10**ctl) - 10**tic_level[0]
        self.cb_labels = None

    def __create_colorbar__(self):
        """
		This routine creates the colorbar for the contour plot
		"""
        if self.log:
            max_counts = log10(max(self.data[nonzero(self.data)]))
            min_counts = log10(min(self.data[nonzero(self.data)]))
        else:
            max_counts = max(self.data)
            min_counts = min(self.data[nonzero(self.data)])
        cbrange = max_counts - min_counts
        if self.log:
            mtn = 10.
        else:
            mtn = self.mtn
        cb_tics = self.cb_tics
        cbw = self.cb_tics[1] - self.cb_tics[0]
        xs, xe = 1.05, 1.1
        self.gp(
            "set arrow from graph %s, graph -0.01 to graph %s, graph 1. nohead"
            % (xs, xs))
        self.gp(
            "set arrow from graph %s, graph -0.01 to graph %s, graph 1. nohead"
            % (xe, xe))
        self.gp(
            "set arrow from graph %s, graph -0.01 to graph %s, graph -0.01 nohead"
            % (xs, xe))
        self.gp(
            "set arrow from graph %s, graph 1. to graph %s, graph 1. nohead" %
            (xs, xe))
        for rgb_color in arange(0, 1020.):
            r, g, b = self.__det_rgb__(rgb_color)
            ys = rgb_color / 1020. - 0.01
            ye = rgb_color / 1020.

            self.gp(
                'set obj %s rect from graph %s, graph %s to graph %s, graph %s fc rgb "#%02X%02X%02X" fs noborder'
                % (rgb_color + 1, xs, ys, xe, ye, r, g, b))
        for index, t in enumerate(cb_tics):
            rgb_color = long(1020. * (float(t) - min_counts) / cbrange)
            ye = rgb_color / 1020.
            if t > min_counts and t < max_counts:
                self.gp(
                    "set arrow from graph %s, graph %s to graph %s, graph %s nohead"
                    % (xs, ye, xs + (xe - xs) * 0.3, ye))
                self.gp(
                    "set arrow from graph %s, graph %s to graph %s, graph %s nohead"
                    % (xe, ye, xe - (xe - xs) * 0.3, ye))
                if self.cb_labels == None:
                    if self.log:
                        self.gp(
                            "set label '10^{%s}' at graph %s, graph %s front" %
                            (t, xe + (xe - xs) * 0.4, ye))
                    else:
                        self.gp("set label '%s' at graph %s, graph %s front" %
                                (t, xe + (xe - xs) * 0.4, ye))
                else:
                    self.gp("set label '%s' at graph %s, graph %s front" %
                            (self.cb_labels[index], xe + (xe - xs) * 0.4, ye))
            if self.log:
                mts = log10(arange(10**t, 10**(t + 1), 10**t))  #HIER WEITER
            else:
                mts = range(long(mtn))  #HIER WEITER
            for mt in mts:
                if self.log:
                    mtic = mt
                else:
                    mtic = t + (mt / mtn) * cbw
                if mtic > min_counts and mtic < max_counts:
                    if self.log:
                        rgb_color = long(1020. * (mtic - min_counts) / cbrange)
                    else:
                        rgb_color = long(
                            1020. * (t +
                                     (mt / mtn) * cbw - min_counts) / cbrange)
                    ye = rgb_color / 1020.
                    self.gp(
                        "set arrow from graph %s, graph %s to graph %s, graph %s nohead"
                        % (xs, ye, xs + (xe - xs) * 0.15, ye))
                    self.gp(
                        "set arrow from graph %s, graph %s to graph %s, graph %s nohead"
                        % (xe, ye, xe - (xe - xs) * 0.15, ye))

    def reset(self):
        """
		This routine resets the current plot window to standard options
		If you change certain parameters (like self.log) you may want to run this again to update the data
		This also 
		"""
        self.__create_gpdata__()
        self.gp = Gnuplot()
        self.gp("set xrange [-%s:%s]" %
                (self.radial_bins[-1], self.radial_bins[-1]))
        self.gp("set yrange [-%s:%s]" %
                (self.radial_bins[-1], self.radial_bins[-1]))
        self.gp("set xlabel ''")
        self.gp("set ylabel ''")
        self.gp("set xtics out autofreq")
        self.gp("set ytics out autofreq")
        self.gp("set mxtics")
        self.gp("set mytics")
        self.gp("unset title")
        self.gp("unset grid")
        self.gp("unset label")
        self.gp("unset title")
        self.cb_labels = None
        self.__det_cbtics__()

    def set_title(self, title, corner=0):
        """
		This routine sets the title
		INPUT: 
			title - title of the plot as a string
			corner - if 0 title is put on top of the plot, if 1 title is put in lower left corner 
		"""
        if corner == 0:
            self.gp("set title '%s'" % (title))
        else:
            self.gp("set label '%s' at graph %s, graph %s" %
                    (title, 0.02, 0.03))

    def set_label(self, label):
        """
		This routine set the x and y label
		"""
        self.gp("set xlabel '%s'" % (label))
        self.gp("set ylabel '%s'" % (label))

    def set_cblabel(self, label, xoff=0, yoff=0):
        """
		This routine sets the cb label
		INPUT: label - string of the cblabel
		       xoff - optional offset to the label in x direction
		       yoff - optional offset to the label in y direction
		"""
        x, y = 1.23, 0.6
        self.gp(
            "set label '%s' at graph %s, graph %s rotate by 90 right front" %
            (label, x + xoff, y + yoff))

    def set_range(self, arg):
        """
		This routine sets the r-range of the plot
		"""
        self.gp("set xrange [-%s:%s]" % (arg, arg))
        self.gp("set yrange [-%s:%s]" % (arg, arg))

    def set_tics(self, tics, ticlabels=None):
        """
		Explicitly gives tics to the plot. This also affects at what location the polar grid is drawn
		INPUT: tics      - list of tics (e.g. [0,10,12,13,25])
		       ticlabels - corresponding tic labels (e.g. ["ZERO","TEN","TWELVE","THIRTEEN","TWENTYFIVE"])
		                 -- if names is not given, the tic location is used as a ticlabel instead --
		"""
        ticlabel = ""
        if ticlabels != None:
            if len(tics) != len(ticlabels):
                print " --- Tics and ticlabels must have the same size! ---"
                print " --- Ignoring call of set_tics! ---"
                return 0
        for index, tic in enumerate(tics):
            if ticlabels != None:
                ticlabel += "'%s' %s," % (ticlabels[index], tic)
            else:
                ticlabel += "'%s' %s," % (tic, tic)
        self.gp("set xtics out (%s) rotate by -90" % (ticlabel[0:-1]))
        self.gp("set ytics out (%s)" % (ticlabel[0:-1]))

    def set_cbtics(self, cb_tics, cb_labels=None):
        """
		This routine sets the tics for the colorbar
		INPUT: cbtics - list of cbtics (e.g. [10,100,1000])
		       cb_labels - list of cbticlabels
		       -- if cbticlabels are not given, the cbtics are used as labels instead
		"""
        self.cb_tics = cb_tics
        self.cb_labels = cb_labels
        self.mtn = 0

    def add_2ddata(self, data, linewidth=2, color='red'):
        """
		Here you can add additional 2 dimensional data to the color contour plot
		INPUT: data (must be of dimension of angular_bins, values must be in range of radial_bins)
		       linewidth of the data
		       color of the data
		"""
        from numpy import append
        datax, datay = self.__polar_to_cart__(
            append(data, data[0]),
            append(self.angular_bins, self.angular_bins[0]))
        dataobj = Data(datax,
                       datay,
                       with_="lines lw %s lc rgb '%s'" % (linewidth, color))
        self.data2d.append(dataobj)

    def set_grid(self, trig, angles=45, color='black', solid=1, linewidth=0.5):
        """
		Here you can turn the grid on and off
		INPUT: trig - (0 for 'off', 1 for 'on')
		       angles - number of radial lines in polar grid
		       color - color of the grid
		INPUT: trig - (0 for 'off', 1 for 'on')
		"""
        if trig == 1:
            self.gp("set grid xtics nomxtics polar %s" % (angles))
            self.gp("set grid xtics front lw %s" % (linewidth))
            self.gp("set grid linecolor rgb '%s'" % (color))
            if solid == 1:
                self.gp("set grid linetype 1")
            else:
                self.gp("set grid linetype 0")
            for ang in arange(0, 360, angles):
                x, y = self.__polar_to_cart__(0.45, ang)
                self.gp(
                    "set label '%s {/Symbol \260}' at graph %s, graph %s textcolor rgb '%s' front"
                    % (ang, x + 0.47, y + 0.49, color))
        else:
            self.gp("unset grid")

    def set_log(self, trig):
        """
		Here you can turn on an logarithmic plot
		INPUT: trig - (0 for 'off', 1 for 'on')
		       -- Data set muste be reloaded, which could take while ---
		"""
        if trig == 1:
            self.log = trig
        else:
            self.log = 0

    def save(self, filename='polar.eps', font="Helvetica", fontsize=15):
        """
		This routine saves the plot into an eps file
		INPUT: filename - filename
		       font - name of the eps font
		       fontsize- size of eps font
		"""
        self.gp.hardcopy(filename,
                         enhanced=1,
                         color=1,
                         solid=1,
                         fontname=font,
                         fontsize=fontsize)

    def plot(self):
        """
		This routine creates the Gnuplot plot
		"""
        self.__create_gpdata__()
        self.__create_colorbar__()
        if self.data2d:
            for d in self.data2d:
                self.gparray.append(d)
        self.gp.plot(*self.gparray)

    def kill_plot(self):
        """
		Routines that kills the Gnuplot window
		"""
        del self.gp
コード例 #10
0
ファイル: cascade.py プロジェクト: annefi/PUI-fun
class cascade:
    def __init__(self, B, power, index, eff, ions, vsw, valf):
        "B\t->\t float : magnetic field strength in nT\npower\t->\t float : scales the wavepower spectrum\nindex\t->\t float : spectral index of cascade\neff\t->\t float : efficiency for energy drain from cascade\nions\t->\t [nrions][ioname(str),ionmass(float,in amu),ioncharge(float,in e),iondens(float,in respect to protons)\nvsw\t->\t float : solar wind speed\nvalf\t->\t float : alfven speed"
        self.B = B * 1e-9
        self.power = power
        self.index = index
        self.eff = eff
        self.vsw = vsw
        self.valf = valf
        self.name = []
        self.dens = []
        self.mass = []
        self.mqarr = []
        self.charge = []
        self.sequence = []
        for ion in ions:
            self.name.append(ion[0])
            self.mass.append(ion[1])
            self.charge.append(ion[2])
            self.dens.append(ion[3])
            self.mqarr.append(ion[2] / ion[1])
            self.sequence.append(0)
        self.qm0 = 1.602176487e-19 / 1.66053886e-27
        self.warr = []
        self.dim = len(self.mqarr)

        self.get_sequence()
        self.build_warr()
        self.calc_casc()

    def set_index(self, a):
        self.index = a

    def set_B(self, a):
        self.B = a * 1e-9

    def set_efficiency(self, a):
        self.eff = a

    def build_warr(self):
        "calculates the resonance frequencies"
        for i in self.sequence:
            self.warr.append(-(self.mqarr[i] * self.qm0 * self.B) /
                             (1. - self.vsw / self.valf))

    def get_sequence(self):
        mqarr = []
        sequence = []
        for val in self.mqarr:
            mqarr.append(val)
        for i in range(self.dim):
            maxval = min(mqarr)
            maxpos = 0
            i = 0
            while (mqarr[i] != maxval):
                i += 1
            maxpos = i
            """    
            for i in range(self.dim):
                if (mqarr[i]==maxval):
                    maxpos=i
            """
            sequence.append(maxpos)
            newmqarr = []
            for i in range(self.dim):
                if (i != maxpos):
                    newmqarr.append(mqarr[i])
                else:
                    newmqarr.append(100.)
            mqarr = []
            for val in newmqarr:
                mqarr.append(val)
        self.sequence = sequence

    def calc_casc(self):
        Parr = [[.01, self.power]]
        dParr = [[.01, 0.]]
        for i in range(self.dim):
            Parr.append([self.warr[i], 0.])
            dParr.append([self.warr[i], 0.])
        Parr[0][1] = (self.power * Parr[0][0]**-self.index)
        dParr[0][1] = (self.power * Parr[0][0]**-self.index)
        #dParr[0][1]=0.
        Parr[1][1] = (self.power * Parr[1][0]**-self.index) - (
            self.power * Parr[1][0]**-self.index
        ) * self.dens[self.sequence[0]] * self.eff * self.charge[
            self.sequence[0]]**2 / self.mass[self.sequence[0]]
        dParr[1][1] = (self.power * Parr[1][0]**-self.index) * self.dens[
            self.sequence[0]] * self.eff * self.charge[
                self.sequence[0]]**2 / self.mass[self.sequence[0]]
        for i in range(self.dim - 1):
            P0 = (self.power * Parr[i + 2][0]**-self.index) - (
                (self.power * Parr[i + 1][0]**-self.index) - Parr[i + 1][1])
            dP = P0 * self.dens[self.sequence[i + 1]] * self.eff * self.charge[
                self.sequence[i + 1]]**2 / self.mass[self.sequence[i + 1]]
            print "P0,dP"
            print P0, dP
            if (dP < P0):
                Parr[i + 2][1] = P0 - dP
            else:
                Parr[i + 2][1] = 1.
                dP = P0
            dParr[i + 2][1] = dP
            if (i == 0):
                dParr[i + 2][1] = dP
            if (i == 1):
                dParr[i + 2][1] = dP
            if (i == 2):
                dParr[i + 2][1] = dP
        self.Parr = Parr
        self.dParr = dParr

        dParr2 = []
        dParr3 = []
        dVarr = []

        E0 = 0.
        ppos = 0
        hepos = 0
        for j in range(len(self.sequence)):
            if (self.name[self.sequence[j]] == "H1+"):
                ppos = j
            if (self.name[self.sequence[j]] == "He2+"):
                hepos = j
        for i in range(self.dim):
            pos = self.sequence[i]
            print "pos = ", i, self.sequence[i], pos
            print "p,hepos = ", ppos, hepos
            dParr2.append([
                dParr[i + 1][0], (dParr[i + 1][1] / self.dens[pos]) /
                (dParr[ppos + 1][1] / self.dens[self.sequence[ppos]])
            ])
            # dv/dvHe
            #a=sqrt((dParr[i+1][1]*2./self.dens[i]**2)/self.mass[i])*(self.charge[i]**1.5/self.mass[i])/(sqrt((dParr[self.dim-3][1]*2./self.dens[self.dim-4]**2)/self.mass[self.dim-4])*(self.charge[self.dim-4]**1.5/self.mass[self.dim-4]))

            a = sqrt(
                (dParr[i + 1][1] * 2. / self.dens[pos]**1.) / self.mass[pos]
            ) * (self.charge[pos]**1.5 / self.mass[pos]**1.) / (sqrt(
                (dParr[hepos + 1][1] * 2. / self.dens[self.sequence[hepos]]**
                 1.) / self.mass[self.sequence[hepos]]) * (
                     self.charge[self.sequence[hepos]]**1.5 /
                     self.mass[self.sequence[hepos]]**1.))
            # b = E/Ep
            b = (dParr[i + 1][1] / self.dens[pos]) / (
                dParr[ppos + 1][1] / self.dens[self.sequence[ppos]])

            print a, b
            #dParr3.append([self.mass[i]/self.charge[i],(a)*(self.charge[i]**1.5/self.mass[i])])
            dParr3.append([self.charge[pos] / self.mass[pos], b])
            dVarr.append([self.charge[pos] / self.mass[pos], a])
        pdParr = []
        pdVarr = []
        self.pdVarr = []
        self.pdParr = []
        for j in range(self.dim):
            for k in range(self.dim):
                if (self.name[self.sequence[k]] == self.name[j]):
                    pos = k
                    if (self.name[j] != "H1+"):
                        self.pdVarr.append(Data([dVarr[pos]]))
                    self.pdVarr[len(self.pdVarr) - 1].set_option_colonsep(
                        "with", "p pt %i lt 3" % (j + 1))
                    self.pdParr.append(Data([dParr3[pos]]))
                    if (self.name[j] == "H1+"):
                        self.pdParr[len(self.pdParr) - 1].set_option_colonsep(
                            "title", "'%s'" % ("H^{1+}"))
                    if (self.name[j] == "H1+"):
                        self.pdParr[len(self.pdVarr) - 1].set_option_colonsep(
                            "with", "p pt %i lt 1" % (j + 1))
                    else:
                        self.pdParr[len(self.pdVarr) - 1].set_option_colonsep(
                            "with", "p pt %i lt 3" % (j + 1))

        self.dParr2 = dParr2
        self.dParr3 = dParr3
        self.dVarr = dVarr

    def plot(self):

        self.gp = Gnuplot()
        #self.gp("set autoscale")
        self.gp("set size square")
        self.gp("set xrange[0.01:.1]")
        self.gp("set yrange[100.:1000.]")
        self.gp("set format xy '10^%T'")
        self.gp("set xlabel '{/Symbol w} [Hz]'")
        self.gp("set ylabel 'Wave Power [arb.]'")
        self.gp("set logscale xy")
        self.pParr = Data(self.Parr)
        self.pParr.set_option_colonsep("with", "lp")
        self.gp.plot(self.pParr)
        #self.gp.replot(Data(self.dParr2))
        #self.gp.replot(Data(self.dParr2))
        self.gp("a=%f" % (self.power))
        self.gp("k=%f" % (self.index))
        self.gp("f(x)=a*x**-k")
        self.gp("f2(x)=(a*.7)*x**-(k+.1)")
        self.gp("f3(x)=(a*1e-5)*x**-(k+4.)")
        #self.gp.replot("f(x) with l lt 3","f2(x) with l lt 4","f3(x) with l lt 5")
        self.gp("set term postscript color 18 lw 2 eps")
        self.gp.hardcopy("Pcascall.ps", color="true", fontsize=18)
        self.gp2 = Gnuplot()
        self.gp2("set logscale xy")
        self.gp2("set title 'theocasc dE'")
        #gp2("set yrange[1:1.1]")
        first = 1
        for j in range(self.dim):
            if (first == 1):
                self.gp2.plot(self.pdParr[j])
                first = 0
            else:
                self.gp2.replot(self.pdParr[j])
        self.gp3 = Gnuplot()
        self.gp3("set logscale xy")
        self.gp3("set title 'theocasc dV'")
        first = 1
        for j in range(self.dim):
            if (first == 1):
                self.gp3.plot(self.pdVarr[j])
                first = 0
            else:
                self.gp3.replot(self.pdVarr[j])
コード例 #11
0
from Gnuplot import Gnuplot

pin = open("/home/ivar/berger/projects/ionpositions/ion_para.dat")
hepos = []
o6pos = []
o7pos = []
for step in range(58):
    s = pin.readline()
    k = s.split()
    ions = float(k[5])
    s = pin.readline()
    for i in range(ions):
        s = pin.readline()
        k = s.split()
        if (k[0] == "He2+"):
            hepos.append([float(k[7]), float(k[2])])
        if (k[0] == "O6+"):
            o6pos.append([float(k[7]), float(k[2])])
        if (k[0] == "O7+"):
            o7pos.append([float(k[7]), float(k[2])])

pin.close()
gp = Gnuplot()
gp("f(x)=8")
gp("set yrange[5:10]")
gp("set xrange[200:700]")
gp.plot(hepos, "f(x)")

#gp.plot(hepos,o6pos,o6pos,o7pos)
コード例 #12
0
ファイル: linfit.py プロジェクト: annefi/PUI-fun
#a               = -7.61996e-12     +/- 2.396e-15    (0.03145%)
#b               = 0.000565656      +/- 4.014e-09    (0.0007097%)
#c               = 104.733          +/- 0.00141      (0.001346%)

def tstep2bin2(tstep):
    a = -7.61996e-12     
    b = 0.000565656      
    c = 104.733          

    return a*tstep*tstep+b*tstep+c

funct2=zeros([xdim],Float)

for i in range(xdim):
    funct2[i]=tstep2bin2(i)



gp=Gnuplot()
gp("c=1.")
gp("a=1.")
gp("b=1.")
#gp("set outp X11")
#gp("f(x)=a*x**2+b*x+c")
#gp("fit f(x) 'tmp.dat' via a,b,c")
gp("set data style dots")
gp("set xrange[500000:1000000]")
gp.plot(data,funct2)
    

コード例 #13
0
        for i in range(n_coeffs):
            line = string.split(data[number+14+i])
            exponents[i] = string.atof(line[0])
            coeffs[i] = string.atof(line[1])
        print "Rep orbital for atom", atom, "orbital", orbital, "rc", rc

        max_dist = rc*1.1
        dr = max_dist/100
        r = range(101)
        rep = range(101)
        orig = range(101)
        for i in range(101):
            r[i] = dr*i
            rep[i] = 0.0
            orig[i] = 0.0
        for i in range(101):
            R = alpha[0]+r[i]*(alpha[1]+r[i]*(alpha[2]+r[i]*(alpha[3]+r[i]*alpha[4])))
            rep[i] = C+sgn*exp(R)
            orig[i] = 0.0
            for j in range(n_coeffs):
                orig[i] = orig[i]+coeffs[j]*exp(-exponents[j]*r[i]*r[i])
        d1 = Data(r[:],rep[:],with='lines')
        d2 = Data(r[:],orig[:],with='lines')
        g.plot(d1,d2)
        raw_input("Press enter to continue...")

    number = number+1
            
                            
                       
コード例 #14
0
ファイル: meanallions.py プロジェクト: annefi/PUI-fun
gp("%s" % (xtics))
gp("set xrange[0:%i]" % (numpion[-1][-1][0] + 1))
gp("set yrange[10.:2000.]")
gp("set xlabel '{/Times-Roman=20 q [e]}'")  # offset 1.5")
gp("set ylabel '{/Times-Roman=20 # data points}' offset -.32")
gp("set format y '10^%T'")
gp("set log y")

for i in range(len(elemlist)):
    tmp = array(numpion[i])
    print elemlist[i], mean(tmp[:, 0]), 10.
    gp("set label '%s' at %f,%f center front" %
       (elemlist[i], mean(tmp[:, 0]), 100.))
#pnumpion=array(pnumpion)
gp.plot(
    pnumpion[0], pnumpion[1], pnumpion[2], pnumpion[3], pnumpion[4],
    pnumpion[5], pnumpion[6], pnumpion[7], pnumpion[8], pnumpion[9]
)  #,pnumpion2[0],pnumpion2[1],pnumpion2[2],pnumpion2[3],pnumpion2[4],pnumpion2[5],pnumpion2[6],pnumpion2[7],pnumpion2[8],pnumpion2[9])
#for i in range(len(pnumpion)-1):
#    gp.replot(pnumpion[i+1])

gp("set origin 0.,.288")
gp("set size 1.,0.65")
gp("set autoscale")
gp("unset xlabel")
gp("unset label")
gp("unset log y")
gp("unset format")
gp("set yrange[-1.:1.]")
gp("set grid front")
gp("unset grid")
#gp("set x2range[0:10]")
コード例 #15
0
#gp("f(x)=3.e6*x**-5.7")
gp("set log yx")
gp("set yrange[0.1:1e5]")
gp("set xrange[.1:100.]")
gp("set format y '10^{%T}'")
gp("set xlabel 'keV/amu'")
gp("set ylabel 'N[#]'")
if (len(hedata.time) == 1):
    gp("set title '2007 DoY %.3f'" % (hedata.time[0]))
else:
    gp("set title '2007 DoY %.3f-%.3f'" %
       (hedata.time[0], hedata.time[len(hedata.time) - 1]))
first = 1
for spec in pspec:
    if (first):
        gp.plot(spec)
        first = 0
    else:
        gp.replot(spec)
#gp.replot(psumhist)
#gp.replot("f(x)")

if (len(hedata.time) == 1):
    name = "%.3f" % (hedata.time[0])
else:
    name = "%.3f-%.3f" % (hedata.time[0], hedata.time[len(hedata.time) - 1])

gp.hardcopy("%s.ps" % (name), color="true", fontsize=20)

#for i in range(len(fedata[0].time)):
#    sumspec.append([
コード例 #16
0
ファイル: plot_testdist.py プロジェクト: annefi/PUI-fun
gphistsumnorm2.set_option_colonsep("using", "1:2")
gphistsumnorm2.set_option_colonsep("title",  "'sumnorm2 soll:%f'" %(sollsum))
gphistsumnorm2.set_option_colonsep("with","boxes")


#!!!!!!!!!!!!!!!!!!!!!! plotte daten !!!!!!!!!!!!!!!!!!!!!!!!!!!!



        
ion=2
for ion in range(numberions):
    
    xrange=[nomcounts[ion]-diffrange[ion],nomcounts[ion]+diffrange[ion]]
    #xrange=[610,630]
    gp=Gnuplot()
    gp("set xlabel 'Fit Result'")
    gp("set ylabel 'Number of Fit Results' ")
    gp("set xrange[%i:%i]" % (xrange[0],xrange[1]))
    #gp("set title 'Fitergebnis 1000 Datensätze'")
    gp("set title ''")
    gp("set border 15 lw 2")

    print "ionnames = ",ionname
#    gp.plot(gphist[ion],gphist2[ion],gphistnorm[ion],gphistnorm2[ion])
    gp.plot(gphist[ion])
    #gp.plot(gphistsum,gphistsum2,gphistsumnorm,gphistsumnorm2)
    gp("set term postscript color 18")
    gp.hardcopy("%s.ps"%(ion_names[ion]), color=True, fontsize=18)
    #gp.hardcopy("Summe.ps", color=True)
コード例 #17
0
plotswepamdata.set_option_colonsep("title", "'SWEPAM'")
plotswepamspeed.set_option_colonsep("with", "lines")
plotswicsdata.set_option_colonsep("with", "points ls 3")
plotswicsdata.set_option_colonsep("title", "'SWICS'")
plotswicsspeed.set_option_colonsep("with", "lines")
plotswicspspeed.set_option_colonsep("with", "lines")
plotaspang.set_option_colonsep("with", "lines")

gp=Gnuplot()
gp("set xrange[0:60]")
gp("set format y '10^{%T}'")
gp("set xlabel 'DoY 2007'")
gp("set ylabel 'He^{2+} Density [1cm^{-3}]'")
#gp("set yrange[0.01:1.]")
gp("set log y")
gp.plot(plotswepamdata,plotswicsdata,plotaspang)
gp("set term postscript color 18 lw 2 eps")
gp.hardcopy("absHedensswepamswics.ps",color=True, fontsize=18)
#gp2=Gnuplot()
#gp2("set xrange[0:60]")
#gp("set yrange[0.01:1.]")
#gp2("set logscale y")
#gp2.plot(plotswepamspeed,plotswicsspeed,plotswicspspeed)
#gp3=Gnuplot()
#gp3("set xrange[0:60]")
#gp("set yrange[0.01:1.]")
#gp2("set logscale y")
#gp3.plot(plotswepampdata)
#gp("set outp 'etslicefastswnew.ps'")
コード例 #18
0
ファイル: analyse_pui.py プロジェクト: annefi/PUI-fun
    br=13.1/float(doys[year-2006])
    hedoyinstrrm[i,1]=mean(hedoydatainstr[(hedoydatainstr[:,0]>=hedoydatainstr[i,0]-br)*(hedoydatainstr[:,0]<=hedoydatainstr[i,0]+br)][:,1])
xdim,ydim=hedoydatainstrmag.shape
hedoyinstrmagrm=zeros([xdim,ydim])
hedoyinstrmagrm[:,0]=hedoydatainstrmag[:,0]
bw=27
for i in range(bw/2,xdim-bw/2+1):
    year=int(hedoydatainstr[i,0])
    br=13.1/float(doys[year-2006])
    hedoyinstrmagrm[i,1]=mean(hedoydatainstrmag[(hedoydatainstrmag[:,0]>=hedoydatainstrmag[i,0]-br)*(hedoydatainstrmag[:,0]<=hedoydatainstrmag[i,0]+br)][:,1])
    #hedoyinstrmagrm[i,1]=mean(hedoydatainstrmag[i-bw/2:i+bw/2+1,1])


gp=Gnuplot()
gp("set title 'data'")
gp.plot(Data(data[:,0]+data[:,1]/366.,data[:,2],with_="p lt 1"),Data(data[:,0]+data[:,1]/366.,data[:,4],with_="l lt 3"))
gp2=Gnuplot()
gp2("set title 'instr'")
gp2.plot(Data(hedoydatainstr,with_="steps lt 3"),Data(hedoyinstrrm,with_="steps lt 1 lw 3"))
gp3=Gnuplot()
gp3("set title 'instrmag'")
gp3.plot(Data(hedoydatainstrmag,with_="steps lt 3"),Data(hedoyinstrmagrm,with_="steps lt 1 lw 3"))
gp4=Gnuplot()
gp4("set title 'data/instr hires'")
gp4.plot(Data(data[:,0]-2000+data[:,1]/366.,data[:,2]/getinstrcorr(data[:,3]),with_="l lt 1"),Data(data[:,0]-2000+data[:,1]/366.,sqrt(data[:,4])*sin(data[:,5]),with_="l lt 3"),Data(data[:,0]-2000+data[:,1]/366.,sqrt(data[:,4]),with_="l lt 4"))


#timemask=(data[:,1]>300.)*(data[:,1]<365.)
mask=(data[:,3]>600.)*(data[:,3]<700.)*(data[:,4]>3.)*(data[:,4]<5.)#*timemask
thetacounts,thetabins=histogram(data[mask][:,5],linspace(0,pi,19),weights=data[mask][:,2])
normthetacounts,x=histogram(data[mask][:,5],linspace(0,pi,19))
コード例 #19
0
histvswcorrfac, vswbins = histogram(corrarr2[:, 0],
                                    linspace(200, 1000, 41),
                                    weights=corrarr2[:, 3])
normvswcounts, x = histogram(corrarr2[:, 0], linspace(200, 1000, 41))
histvswcounts /= normvswcounts
histvswmag /= normvswcounts
histvswcorrfac /= normvswcounts
vswbins = vswbins[:-1]
gp6 = Gnuplot()
gp6.plot(
    Data(vswbins[histvswcounts > 0.],
         histvswcounts[histvswcounts > 0.],
         with_="steps lt 1"),
    Data(vswbins[histvswmag > 0.],
         histvswmag[histvswmag > 0.],
         with_="steps lt 3"),
    Data(vswbins[histvswcorrfac > 0.],
         histvswcorrfac[histvswcorrfac > 0.],
         with_="steps lt 4"),
    Data(vswbins[histvswcorrfac > 0.],
         histvswcorrfac[histvswcorrfac > 0.] * histvswmag[histvswcorrfac > 0.],
         with_="steps lt 5"))
gp5 = Gnuplot()
#gp5.plot(Data(vswbins[histvswcorrfac>0.],histvswcounts[histvswcorrfac>0.]/histvswcorrfac[histvswcorrfac>0.]*histvswmag[histvswcorrfac>0.],with_="steps lt 3"))
gp5.plot(
    Data(vswbins[histvswcorrfac > 0.],
         histvswcounts[histvswcorrfac > 0.] /
         histvswcorrfac[histvswcorrfac > 0.],
         with_="steps lt 3"))

# Build w histograms
コード例 #20
0
ファイル: alfvenwaves2.py プロジェクト: annefi/PUI-fun
        alphanfft = []
        for i in range(N):
            alphanfft.append(alphan[i][1])
        psdnraw = fft(alphanfft)
        psdnges = []
        for i in range(len(psdnraw) / 2 + 1):
            psdnges.append([
                (float(i) / (float(N) * timeres)),
                2. * abs(psdnraw[i].imag) / N + 2. * abs(psdnraw[i].real) / N
            ])

        if (bin == 0):
            psdngessum = psdnges
        if (bin != 0):
            for i in range(len(psdngessum)):
                psdngessum[i][1] += psdnges[i][1]
    plotpsdngessum = Data(psdngessum)
    plotpsdngessum.set_option_colonsep("with", "lines")
    gp = Gnuplot()
    gp("set title '%f , gap = %i'" % (doy, gap))
    gp("set logscale x")
    gp("set logscale y")
    gp("set yrange[1e-5:0.1]")
    gp("set xrange[0.001:1.]")
    gp.plot(plotpsdngessum)
    gp.hardcopy("%f_%is_%i_%i.ps" % (doy, int(timeres), N, binning),
                color=True,
                fontsize=18)
    del gp
コード例 #21
0
ファイル: soho_plot_hep.py プロジェクト: annefi/PUI-fun
    tmpsemdat = semtot[semtot[:, 1] == years[i]]
    if (years[i] != 2008):
        semdat[sum(doys[0:i]):sum(doys[0:i]) + doys[i], 1] = tmpsemdat[:, 15]
    else:
        semdat[sum(doys[0:i]):sum(doys[0:i]) + doys[i] - 2, 1] = tmpsemdat[:,
                                                                           15]
semdat2 = zeros([len(years) * 365 + 1, 2])
semdat2[:, 0] = arange(len(years) * 365. + 1.)
for i in range(len(years)):
    tmpsemdat = semtot[semtot[:, 1] == years[i]]
    if (years[i] != 2008):
        semdat2[sum(doys[0:i]):sum(doys[0:i]) + doys[i], 1] = tmpsemdat[:, 14]
    else:
        semdat2[sum(doys[0:i]):sum(doys[0:i]) + doys[i] - 2, 1] = tmpsemdat[:,
                                                                            14]

semdat[:, 1] /= 1e8
semdat[:, 1] *= 1.5

gp2 = Gnuplot()
gp2("set style data histeps")
gp2("set yrange[0:2000]")
gp2("set xlabel 'Date'")
gp2("set ylabel 'He^{1+} 1.5<w<2.0 / scaled UV-flux'")
gp2("set xtics ('2006' 1,'' 31+1 1,'' 31+28+1 1,'' 31+28+31+1 1,'' 31+28+31+30+1 1,'' 31+28+31+30+31+1 1,'' 31+28+31+30+31+30+1 1,'' 31+28+31+30+31+30+31+1 1,'' 31+28+31+30+31+30+31+31+1 1,'' 31+28+31+30+31+30+31+31+30+1 1,'' 31+28+31+30+31+30+31+31+30+31+1 1,'' 31+28+31+30+31+30+31+31+30+31+30+1 1,'2007' 365+1,'' 365+31+1 1,'' 365+31+28+1 1,'' 365+31+28+31+1 1,'' 365+31+28+31+30+1 1,'' 365+31+28+31+30+31+1 1,'' 365+31+28+31+30+31+30+1 1,'' 365+31+28+31+30+31+30+31+1 1,'' 365+31+28+31+30+31+30+31+31+1 1,'' 365+31+28+31+30+31+30+31+31+30+1 1,'' 365+31+28+31+30+31+30+31+31+30+31+1 1,'' 365+31+28+31+30+31+30+31+31+30+31+30+1 1,'2008' 2*365+1,'' 2*365+31+1 1,'' 2*365+31+29+1 1,'' 2*365+31+29+31+1 1,'' 2*365+31+29+31+30+1 1,'' 2*365+31+29+31+30+31+1 1,'' 2*365+31+29+31+30+31+30+1 1,'' 2*365+31+29+31+30+31+30+31+1 1,'' 2*365+31+29+31+30+31+30+31+31+1 1,'' 2*365+31+29+31+30+31+30+31+31+30+1 1,'' 2*365+31+29+31+30+31+30+31+31+30+31+1 1,'' 2*365+31+29+31+30+31+30+31+31+30+31+30+1 1,'2009' 3*365+2,'' 3*365+31+2 1,'' 3*365+31+28+2 1,'' 3*365+31+28+31+2 1,'' 3*365+31+28+31+30+2 1,'' 3*365+31+28+31+30+31+2 1,'' 3*365+31+28+31+30+31+30+2 1,'' 3*365+31+28+31+30+31+30+31+2 1,'' 3*365+31+28+31+30+31+30+31+31+2 1,'' 3*365+31+28+31+30+31+30+31+31+30+2 1,'' 3*365+31+28+31+30+31+30+31+31+30+31+2 1,'' 3*365+31+28+31+30+31+30+31+31+30+31+30+3 1,'2010' 4*365+2,'' 4*365+31+2 1,'' 4*365+31+28+2 1,'' 4*365+31+28+31+2 1,'' 4*365+31+28+31+30+2 1,'' 4*365+31+28+31+30+31+2 1,'' 4*365+31+28+31+30+31+30+2 1,'' 4*365+31+28+31+30+31+30+31+2 1,'' 4*365+31+28+31+30+31+30+31+31+2 1,'' 4*365+31+28+31+30+31+30+31+31+30+2 1,'' 4*365+31+28+31+30+31+30+31+31+30+31+2 1,'' 4*365+31+28+31+30+31+30+31+31+30+31+30+3 1)"
    )
gp2.plot(Data(hetsdata, title='He^{1+} [cts/day]', with_='histeps lt 1'),
         Data(herunav, title='He@_{RM}^{1+} (+-13 Days)', with_='l lt 3 lw 3'),
         Data(semdat, title="SEM UV", with_="l lt 4"))
gp2.hardcopy("He1+_soho.ps", color=True)
コード例 #22
0
ファイル: multipanel_plot.py プロジェクト: annefi/PUI-fun
gp("plot sin(x)")
gp("set ytics")
gp("set autoscale")
gp("set xrange[1:1e11]")
gp("set key box")
gp("unset xtics")
gp("unset xlabel")
gp("set size 1,0.285")
gp("set origin 0,0.045")
gp("set lmargin 10")
gp("set logscale y")
gp("set format y '10^{%03T}'")
gp("set ylabel -1.85")
gp("set ylabel 'Proton density in cm^{-3}' font 'Helvetica,10'")
#gp("plot 1000*f(x) w l title 'Proton density'")
gp.plot("1e100*f(x)")
gp("set border 10")
gp("set format y '10^{%03T}'")
gp("set size 1,0.29")
gp("set origin 0,0.264")
gp("set ylabel -1.85")
gp("set ylabel 'Proton temperature in K'")
#gp("plot f(x) w l title 'Proton temperature'")
gp.plot("1e-4*f(x)")
gp("set origin 0,0.487")
gp("set format y '%g'")
gp("set border 11")
gp("set ylabel -0.6")
gp("set ylabel 'Alpha to proton ratio'")
#gp("plot f(x) w l title 'Alpha to proton ratio'")
gp.plot("1000*f(x)")
コード例 #23
0
class multiplot:
    """
    docstring should be added ...
    """
    def __init__(self, panels, setformat=0):
        self.panel = []
        for i in range(panels):
            self.panel.append(plotdata())
        self.xrange = [0., 100.]
        self.xlabel = "DoY"
        self.xaxis_flag = 0
        self.title = ""
        self.gv = 1
        self.format = setformat  #0 Querformat, 1 Hochformat
        self.outname = "multiplot"
        self.plotmarks = []

    def addplotmark(self, style, lt=5):
        self.plotmarks.append(plotmark(style, lt))

    def addpanel(self, data):
        self.panel.append(plotdata())

    def setxrange(self, a, b):
        self.xrange[0] = a
        self.xrange[1] = b

    def settitle(self, a):
        self.title = a

    def setgv(self, a):
        self.gv = a

    def setxaxis2(self, a):
        """
	This routine plots a seconds xaxis on top of the screen.
	Input must be a list of lists containing the x2label and xposition of that label:
	e.g: [["Jan",30],["Feb",58]...]
	"""
        self.xaxis_flag = 1
        try:
            b = a[0][0]
            b = a[0][1]
        except:
            print "Wrong input for SELF.SETXAXIS2()"
            print "Input must be of the form of [['label',xpos],['label',xpos],[],[],...,[]]"
            print "Second x axis is omitted. Hit ENTER to proceed"
            blub = raw_input()
        self.xaxis2 = a

    def setxlabel(self, a):
        self.xlabel = str(a)

    def setname(self, a):
        self.outname = str(a)

    def build_xaxis2(self):
        """
 	This routine builds the seconds xaxis from self.xaxis2
	"""
        for label in self.xaxis2:
            if label[1] > self.xrange[0] and label[1] < self.xrange[1]:
                self.gp(
                    "set label center'{/Helvetica=5  %s}' at first %f, screen 1.00"
                    % (label[0], label[1]))
        self.xaxis_flag = 0

    def plot(self):
        self.gp = Gnuplot()
        self.generatebox()
        for panel in range(len(self.panel)):
            self.plotpanel(panel)
        #self.gp("unset tmargin")
        #self.gp("unset title")
        #self.gp("unset multiplot")
        #self.gp("set size 1,1")
        #self.gp("set xtics")
        self.gp("set autoscale")
        self.gp.sync()
        os.system("ps2eps -f -B -l %s.ps" % (self.outname))
        os.system("rm %s.ps" % (self.outname))
        if (self.gv):
            os.system("okular %s.eps" % (self.outname))
        del self.gp

    def generatebox(self):
        self.gp("set term postscript solid enhanced color")
        self.gp("set output '%s.ps'" % (self.outname))
        self.gp("set border front")
        self.gp("unset key")
        self.gp("unset colorbox")
        self.gp(
            "set palette model RGB functions gray<1.e-20 ? 1 : gray<0.5 ? gray*2 : 1 , gray<1.e-20 ? 1 : gray<0.5 ? gray*2 : 2-gray*2, gray <1.e-20 ? 1 : gray<0.5 ? 1-sqrt(gray*2) : 0"
        )
        if (self.format):
            self.gp("set xtics nomirror font 'Helvetica,9'")
        else:
            self.gp("set xtics nomirror")
        self.gp("set multiplot")
        self.gp("set xlabel 0,0.1")
        if (self.format):
            self.gp("set xlabel '%s' font 'Helvetica,9'" % (self.xlabel))
        else:
            self.gp("set xlabel '%s' font 'Helvetica,12'" % (self.xlabel))
        self.gp("set xrange[%e:%e]" %
                (float(self.xrange[0]), float(self.xrange[1])))
        if (self.format):
            self.gp("set ytics font 'Helvetica,9'")
        else:
            self.gp("set ytics")
        #self.gp("set autoscale")
        self.gp("set key right samplen 0.5")
        self.gp("set key spacing 0.8")
        self.gp("unset xtics")
        self.gp("unset xlabel")
        self.gp("set border front")
        if self.xaxis_flag == 1:
            self.build_xaxis2()

    def plotpanel(self, panel):
        self.buildplotmarks(panel)
        first = 1
        self.gp("unset key")
        self.gp(
            "set label center'{/Helvetica=9  %s}' at screen 0.3, screen 1.02" %
            (self.title))
        self.gp("set border front")
        #self.gp("unset label")
        if (self.panel[panel].grid):
            self.gp("set grid xtics front")
        else:
            self.gp("set grid xtics front")
            self.gp("unset grid")
        size = (.86 / (float(len(self.panel)))) + 0.06
        size2 = .86
        self.gp("unset xlabel")
        self.gp("set format x ''")
        self.buildytics(panel)
        if (panel == 0):
            size = (.86 / float((len(self.panel)))) + 0.1
            self.gp("set xlabel 0,0.2")
            if (self.format):
                self.gp("set xlabel '%s' font 'Helvetica,9'" % (self.xlabel))
            else:
                self.gp("set xlabel '%s' font 'Helvetica,12'" % (self.xlabel))
            self.gp("set format x")
            if (self.format):
                self.gp("set xtics font 'Helvetica,9'")
            else:
                self.gp("set xtics")
            self.gp("set mxtics 10")
        if (self.panel[panel].type == "plot"):
            self.gp("set size 1.,%f" % (size))
            if (self.format):
                self.gp("set size 0.6,%f" % (size))
        elif (self.panel[panel].type == "splot"):
            self.gp("set size 1.2935,%f" % (size * 1.65))
        if (panel == 0):
            self.gp("set origin 0,%f" % (0.05))
        else:
            if (self.panel[panel].type == "plot"):
                self.gp("set origin 0,%f" % (0.09 + float(panel) *
                                             (size - 0.06)))
            elif (self.panel[panel].type == "splot"):
                self.gp("set origin -.147,%f" % ((0.09 + float(panel) *
                                                  (size - 0.06)) - .1315))

        self.gp("set lmargin 8")
        if (self.format):
            self.gp(
                "set label '%s' at screen 0.05,%f center rotate by 90 font 'Helvetica,9'"
                % ((self.panel[panel].ylabel),
                   (0.09 + float(panel) * (size - 0.06) + size / 2.)))
        else:
            self.gp(
                "set label '%s' at screen 0.03,%f center rotate by 90 font 'Helvetica,12'"
                % ((self.panel[panel].ylabel),
                   (0.09 + float(panel) * (size - 0.06) + size / 2.)))
        self.gp("set yrange[%e:%e]" %
                (self.panel[panel].yrange[0], self.panel[panel].yrange[1]))
        if self.panel[panel].xrange[0] != "NAN":
            self.gp("set xrange[%e:%e]" %
                    (self.panel[panel].xrange[0], self.panel[panel].xrange[1]))
        # plot marks
        for mark in self.plotmarks:
            doplotmark = 0
            for i in mark.panels:
                if (i == -1
                        or i == panel and self.panel[panel].type == "plot"):
                    doplotmark = 1
            if (doplotmark):
                doplotlabel = 0
                if (mark.label != ""):
                    for i in mark.labelpanels:
                        if (i == -1 or i == panel):
                            doplotlabel = 1
                if (mark.style == "vline"):
                    head = ""
                    if (mark.arrowhead == 0):
                        head = "nohead"
                    elif (mark.arrowhead == 1):
                        head = "head filled"
                    mark.plot[panel].set_option_colonsep(
                        "with", "vectors %s lt %i lw %i" %
                        (head, mark.linetype, mark.linewidth))
                    #self.gp("plot 'testvector.dat' with vectors")
                    if (doplotlabel):
                        if (self.format):
                            self.gp(
                                "set label '%s' at graph %f,%f tc lt %i font 'Helvetica,9' front"
                                % ((mark.label, mark.pos[0][0] /
                                    (self.xrange[1] - self.xrange[0]) + 0.01,
                                    0.8, mark.linetype)))
                        else:
                            self.gp(
                                "set label '%s' at graph %f,%f tc lt %i font 'Helvetica,12' front"
                                % ((mark.label, mark.pos[0][0] /
                                    (self.xrange[1] - self.xrange[0]) + 0.01,
                                    0.8, mark.linetype)))
                    if (first):
                        self.gp.plot(mark.plot[panel])
                        first = 0
                    else:
                        self.gp.replot(mark.plot[panel])
                if (mark.style == "box"):
                    mark.plot[panel].set_option_colonsep("using", "1:2:3")
                    mark.plot[panel].set_option_colonsep(
                        "with", "filledcurves lt %i" % (mark.linetype))
                    if (doplotlabel):
                        if (self.format):
                            self.gp(
                                "set label '%s' at graph %f,%f tc lt %i font 'Helvetica,9' center front"
                                % (mark.label,
                                   (mark.pos[0][0] +
                                    (mark.pos[0][2] - mark.pos[0][0]) / 2.) /
                                   (self.xrange[1] - self.xrange[0]), 0.8, 0))
                        else:
                            self.gp(
                                "set label '%s' at graph %f,%f tc lt %i font 'Helvetica,12' center front"
                                % (mark.label,
                                   (mark.pos[0][0] +
                                    (mark.pos[0][2] - mark.pos[0][0]) / 2.) /
                                   (self.xrange[1] - self.xrange[0]), 0.8, 0))
                    if (first):
                        self.gp.plot(mark.plot[panel])
                        first = 0
                    else:
                        self.gp.replot(mark.plot[panel])
                if (mark.style == "hline"):
                    head = ""
                    if (mark.arrowhead == 0):
                        head = "nohead"
                    elif (mark.arrowhead == 1):
                        head = "head filled"
                    mark.plot[panel].set_option_colonsep(
                        "with", "vectors %s lt %i lw %i" %
                        (head, mark.linetype, mark.linewidth))
                    #self.gp("plot 'testvector.dat' with vectors")
                    if (doplotlabel):
                        if (self.format):
                            self.gp(
                                "set label '%s' at graph %f,%f tc lt %i font 'Helvetica,9' front"
                                % ((mark.label, mark.pos[0][0] /
                                    (self.xrange[1] - self.xrange[0]) + 0.01,
                                    0.8, mark.linetype)))
                        else:
                            self.gp(
                                "set label '%s' at graph %f,%f tc lt %i font 'Helvetica,12' front"
                                % ((mark.label, mark.pos[0][0] /
                                    (self.xrange[1] - self.xrange[0]) + 0.01,
                                    0.8, mark.linetype)))
                    if (first):
                        self.gp.plot(mark.plot[panel])
                        first = 0
                    else:
                        self.gp.replot(mark.plot[panel])
                if (mark.style == "function"):
                    if (first):
                        self.gp.plot(mark.plot[panel])
                    else:
                        self.gp.replot(mark.plot[panel])

        if (first and self.panel[panel].type == "plot"):
            if len(self.panel[panel].data) == 1:
                self.gp("%s" % (self.panel[panel].key))
            self.gp.plot(self.panel[panel].data[0])
            first = 0
        elif (first and self.panel[panel].type == "splot"):
            self.gp("set pm3d map")
            self.gp.splot(self.panel[panel].data[0])
            first = 0
        else:
            self.gp.replot(self.panel[panel].data[0])
        for i in range(len(self.panel[panel].data) - 1):
            if i == len(self.panel[panel].data) - 2:
                self.gp("%s" % (self.panel[panel].key))
            self.gp.replot(self.panel[panel].data[i + 1])
        self.gp("unset pm3d")

    def buildplotmarks(self, panel):
        for mark in self.plotmarks:
            tmpmark = []
            if (mark.style == "vline"):
                tmppos = mark.pos
                tmppos[0][1] = self.panel[panel].yrange[0] * 1.01
                tmppos[0][3] = (self.panel[panel].yrange[1] -
                                self.panel[panel].yrange[0]) * 0.99
                tmpmark = Data(tmppos)
            if (mark.style == "hline"):
                tmppos = mark.pos
                tmppos[0][0] = self.xrange[0] * 1.01
                tmppos[0][2] = (self.xrange[1] - self.xrange[0]) * 0.99
                tmpmark = Data(tmppos)
            if (mark.style == "box"):
                if mark.pos[0][2] == 1e-20:
                    ymin = self.panel[panel].yrange[0]
                else:
                    ymin = mark.pos[0][2]
                if mark.pos[0][3] == 1e20:
                    ymax = self.panel[panel].yrange[1]
                else:
                    ymax = mark.pos[0][3]
                tmppos = [[mark.pos[0][0], ymin, ymax],
                          [mark.pos[0][1], ymin, ymax]]
                #tmppos=[[mark.pos[0][0],self.panel[panel].yrange[1],self.panel[panel].yrange[0]],[mark.pos[0][2],self.panel[panel].yrange[1],self.panel[panel].yrange[0]]]
                tmpmark = Data(tmppos)
            if (mark.style == "function"):
                tmpmark = mark.function
            if (tmpmark != []):
                mark.addplot(tmpmark)

    def buildytics(self, panel):
        # the tics for panel=panel are set. The cases logscale and linear scale are handled. In the first panel (panel==0) all tics are labeled set
        # in all other panels the first tic is unlabeled to avoid overlapp with the tics from the panel below.
        # logscale tics are set   --->  if yrange is smaller than 7 orders of magnitude the tics are set each order of magnitude and 8 minor tics
        #                               corresponding to 2*,3*,...,9* are set (will fail if yrange is smaller than one order of magnitude
        #                               if yrange is greater than
        # linearscale tics are set --->

        if (self.panel[panel].ytics != ""):
            if (self.format):
                self.gp("set ytics %s font 'Helvetica,9'" %
                        (self.panel[panel].ytics))
            else:
                self.gp("set ytics %s" % (self.panel[panel].ytics))
            if (self.panel[panel].logscale):
                self.gp("set logscale y")
            return

        # begin if logscale
        if (self.panel[panel].logscale):
            self.gp("unset ytics")
            self.gp("set logscale y")
            self.gp("set format y '10^{%2T}'")
            adjust = 0
            i = 1.e0
            while (not adjust):
                i = i * 10.
                tmp = self.panel[panel].yrange[0]
                tmp = tmp * i**6
                if (tmp >= self.panel[panel].yrange[1]):
                    adjust = 1

            if (self.panel[panel].minor < 0):
                if (i <= 10.):
                    minor = 8
                else:
                    minor = int(log(i, 10.) + .01)
                    minor2 = 2
            if (self.panel[panel].minor == 0):
                if (i <= 10.):
                    minor = 0
                else:
                    minor = int(log(i, 10.) + .01)
                    minor2 = 1
            if (self.panel[panel].minor > 0):
                if (i <= 10.):
                    minor = self.panel[panel].minor
                else:
                    minor = int(log(i, 10.) + .01)
                    minor2 = 2
            tic = self.panel[panel].yrange[0]
            utic = tic
            if (i <= 10.):
                j = -1
                while (utic <= self.panel[panel].yrange[1]):
                    j += 1
                    utic = tic * i**j
                    if (j == 0):
                        if (panel == 0):
                            if (self.format):
                                self.gp("set ytics (%e) font 'Helvetica,9'" %
                                        (utic))
                            else:
                                self.gp("set ytics (%e)" % (utic))
                        else:
                            if (self.format):
                                self.gp(
                                    "set ytics (' ' %e) font 'Helvetica,9'" %
                                    (float(utic)))
                            else:
                                self.gp("set ytics (' ' %e)" % (float(utic)))
                    else:
                        self.gp("set ytics add (%e)" % (utic))
                    for l in range(minor):
                        self.gp(
                            "set ytics add ('' %e 1)" %
                            (utic +
                             (utic * 9. / float(minor + 1) * float(l + 1))))
            else:
                j = -1
                while (utic <= self.panel[panel].yrange[1]):
                    j += 1
                    utic = tic * i**j
                    if (j == 0):
                        if (panel == 0):
                            if (self.format):
                                self.gp("set ytics (%e) font 'Helvetica,9'" %
                                        (utic))
                            else:
                                self.gp("set ytics (%e)" % (utic))
                        else:
                            if (self.format):
                                self.gp(
                                    "set ytics (' ' %e) font 'Helvetica,9'" %
                                    (float(utic)))
                            else:
                                self.gp("set ytics (' ' %e)" % (float(utic)))
                    else:
                        self.gp("set ytics add (%e)" % (utic))
                    for k in range(minor):
                        for l in range(minor2):
                            if (not (k == minor - 1 and l == minor2 - 1)):
                                if (l == minor2 - 1):
                                    self.gp(
                                        "set ytics add ('' %e)" %
                                        (float(utic) * float(10**k) * float(
                                            (l + 1) * 10. / float(minor2))))
                                else:
                                    self.gp(
                                        "set ytics add ('' %e 1)" %
                                        (float(utic) * float(10**k) * float(
                                            (l + 1) * 10. / float(minor2))))
        # begin if linear scale
        else:
            self.gp("unset ytics")
            self.gp("unset logscale y")
            self.gp("set format y '%6g'")
            i = .1
            while (self.panel[panel].yrange[1] - self.panel[panel].yrange[0] >
                   i):
                i = i * 10.
            minor = 9
            if (i / 4. >=
                    self.panel[panel].yrange[1] - self.panel[panel].yrange[0]):
                i = i / 4.
                minor = 4
            elif (i / 2. >=
                  self.panel[panel].yrange[1] - self.panel[panel].yrange[0]):
                i = i / 2.
                minor = 9
            if (self.panel[panel].minor == 0):
                minor = 0
            elif (self.panel[panel].minor > 0):
                minor = self.panel[panel].minor

            if (i > 10.):
                for j in range(6):
                    if (j == 0):
                        if (panel == 0):
                            if (self.format):
                                self.gp("set ytics (%i) font 'Helvetica,9'" %
                                        (int(self.panel[panel].yrange[0])))
                            else:
                                self.gp("set ytics (%i)" %
                                        (int(self.panel[panel].yrange[0])))
                        else:
                            if (self.format):
                                self.gp(
                                    "set ytics (' ' %i) font 'Helvetica,9'" %
                                    (int(self.panel[panel].yrange[0])))
                            else:
                                self.gp("set ytics (' ' %i)" %
                                        (int(self.panel[panel].yrange[0])))
                    else:
                        self.gp(
                            "set ytics add (%i)" %
                            (int(self.panel[panel].yrange[0] + i / 5. * j)))
                    print "minor = ", minor
                    for k in range(minor):
                        if ((minor + 1) % 5 == 0 and (k + 1) % 5 == 0):
                            self.gp(
                                "set ytics add (' ' %i)" %
                                (int(self.panel[panel].yrange[0] + j * i / 5. +
                                     (i / 5. / float(minor + 1) *
                                      float(k + 1)))))
                        else:
                            self.gp(
                                "set ytics add (' ' %i 1)" %
                                (int(self.panel[panel].yrange[0] + j * i / 5. +
                                     (i / 5. / float(minor + 1) *
                                      float(k + 1)))))
            else:
                for j in range(6):
                    if (j == 0):
                        if (panel == 0):
                            if (self.format):
                                self.gp("set ytics (%f) font 'Helvetica,9'" %
                                        (self.panel[panel].yrange[0]))
                            else:
                                self.gp("set ytics (%f)" %
                                        (self.panel[panel].yrange[0]))
                        else:
                            if (self.format):
                                self.gp(
                                    "set ytics (' ' %f) font 'Helvetica,9'" %
                                    (self.panel[panel].yrange[0]))
                            else:
                                self.gp("set ytics (' ' %f)" %
                                        (self.panel[panel].yrange[0]))
                    else:
                        self.gp("set ytics add (%f)" %
                                (self.panel[panel].yrange[0] + i / 5. * j))
                    for k in range(minor):
                        if ((minor + 1) % 5 == 0 and (k + 1) % 5 == 0):
                            self.gp(
                                "set ytics add (' ' %f)" %
                                (self.panel[panel].yrange[0] + j * i / 5. +
                                 (i / 5. / float(minor + 1) * float(k + 1))))
                        else:
                            self.gp(
                                "set ytics add (' ' %f 1)" %
                                (self.panel[panel].yrange[0] + j * i / 5. +
                                 (i / 5. / float(minor + 1) * float(k + 1))))
コード例 #24
0
for i in range(len(name)):
    for ion in range(len(ionnames)):
        if (ionnames[ion]==name[i]):
            plotion[i]=ion

plotelem=[]
elemname=["C","N","O","Ne","Mg","Si","S","Fe"]
for i in range(len(elemname)):
    plotelem.append(0)
for i in range(len(elemname)):
    for elem in range(len(elemnames)):
        if (elemnames[elem]==elemname[i]):
            plotelem[i]=elem


gp.plot(plotvelocity[plotion[0]])
for ion in range(len(name)-1):
    gp.replot(plotvelocity[plotion[ion+1]])

gp.replot(plotdens[plotion[0]])
for ion in range(len(name)-1):
    gp.replot(plotdens[plotion[ion+1]])
    
gp.replot(plottemp[plotion[0]])
for ion in range(len(name)-1):
    gp.replot(plottemp[plotion[ion+1]])

gp.replot(plotmaxdens[plotion[0]])
for ion in range(len(name)-1):
    gp.replot(plotmaxdens[plotion[ion+1]])
コード例 #25
0
ファイル: Plot.py プロジェクト: bionomicron/Redirector
class Plot:
        
    def __init__(self):
        self.verbose = True
        self.origin = (0,0)
        self.data2 = []
        self.data3 = []
        self.g = Gnuplot()
        self.g('set data style points')
        self.g('set key left top Left title \'Legend\' box 3')
        self.title = 'title'
        self.xlabel = 'x'
        self.ylabel = 'y'
        self.zlabel = 'z'
        
    def __call__(self,value):
        self.g(value)
        
    def setOrigin(self,x,y):
        """
        @type x: float
        @type y: float
        """
        self.origin = (x,y)
        
    def setVerbose(self,verbose):
        """
        @type verbose: binary
        """
        self.verbose = verbose
        
    def addArrayTuples(self, data, name = ''):
        """
        @param data: data to be added to 2d plot
        @type data: (float,float)[]
        """
        d = Data(data, title = name)
        self.data2.append(d)
 
         
    def add2Arrays(self,x,y):
        """
        @type x: float[]
        @type y: float[]
        """
        if len(x) != len(y):
            return 'arrays not of equal length'
        else:
            array2 = []
            for i in range(len(array)):
                value = (x[i],y[i])
                array2.append(value)
            self.addArrayTuples(array2)
            
    def addArrayTriples(self, data):
        """
        @param data: data to be added to 3d plot
        @type data: (float, float, float)[]
        """        
        self.data3.append(data)
                  
    def add3Arrays(self,x,y,z):
        """
        @type x: float[]
        @type y: float[]
        @type z: float[]
        """        
        if (len(x) == len(y) == len(z)):
            array3 = []
            for i in range(len(x)):
                value = (x[i],y[i],z[i])
                array3.append(value)
            self.addArrayTriples(array3)
            
        else:
           print 'arrays not of equal length'
            
    def setLabels(self,title='title',xlabel='x',ylabel='y',zlabel='z'):
        """
        @type title: string
        @type xlabel: string
        @type ylable: string
        @type zlable: string
        """
        self.title = title
        self.xlabel = xlabel
        self.ylabel = ylabel
        self.zlabel = zlabel
        
    def _plot2D(self):
        self.g.title(self.title)
        self.g.xlabel(self.xlabel)
        self.g.ylabel(self.ylabel)
        if len(self.data2) == 0:
            return False
        self.g.title(self.title)
        self.g.xlabel(self.xlabel)
        self.g.ylabel(self.ylabel)
        self.g.plot(self.data2[0])
        for d in self.data2[1:]:
            self.g.replot(d)
        return True
    
    def plot2DtoScreen(self):
        if not self._plot2D():
            return None
        raw_input('Please press return to continue...\n')
    
    def plot2DtoFile(self, fileName):
        """
        @type fileName: string
        """
        self.g('set term post eps')
        self.g('set output \'%s\'' % fileName)
        if not self._plot2D():
            return None
        self.g.hardcopy(fileName, enhanced=1, color=1)
        if self.verbose: print ('\n******** Saved plot to postscript file %s ********\n' % fileName)
         
    def _plot3d(self):
        if len(self.data3) == 0:
            return False
        self.g.title(self.title)
        self.g.xlabel(self.xlabel)
        self.g.ylabel(self.ylabel)
        self.g('set zlabel \"%s\"' % self.zlabel)
        self.g.plot([self.data3[0]])
        for d in self.data3[1:]:
            self.g.replot(d)
        return True
    
    def plot3DtoScreen(self):
        if not self._plot3D():
            return None  
        raw_input('Please press return to continue...\n')
        
    def plot3DtoFile(self,fileName):
        """
        @type fileName: string
        """
        self.g('set term post eps')
        self.g('set output \'%s\'' % fileName)
        if not self._plot3d():
            return None
        self.g.hardcopy(fileName, enhanced=1, color=1)
        if self.verbose: print ('\n******** Saved plot to postscript file %s ********\n' % fileName)
コード例 #26
0
ファイル: demo.py プロジェクト: marionb/CompPhysics
def plot(energies):
    from Gnuplot import Gnuplot, Data
    p = Gnuplot()
    d = Data(range(len(energies)),energies)
    p.plot(d)
    return
コード例 #27
0
#for i in range(len(he1.time)):
#    summ=0.
#    for val in he1.countspec[i]:
#        summ+=val[1]
#    he1ts.append([he1.time[i],summ])

#h1ts=[]
#for i in range(len(h1.time)):
#    summ=0.
#    for val in h1.countspec[i]:
#        if (val[0]<1300.):
#            summ+=val[1]
#    h1ts.append([h1.time[i],summ])

#sumts=[]
#for i in range(len(o1ts)):
#    sumts.append([o1ts[i][0],o1ts[i][1]])

gp = Gnuplot()
#gp("set xrange [1:365.]")
#gp.plot(o1ts,c1ts,c1ts,ne1ts,si1ts,vel)
#gp.plot(vel,sumts,sumts)
#gp.plot(o12ts,o13ts,o14ts,o15ts,o16ts,o17ts,o18ts)
#gp.hardcopy("o1p1h2007.ps",color="true")

#gp.plot(pwhist)
gp2 = Gnuplot()
gp2.plot(o11ts, o12ts, o13ts, o14ts, o15ts, o16ts, o17ts, o18ts)
#gp2("set xrange [1:365.]")
#gp2.plot(dens)
コード例 #28
0
hedata = []
for step in range(len(data)):
    for ion in range(len(data[step])):
        if (data[step][ion][0] == "He2+"):
            hedata.append([data[step][ion][7] * 1000., data[step][ion][13]])

print hepara
print hedata
heplotdata = Data(hedata)
gp = Gnuplot()
#gp("set logscale x")
gp("set logscale y")
gp("set xrange[250000.:500000.]")
gp("set yrange[0.0000000001:0.0001]")
gp("pi = 3.14159265")
gp("kb = 1.38065*10.**(-23)")
gp("u = 1.660538*10.**(-27)")
gp("m = 4.*u")
gp("T=%f" % (hepara[0][1]))
gp("x0=%f" % (hepara[0][0]))
gp("ph = %f" % (hepara[0][2]))
gp("f(x)= ph*sqrt(m/(2.*pi*kb*T))*exp(-(m*(x-x0)**2.)/(2.*kb*T))")
gp("set xlabel 'V [m/s]'")
gp("set ylabel 'density [1/cm^{3}]'")
gp("set title 'VDF He2+ (1 hour data)'")
gp.plot(
    heplotdata, "f(x) t 'Fit : Vbulk=%.2fkm/s, T=%.0fK, Dens=%.3f1/cm^{3}'" %
    (hepara[0][0] / 1000., hepara[0][1], hepara[0][2]))
gp("set term postscript color 18 lw 3 eps")
gp.hardcopy("vdf.ps", color=True, fontsize=18)
コード例 #29
0
    for time in range(len(data)):
        for ion2 in range(len(data[time])):
            if (ion_list[ion]==data[time][ion2][0]):
                tmpdensplot.append([(279.+time*5.*0.00833),data[time][ion2][7]])
    plotdens.append(Data(tmpdensplot))

for ion in range(len(ion_list)):
    plottemp[ion].set_option_colonsep("title",  "'%s'" %(ion_list[ion]))
    plotdens[ion].set_option_colonsep("title",  "'%s'" %(ion_list[ion]))
    plotvel[ion].set_option_colonsep("title",  "'%s'" %(ion_list[ion]))


gp=Gnuplot()
gp("set logscale y")
#gp("set yrange[0.00001:100]")
gp.plot(plotswepamd)
for ion in range(len(plotdens)):
    gp.replot(plotdens[ion])
gp.replot(plotswepamr)
gp("set xlabel 'DoY'")
gp("set ylabel 'Density [1/cm^{3}]'")
gp("set title ''")
gp("set term postscript color 18 lw 3 eps")
gp.hardcopy("density.ps", color=True, fontsize=18)

"""
gp.plot(plotswepamt)
for ion in range(len(plottemp)):
    gp.replot(plottemp[ion])
gp("set xlabel 'DoY'")
gp("set ylabel 'T [K]'")
コード例 #30
0
ファイル: P_KS.py プロジェクト: Angelarmandol/C-Bana
 def graficar(self, tipo='dots', serie='Valores'):
     gp = Gnuplot(persist=1)
     gp('set title "Kolmogorov-Smirnov(Aleatoriedad)"')
     plot1 = PlotItems.Data(self.lista, with_=tipo, title=serie)
     gp.plot(plot1)
     return
コード例 #31
0
ファイル: test_funcext.py プロジェクト: annefi/PUI-fun
#!/usr/bin/python
from Gnuplot import Gnuplot
from func_ext import *

gp = Gnuplot()
ef = ExternalFunction(gp, "test", ["a"], lambda x, a: a * x * x)
gp("a=3")
gp.plot("test(x)")
コード例 #32
0
for i in range(dim):
    expfitepos2[i] = expepos2(i)

gp = Gnuplot()
gp("a=-0.2")
gp("b=10.")
gp("c=7.")
#gp("set outp X11")
#gp("f(x)=a*x+b")
gp("f(x)= b*exp(a*x)+c")
gp("fit f(x) 'tmp2.dat' using 1:2 via a,b,c")

#gp("set logscale y")
#gp("set zrange[1:80]")
#gp("set palette rgbformula -3,-3,-3")
#gp("test palette")
#gp("set xrange[400:800]")
#gp("set yrange[0:50]")

#gp("set pm3d map")
#gp.splot(cmgd,data2grid)
#gp("set term postscript color")
#gp("set outp 'sigt3.ps'")
gp("set data style line")
gp("set xrange[0:60]")
#gp.plot(tposHe2,eposHe2,expfitem,expfitep,sumHe2,sumHefit)
gp.plot(eposHe2, expfitepos1, expfitepos2)
#expfitep,expfitem)
#,linfittm,tposHe2,linfittp)
コード例 #33
0
ファイル: spthspecfe.py プロジェクト: annefi/PUI-fun
if (len(hedata.time) == 1):
    gp("set title 'Fe - SWICS-2001-DoY-%.3f'" % (hedata.time[0]))
else:
    gp("set title 'Fe - SWICS-2001-DoY-%.3f-%.3f'" %
       (hedata.time[0], hedata.time[len(hedata.time) - 1]))

#first=1
#for spec in pspec:
#    if (first):
#        gp.plot(spec)
#        first=0
#    else:
#        gp.replot(spec)
#gp.replot(pbin)
#gp.plot(pspec[0],pspec[3],pspec[6],pspec[9],pspec[12],pbin)
gp.plot(pspec[fi], "f(x)")  #,"f2(x)","f3(x)","f4(x)","f5(x)")
#gp.replot(psumhist,"f(x) with l lt 3 title 'Y=M0*X^{M1}'")
#gp.replot("f(x)")
#gp.replot()
if (len(hedata.time) == 1):
    name = "fe16%.3f" % (hedata.time[0])
else:
    name = "fe16%.3f-%.3f" % (hedata.time[0],
                              hedata.time[len(hedata.time) - 1])

gp.hardcopy("%s.ps" % (name), color="true")

#for i in range(len(fedata[0].time)):
#    sumspec.append([
#    for j in range(len(fedata)):
コード例 #34
0
ファイル: plot_vdf_nen.py プロジェクト: annefi/PUI-fun
gp("vth=.03*x0")
gp("f(x)= ph*sqrt(1./(2.*pi*sqrt(vth)))*exp(-((x-x0)**2.)/(2.*vth**2))")
#gp("fit f(x) '"+allfiles[i].filename+"' using 1:2 via ph")
#gp("fit f(x) '"+allfiles[i].filename+"' using 1:2 via vth")
gp("ph2=10")
gp("x02=%f" % (ionvelarr[offs]))
gp("vth2=.03*x0")
gp("g(x)= ph2*sqrt(1./(2.*pi*sqrt(vth2)))*exp(-((x-x02)**2.)/(2.*vth2**2))")
gp("h(x)=f(x)+g(x)")
gp("fit h(x) '" + plotsumcounts.filename + "' using 1:2:3 via ph,ph2")
gp("fit h(x) '" + plotsumcounts.filename + "' using 1:2:3 via vth,vth2")
first = 1
#gp("set xrange[0.9:5.]")
#gp("set yrange[1e-12:1e-6]")
#gp("set xtics 1,2")

gp.plot(plotsumcounts, "h(x)", "f(x)", "g(x)")
#gp.plot(allfiles[i],"h(x)")
#gp.replot(allfiles[j],"g(x) title 'Maxwell-Fit 20:00-21:00'")
gp("set term postscript color 18 lw 2 eps")
gp.hardcopy("vdfs.ps", color=True, fontsize=18)
#for k in range(23):
#    gp.replot(allfiles[i+k+1])

#for i in range(len(allfiles)):
#    if (first):
#        gp.plot(allfiles[i])
#        first=0
#    else:
#        gp.replot(allfiles[i])
コード例 #35
0
ファイル: fipvsheh.py プロジェクト: annefi/PUI-fun
for i in range(len(he.time)):
    if (hsync.dens[i][1] > 0. and he.vel[i] > 600. and he.vel[i] > 600.):
        feoheh.append([he.dens[i][0] / hsync.dens[i][1], hsync.heh[i][1]])

for i in range(len(he.time)):
    if (hsync.dens[i][1] > 0. and he.vel[i] > 500. and he.vel[i] < 600.):
        feoheh2.append([he.dens[i][0] / hsync.dens[i][1], hsync.heh[i][1]])

for i in range(len(he.time)):
    if (hsync.dens[i][1] > 0. and he.vel[i] > 400. and he.vel[i] < 500.):
        feoheh3.append([he.dens[i][0] / hsync.dens[i][1], hsync.heh[i][1]])

for i in range(len(he.time)):
    if (hsync.dens[i][1] > 0. and he.vel[i] > 350. and he.vel[i] < 400.):
        feoheh4.append([he.dens[i][0] / hsync.dens[i][1], hsync.heh[i][1]])

for i in range(len(he.time)):
    if (hsync.dens[i][1] > 0. and he.vel[i] > 300. and he.vel[i] < 350.):
        feoheh5.append([he.dens[i][0] / hsync.dens[i][1], hsync.heh[i][1]])
#gp("set xrange[0:1.]")
#gp("set yrange[0:.1]")
gp("set size square")
gp("set xrange[0:0.5]")
gp("set yrange[0:0.5]")

gp.plot(feoheh, feoheh2, feoheh2, feoheh3, feoheh4, feoheh5)
"""
gp2=Gnuplot()
gp2.plot(hehmag)
"""
コード例 #36
0
    tmpion = Data(ionpos[ion])
    if (ion_names[ion] != "20Ne8+"):
        tmpion.set_option_colonsep("title", "'%s'" % (ion_names[ion]))
    else:
        tmpion.set_option_colonsep("title", "'Ne8+'")
    plotionpos.append(tmpion)

yrange = [0, 127]
xrange = [50, 300]
gp = Gnuplot()
gp("set mouse")
gp("set xlabel 'Time-of-Flight Channel'")
gp("set ylabel 'Energy Channel' ")
gp("set xrange[%i:%i]" % (xrange[0], xrange[1]))
gp("set yrange[%i:%i]" % (yrange[0], yrange[1]))

gp.plot(plotionpos[0])
for ion in range(len(ionpos) - 1):
    gp.replot(plotionpos[ion + 1])

if (our):
    gp("set title 'New improved Ion Positions'")
else:
    gp("set title 'Hefti Ion Positions'")
gp("set term postscript color 18 lw 2 eps")
#gp("set outp 'positions.ps'")
if (our):
    gp.hardcopy("positions.ps", color=True, fontsize=18)
else:
    gp.hardcopy("positionshefti.ps", color=True, fontsize=18)