コード例 #1
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...")
コード例 #2
0
    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]'")
gp("set title ''")
gp("set term postscript color 18 lw 3 eps")
gp.hardcopy("temperature.ps", color=True, fontsize=18)
"""
"""
gp("unset logscale y")
gp("set yrange[250:800]")
gp.plot(plotswepamv)
コード例 #3
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)
コード例 #4
0
gp.plot(Data(hesumdata, with_="histeps lt 1"),
        Data(herunavsum, with_="histeps lt 3"))

gp2 = Gnuplot()
gp2("set style data histeps")
#gp2("set yrange[0:2000]")
gp2("set xlabel 'Days since 01.01.2001'")
gp2("set xlabel 'Date'")
gp2("set ylabel 'Counts/Day (He^{1+} 1.5<w<2.)'")
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='Cts/Day',with_='histeps lt 1'),Data(hetsdataeff,axes='x1y2',title='Cts/Day Corr',with_='histeps lt 2'),Data(hetsdataeff2,axes='x1y2',title='Cts/Day CorrMag',with_='histeps lt 3'),Data(herunav,title='Running Mean (+-13 Days)',with_='l lt 4 lw 3'),Data(herunaveff,title='Running Mean (+-13 Days) Corr',with_='l lt 5 lw 3',axes='x1y2'),Data(herunaveff2,title='Running Mean (+-13 Days) Corr',with_='l lt 6 lw 3',axes='x1y2'),Data(semdat,title='SEM UV',with_="histeps lt 7 lw 3"))
gp2.plot(
    Data(hetsdata, title='Cts/Day', with_='histeps lt 1'),
    Data(hetsdataeff, axes='x1y2', title='Cts/Day Corr', with_='histeps lt 2'),
    Data(hetsdataeff2,
         axes='x1y2',
         title='Cts/Day CorrMag',
         with_='histeps lt 3'),
    Data(herunav, title='Running Mean (+-13 Days)', with_='l lt 4 lw 3'),
    Data(herunaveff,
         title='Running Mean (+-13 Days) Corr',
         with_='l lt 5 lw 3',
         axes='x1y2'),
    Data(herunaveff2,
         title='Running Mean (+-13 Days) Corr',
         with_='l lt 6 lw 3',
         axes='x1y2'))
#gp2.plot(Data(herunav,title='Running Mean (+-13 Days)',with_='histeps lt 1'),Data(herunaveff,title='Running Mean (+-13 Days) Eff',with_='histeps lt 3',axes='x1y2'))
gp2.hardcopy("He1+_all_corr_mag.ps", color=True)
コード例 #5
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)
コード例 #6
0
ファイル: meanallions.py プロジェクト: annefi/PUI-fun
mp.panel[0].adddata(phistarr2[36])
mp.panel[0].adddata(phistarr2[26])
mp.panel[0].adddata(phistarr2[9])
mp.panel[0].adddata(pmeandv2[-1])
mp.panel[0].adddata(pmeandv2[36])
mp.panel[0].adddata(pmeandv2[26])
mp.panel[0].adddata(pmeandv2[9])
mp.plot()
gp2 = Gnuplot()
gp2("set xlabel '|v_{ip}|/C_{A}'")
gp2("set ylabel '# occurences'")
gp2("set xrange[0:2]")
gp2("set mxtics 10")
gp2("set mytics 4")
gp2.plot(phistarr2[-1], phistarr2[36], phistarr2[26], phistarr2[9])
gp2.hardcopy("paperdvhist.ps", color="True")
"""
gp("set boxwidth 1.")
gp("%s"%(xtics))
gp("set xrange[0:%i]"%(numpion[-1][-1][0]+1))
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]),10.))

gp.plot(pnumpion[0])
for i in range(len(pnumpion)-1):
    gp.replot(pnumpion[i+1])
gp3=Gnuplot()
gp3("set xrange[0:10]") 
gp3("set yrange[0.:1.]") 
コード例 #7
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)
コード例 #8
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])
コード例 #9
0
ファイル: vi_vs_vp.py プロジェクト: annefi/PUI-fun
yrange = [0., 2.]
a = [[xrange[0], yrange[0], 1.], [xrange[1], yrange[1], 1.]]
pa = Data(a)
pa.set_option_colonsep("with", "l lt -1")
gp = Gnuplot()
gp("set pm3d at bs map explicit corners2color c1")
#gp("set pm3d map")
gp("set size square")
gp("set xrange[%f:%f]" % (xrange[0], xrange[1]))
gp("set yrange[%f:%f]" % (yrange[0], yrange[1]))
#gp("set logscale x")
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"
   )
gp("set logscale cb")
gp.splot(pvivsvparr, pdvzeros)  #,pa)
gp.hardcopy("v%s_vs_vp.ps" % (ionlist[0]), color="true", fontsize=20)

pmeandv = []
for ion in meandvvsvparr:
    pmeandv.append(Data(ion))
    pmeandv[-1].set_option_colonsep("using", "1:2:3")
    pmeandv[-1].set_option_colonsep("with", "yerrorbars")

gp2 = Gnuplot()
gp2.plot(pmeandv[0])
for i in range(1, len(pmeandv)):
    gp2.replot(pmeandv[i])

pmeanhevse = Data(meanhevse)
pmeanhevse.set_option_colonsep("using", "1:2:3")
pmeanhevse.set_option_colonsep("with", "yerrorbars")
コード例 #10
0
ファイル: testdutyfit.py プロジェクト: annefi/PUI-fun
#para[3]=47.11

df = dutyfit(datapath, swepampath, datapath2, magpath, effpath, ionname,
             timeframe, para)
df.load()
df.hist_data()
df.fit(ia)

from Gnuplot import Gnuplot
gp = Gnuplot()
gp("set autoscale")
gp.plot(df.sumspec, df.sumspecprotons, df.sumspecprotons)
if (1):
    gp("set xrange[0:1.6]")
    gp("set yrange[0:0.8]")
    gp("set format y '%.2f'")
    gp("set ylabel '{/Symbol D}v/v_{Alf}'")
    gp("set xlabel '{/Symbol b} [rad]'")
    gp.plot(df.pdvhist, df.pthdv[0])
    gp.hardcopy("dvvirtobs_%s.ps" % (df.iondata.name),
                color="true",
                fontsize=20)
    gp("set autoscale y")
    gp("set format y '%.1f'")
    gp("set ylabel 'vth [km^{1}s^{-1}]'")
    gp("set xlabel '{/Symbol b} [rad]'")
    gp.plot(df.pvthhist, df.pthvth[0])
    gp.hardcopy("vthvirtobs_%s.ps" % (df.iondata.name),
                color="true",
                fontsize=20)
コード例 #11
0
ファイル: tail_bulk.py プロジェクト: annefi/PUI-fun
            plotspthmq.append(tmpplotspthmq)
        del iondata

if (plotspth):
    #plotspthmq.set_option_colonsep("with", "lines")
    gp=Gnuplot()
    gp("set logscale y")
    #gp("set yrange[0.:0.015]")
    gp("set xrange[1.5:7.5]")
    gp("set xlabel 'm/q'")
    gp("set ylabel 'tail/bulk'")
    gp.plot(plotspthmq[0])
    for ion in range(len(plotspthmq)-1):
        gp.replot(plotspthmq[ion+1])
    gp("set term postscript color 18 lw 2 eps")
    gp.hardcopy("mq_tailbulk_quiet_errors_notitles.ps",color=True, fontsize=18)


if (doplotdenstime):
    dens=[]
    temp=[]
    vel=[]
    spth=[]
    spth2=[]
    for i in range(len(iondata.dens)):
        if (iondata.dens[i][0]!=0.):
            dens.append([iondata.time[i],iondata.dens[i][0]])
            temp.append([iondata.time[i],iondata.temp[i][0]])
            vel.append([iondata.time[i],iondata.vel[i]])
            spth.append([iondata.time[i],iondata.suprath[i][0]])
            spth2.append([iondata.time[i],iondata.suprath[i][0]*iondata.dens[i][0]])
コード例 #12
0
gp2=Gnuplot()
gp2("set log y")
gp2("set format y '10^{%T}'")

gp2("set xrange[1:60]")
gp2("set xlabel 'DoY 2007")
gp2("set ylabel 'relative flux error'")
#gp2("set ylabel 'Solar Wind Speed [km^{1}s^{-1}]")
plotratio.set_option_colonsep("with", "lines")
plotratio.set_option_colonsep("title", "'O^{7+}/O^{6+}'")
plotmu1.set_option_colonsep("with", "lines")
plotmu1.set_option_colonsep("title", "'O^{7+}'")
plotmu2.set_option_colonsep("with", "lines")
plotmu2.set_option_colonsep("title", "'O^{6+}'")
gp2.plot(plotratio,plotmu1,plotmu2)
#gp2("set yrange[1.e-7:1.]")
#first=1
#for i in range(len(plotspth)):
#    plotspth[i].set_option_colonsep("title", "'%s'"%(ion_name[i]))
#    if (first==1):
#        plotspth[i].set_option_colonsep("with", "lines")
#        gp2.plot(plotspth[i])
#        first=0
#    else:
#        gp2.replot(plotspth[i])
                      
gp2("set term postscript color 18 lw 2 eps")
gp2.hardcopy("o7o6ratio.ps",color=True, fontsize=18)
                   
コード例 #13
0
ファイル: plot_tail_bulk2.py プロジェクト: annefi/PUI-fun
#first=1
#i=1
#gp.plot(dayfiles[i])
#for k in range(4):
#    gp.replot(dayfiles[i+k+1])

gp2 = Gnuplot()
gp2("set log y")
gp2("set format y '10^{%T}'")

#gp2("set xrange[%i:%i]"%(startdoy,stopdoy))
gp2("set xrange[1:5.5]")
gp2("set xlabel 'DoY 2007")
gp2("set ylabel 'Density [cm^{-3}]")
#gp2("set ylabel 'Solar Wind Speed [km^{1}s^{-1}]")
#gp2.plot(plottbr[0],plotvel[0],plotA,plotB,plotC,plotD)
gp2.plot(tbr)
#gp2("set yrange[1.e-7:1.]")
#first=1
#for i in range(len(plotspth)):
#    plotspth[i].set_option_colonsep("title", "'%s'"%(ion_name[i]))
#    if (first==1):
#        plotspth[i].set_option_colonsep("with", "lines")
#        gp2.plot(plotspth[i])
#        first=0
#    else:
#        gp2.replot(plotspth[i])

gp2("set term postscript color 18 lw 2 eps")
gp2.hardcopy("tailbulk14_15.ps", color=True, fontsize=18)
コード例 #14
0
ファイル: comparesig.py プロジェクト: annefi/PUI-fun
    ion_sigx_plot.append(ion_sigx_plot_tmp)

ion_sigy_plot=[]
for ion in range(len(ion_list)):
    ion_sigy_plot_tmp=Data(ion_sigy[ion])
    ion_sigy_plot_tmp.set_option_colonsep("using", "1:2")
    ion_sigy_plot_tmp.set_option_colonsep("title",  "'%ssigy'" %(ion_list[ion]))
    ion_sigy_plot.append(ion_sigy_plot_tmp)

gp=Gnuplot()
#gp("set xrange[100:260]")
gp("set yrange[0:5]")
gp("set title 'ion_sigp'")

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

#gp.plot(ion_sigxp_plot[0],ion_sigxm_plot[0],ion_sigyp_plot[0],ion_sigym_plot[0])
#for ion in range(len(ion_list)-1):
#    gp.replot(ion_sigxp_plot[ion+1],ion_sigxm_plot[ion+1],ion_sigyp_plot[ion+1],ion_sigym_plot[ion+1])
    

gp.hardcopy("ion_sig.ps",color=True,fontsize=18)






コード例 #15
0
gp("set pm3d map explicit")
#gp("set palette rgbformula -32,-5,-7")
gp("set palette model RGB functions gray<0.0000001 ? 1 : gray , gray<0.0000001 ? 1 : 0.5-gray , gray <0.0000001 ? 1 : (1-gray)*0.7"
   )

#gp("set palette model RGB functions gray<0.0001 ? 1 : 0.5-gray , gray<0.0001 ? 1 : gray , gray <0.0001 ? 1 : 1-gray")
gp("set cblabel 'Counts' -10")
gp("set log cb")
gp("set xlabel 'Time-of-Flight Channel'")
gp("set ylabel 'Energy Channel' ")
#gp("show cblabel")
gp("set xrange[%i:%i]" % (xrange[0], xrange[1]))
gp("set yrange[%i:%i]" % (yrange[0], yrange[1]))

gp("set cbrange[1e2:1e6]")
gp("set format cb '10^%T'")
gp("set grid front noxticks noyticks")
gp.splot(gpdata, gppoints)

gp("set title 'step%i'" % (step))
gp("set title 'Ion-Positions'")
gp("set term postscript color 18 lw 2 eps")
if (step > 9):
    gp("set outp 'step%i.ps'" % (step))
if (step < 10):
    gp("set outp 'step0%i.ps'" % (step))
#gp("set outp 'etslicefastswnew.ps'")
gp.hardcopy("longtermpos.ps", color=True, fontsize=18)
#gp("splot 'tmpetmat.dat' with pm3d t'', 'tmppointsmat.dat' w p lt 5 pt 2 ps 2.5 t '','tmppointsmat3.dat' w p lt 5 pt 2 ps 2.5 t ''")
#gp("show palette")
コード例 #16
0
ファイル: vi_vs_para.py プロジェクト: annefi/PUI-fun
a=[[xrange[0],yrange[0],1.],[xrange[1],yrange[1],1.]]
pa=Data(a)
pa.set_option_colonsep("with","l lt -1")
gp=Gnuplot()
gp("set pm3d at bs map explicit corners2color c1")
#gp("set pm3d map")
gp("set size square")
gp("set xrange[%f:%f]"%(xrange[0],xrange[1])) 
gp("set yrange[%f:%f]"%(yrange[0],yrange[1]))
gp("set xlabel 'vsw")
gp("set title '%i'"%(year))
#gp("set logscale x")
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")
#gp("set logscale cb")
gp.splot(pvivsvparr)#,pa)
gp.hardcopy("dv%s64s_vs_vp%s.ps"%(ionlist[0][0],year),color="true",fontsize=20)

gp4=Gnuplot()
gp4("set pm3d at bs map explicit corners2color c1")
#gp("set pm3d map")
gp4("set size square")
gp4("set xrange[%f:%f]"%(xrange2[0],xrange2[1])) 
gp4("set yrange[%f:%f]"%(yrange[0],yrange[1]))
gp4("set xlabel 'pbeta")
#gp("set logscale x")
gp4("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")
#gp4("set logscale cb")
gp4("set logscale x")
gp4.splot(pvivsvparr2)#,pa)
gp4.hardcopy("dv%s64s_vs_pbeta%i.ps"%(ionlist[0][0],year),color="true",fontsize=20)
コード例 #17
0
ファイル: alfvenwaves.py プロジェクト: annefi/PUI-fun
        plotalphan=Data(alphan)
        plotalphan.set_option_colonsep("with", "lines")
        plotbeta=Data(beta)
        plotbeta.set_option_colonsep("with", "lines")
        plotpsdbetages=Data(psdbetages)
        plotpsdbetages.set_option_colonsep("with", "lines")

    if (dofft):
        gp=Gnuplot()
        gp("set title '%f , gap = %i'"%(doy,gap))
        gp("set logscale x")
        gp("set logscale y")
        gp("set yrange[1e-5:10.]")
        gp("set xrange[1e-6:1.]")
        gp.plot(plotpsdngessum)
        gp.hardcopy("%f_%is_%i_%i.ps"%(doy,int(timeres),N,binning), color=True, fontsize=18)
        gp2=Gnuplot()
        gp2("set title '%f , gap = %i'"%(doy,gap))
        gp2("set logscale x")
        gp2("set logscale y")
        gp2("set yrange[1e-5:1.]")
        gp2("set xrange[1e-5:1.]")
#        gp2("set autoscale")
        gp2.plot(plotpsdbetages)
        gp2.hardcopy("beta_%f_%is_%i_%i.ps"%(doy,int(timeres),N,binning), color=True, fontsize=18)
        del gp
        del gp2
    if (doautocorr):
        gp=Gnuplot()
        gp("set title '%f , gap = %i'"%(doy,gap))
#        gp("set logscale x")
コード例 #18
0
ファイル: etPolar2d.py プロジェクト: annefi/PUI-fun
class polar2D:
    def __init__(self, angular_bins, *datasets):
        """
		Method: __init__(data,angular_bins)
		The polar2D class is used to create a plot using Gnuplot.py in polar coordinates. 
		Typical application would be to show the angular dependence of Count Rates.

		INPUT: datasets - a list of CR, that have the same dimension as angular_bins
		       angular_bins - should be a list or numpy array of the linear-spaced angular bins used in 'data'

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

		AN EXAMPLE HOW TO USE THIS CLASS IS SHOWN AT THE END OF THIS FILE!
		"""
        self.data = []
        for d in datasets:
            self.data.append(array(d))
        self.len_data = len(self.data)
        self.angular_bins = array(angular_bins)
        if len(self.data[0]) != len(self.angular_bins):
            print "--- Dimension of DATA %s differs from angular bins %s! ---" % (
                self.data[0].shape, self.angular_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 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")
        self.plotmode = 'S'
        self.set_data_label(["" for i in range(self.len_data)])

    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 __create_gpdata__(self):
        """
		This routine create a Gnuplot data object from the given data, angular bins and radial bins
		"""
        """
		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 data_i, data in enumerate(self.data):
            data -= min(data)
            if self.log: data = log10(data + 0.01)
            if self.plotmode == 'T':
                data_processed = data / max(data) + 0.5 + data_i * 0.
            elif self.plotmode == 'S':
                data_processed = data / max(data) + 0.5 + data_i * 1.
            datax, datay = self.__polar_to_cart__(data_processed,
                                                  self.angular_bins)
            dataobj = Data(datax, datay, with_="lines lw 2")
            self.gparray.append(dataobj)

    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 - is 0 title is put on top of 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_data_label(self, data_labels):
        """
		Explicitly gives data labels to each data set
		INPUT: 
		       datalabels - corresponding to number of datasets (e.g. ["ZERO","TEN","TWELVE","THIRTEEN","TWENTYFIVE"])
		"""
        if self.plotmode == "S":
            datalabel = ""
            for dindex in range(self.len_data):
                tic = dindex + 0.5
                datalabel += "'%s' %s," % (data_labels[dindex], tic)
            self.gp("set xtics out (%s) rotate by -90" % (datalabel[0:-1]))
            self.gp("set ytics out (%s)" % (datalabel[0:-1]))
        elif self.plotmode == "T":
            for dindex in range(self.len_data):
                self.gp(
                    "set label '%s' at graph %s, graph %s textcolor lt %s" %
                    (data_labels[dindex], 0.03, 0.97 - 0.035 * dindex,
                     dindex + 1))

    def set_grid(self, trig, angles=45, color='black', solid=1):
        """
		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
		"""
        if trig == 1:
            self.gp("set grid xtics nomxtics polar %s" % (angles))
            self.gp("set grid xtics front lw 0.5")
            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_raxis(self, color="black"):
        """
		Here you can turn on an additional axis with tics on it 
		This is only possible in plotstyle T !!
		INPUT: color - color of the raxis
		"""
        if self.plotmode == "T":
            xtics = ""
            for major_t in [0, 0.2, 0.4, 0.6, 0.8, 1.]:
                xtics += "'%s' %s," % (major_t, major_t + 0.5)
                self.gp("set arrow from first %s, first -0.04 to \
					 first %s, first 0.04 \
					 nohead lc rgb '%s' lw 0.3" % (major_t + 0.5, major_t + 0.5, color))
                self.gp("set arrow from first %s, first -0.04 to \
					 first %s, first 0.04 \
					 nohead lc rgb '%s' lw 0.3" % (-major_t - 0.5, -major_t - 0.5, color))
                self.gp("set arrow from first -0.04, first %s to \
					 first 0.04, first %s \
					 nohead lc rgb '%s' lw 0.3" % (major_t + 0.5, major_t + 0.5, color))
                self.gp("set arrow from first -0.04, first %s to \
					 first 0.04, first %s \
					 nohead lc rgb '%s' lw 0.3" % (-major_t - 0.5, -major_t - 0.5, color))
            for minor_t in linspace(0, 1, 49):
                self.gp("set arrow from first %s, first -0.02 to \
					 first %s, first 0.02 \
					 nohead lc rgb '%s' lw 0.1" % (minor_t + 0.5, minor_t + 0.5, color))
                self.gp("set arrow from first %s, first -0.02 to \
					 first %s, first 0.02 \
					 nohead lc rgb '%s' lw 0.1" % (-minor_t - 0.5, -minor_t - 0.5, color))
                self.gp("set arrow from first -0.02, first %s to \
					 first 0.02, first %s \
					 nohead lc rgb '%s' lw 0.1" % (minor_t + 0.5, minor_t + 0.5, color))
                self.gp("set arrow from first -0.02, first %s to \
					 first 0.02, first %s \
					 nohead lc rgb '%s' lw 0.1" % (-minor_t - 0.5, -minor_t - 0.5, color))
            self.gp("set xtics out (%s)" % (xtics[:-1]))
            self.gp("set ytics out (%s)" % (xtics[:-1]))
        else:
            print "Wrong plotmode %s for setting an r - axis! Please chose another plotmode" % (
                self.plotmode)

    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 set_plotstyle(self, plotmode):
        """
		This routines sets the plotstyle. 
		One can choose between plotmode 'S', which means plotting each data set separatly onto a given y=0 line
		or plotmode 'T', which plots all datasets on one y=0 line
		"""
        if plotmode not in ["S", "T"]:
            self.plotmode = 'S'
            print "Invalid Plotmode - Fall back to plotmode 'S'"
        else:
            self.plotmode = plotmode

    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 the 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__()
        if self.plotmode == 'T':
            self.gp("set xrange[-1.9:1.9]")
            self.gp("set yrange[-1.9:1.9]")
            #self.gp("set tic scale 0")
        elif self.plotmode == 'S':
            self.gp("set xrange[-%s:%s]" %
                    (self.len_data + 1.5, self.len_data + 1.5))
            self.gp("set yrange[-%s:%s]" %
                    (self.len_data + 1.5, self.len_data + 1.5))

        self.gp.plot(*self.gparray)

    def kill_plot(self):
        """
		Routines that kills the Gnuplot window
		"""
        del self.gp
コード例 #19
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'")
コード例 #20
0
   % (200, -250))
gp("set label '{/Times-Roman=20 v}_{p}' at %f,%f center" %
   (vpswlabel[0], vpswlabel[1]))
#gp("set label '|{/HelveticaBold= v}_{{/Symbol a}}|' at %f,%f center" % (vaswlabel[0],vaswlabel[1]))
gp("set label '{/Times-Roman=20 v}_{i}' at %f,%f center" %
   (vaswlabel[0], vaswlabel[1]))
#gp("set label '|{/HelveticaBold= v}_{{/Symbol a}p}|' at %f,%f center" % (vdreclabel[0],vdreclabel[1]))
gp("set label '|{/Times-RomanBold=20 v}_{ip}|' at %f,%f center" %
   (vdreclabel[0], vdreclabel[1]))
#gp("set label 'e_{p}|{/HelveticaBold= v}_{{/Symbol a}}|' at %f,%f center" % (vdrotlabel[0],vdrotlabel[1]))

gp("set label '(v@_{y}^{2}+v@_{z}^{2})^{1/2} [km^{1}s^{-1}]'at screen 0.17, screen .41 center rotate by 90"
   )
gp("set label ''at screen 0.17, screen .84 center rotate by 90")
#gp("set label center'{/HelveticaBold=9  %s}' at screen 0.3, screen 1.02"%(self.title))
gp("set size square")
gp.plot(pvdrot, vdarc2, pmajortics, pminortics, pvline1, pvline2, pvline3,
        pshxaxis, pvdrec, pvasw, pvpsw, pvdsw, betaarc, alphaarc, gammaarc,
        alphaarc2, scan[0], scan[1], pxaxis, pvp, pva, pvd)
#gp("set term postscript enhanced color lw 2 eps")
#gp("set output 'projectionscheme.eps'")
#gp("set size ratio 1")
#gp.plot(pvdrot,vdarc2,pmajortics,pminortics,pvline1,pvline2,pvline3,pshxaxis,pvdrec,pvasw,pvpsw,pvdsw,betaarc,alphaarc,gammaarc,alphaarc2,scan[0],scan[1],pxaxis,pvp,pva,pvd)

#gp("set size square")
gp.hardcopy("projectionscheme.eps",
            terminal="postscript",
            eps=True,
            enhanced=True,
            color=True)
コード例 #21
0
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([
#    for j in range(len(fedata)):
コード例 #22
0
onedaym = histogram(cleanmeanch, 85, 1, 20, 4)
onedaym2 = sig_histogram(cleanmeanch, onedaym, 4)
onedaym3 = []
for i in range(len(onedaym)):
    onedaym3.append([onedaym[i][0], onedaym[i][1], onedaym2[i][1]])
#for i in range(16):
#    nrsum=0
#    onedaymean=0.
#    for j in range(24):
#        if (fedata.meanch[i*24+j][1]>0. and fedata.meanch[i*24+j][1]<20.):
#            nrsum+=1
#            onedaymean+=fedata.meanch[i*24+j][1]
#    if (nrsum>0):
#        onedaym.append([90.5+float(i),onedaymean/nrsum])

ponedaym = Data(onedaym3)
ponedaym.set_option_colonsep("using", "1:2:3")
ponedaym.set_option_colonsep("with", "yerrorbars lw 3 pt 2")

gp = Gnuplot()
gp("set grid xtics mxtics noytics back lt -1 lt 0")
gp("set yrange[0:20]")
gp("set xrange[85:105]")
gp("set mxtics 5")
gp("set mytics 5")
gp("set title 'ACE/SWICS Maximum Likelihood PHA Analyse'")
gp("set ylabel 'Qm(Fe)'")
gp("set xlabel 'Doy 2001'")
gp.plot(ponedaym)
gp.hardcopy("meanchfe.ps", color="true")
コード例 #23
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])
コード例 #24
0
ファイル: plot_abundances.py プロジェクト: annefi/PUI-fun
gp("fit f5(x) '"+gpqges[4].filename+"' using 1:2 via a5,b5" )
gp("a6=2.")
gp("b6=0.001")
gp("f6(x)=a6*exp(-b6*x)")
gp("fit f6(x) '"+gpqges[5].filename+"' using 1:2 via a6,b6" )
gp("a7=2.")
gp("b7=0.001")
gp("f7(x)=a7*exp(-b7*x)")
gp("fit f7(x) '"+gpqges[6].filename+"' using 1:2 via a7,b7" )
gp("a8=2.")
gp("b8=0.001")
gp("f8(x)=a8*exp(-b8*x)")
gp("fit f8(x) '"+gpqges[7].filename+"' using 1:2 via a8,b8" )
gp("set autoscale")
gp("set xrange[350:710]")

gp.replot("f1(x) t '' lt 1","f2(x) t '' lt 2","f3(x) t '' lt 3","f4(x) t '' lt 4","f5(x) t '' lt 5","f6(x) t '' lt 6","f7(x) t'' lt 7","f8(x) t '' lt 8")
gp("set term postscript color 18 lw 2")
gp.hardcopy("chargestates.ps", color=True, fontsize=18)

#gp.plot(gpqfe)
#gp("f(x)=3.004*exp(-0.00578*x)")
#gp("a=2.")
#gp("b=0.001")
#gp("f(x)=a*exp(-b*x)")
#gp("fit f(x) '"+gpqfe.filename+"' using 1:2 via a,b" )
#gp.replot("f(x)")
#gp.plot(tmpgpsumme)
#Ion             velocity        Flux                    Temp                    Dens
#He2+            559.15          5.8708e+07              1.1575e+06              1.0472e+00
コード例 #25
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)
コード例 #26
0
ファイル: plot_dcr.py プロジェクト: annefi/PUI-fun
gp3 = Gnuplot()
gp3.plot(Data(wbins, whist, with_="histeps"),
         Data(wbins2, whist2, with_="histeps lt 3"))
gp2 = Gnuplot()
gp2("set style data lines")
gp2.plot(he1sum)

gp = Gnuplot()
#gp("set term postscript enhanced color 18 lw 2 eps")
#gp("set output 'fouryears.ps'")
#gp("set multiplot")
#gp.splot(pionpos[0],pionpos[1],pionpos[2],pionpos[3])
gp("set pm3d map at b corners2color c1")
gp("set log cb")
gp("set cbrange[.1:]")
#gp("set cbrange[1e2:]")
#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")
gp("set xrange[0:57]")
gp("set yrange[0:500]")
#gp.splot(GridData(dcr),pionpos[0],pionpos[1],pionpos[2],pionpos[3],pionpos[4])
gp.splot(GridData(dcr), *pionpos)
gp.hardcopy("10years.ps", color="True")
#gp("set surface")
#gp("set clabel '%0.0f'")
#gp("unset contour")
#gp("unset pm3d")
#gp("unset log z")
#gp("set zrange[0.5:1.5]")
#gp.splot(pionpos[0],pionpos[1],pionpos[2],pionpos[3])
コード例 #27
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)
コード例 #28
0
pdv = Data(dv)
pdv.set_option_colonsep("with", "l lt 1")

gp = Gnuplot()
gp("f(x)=pi/2.")
gp("f2(x)=0.")
gp("f3(x)=-pi/2.")
gp("f4(x)=pi")
gp("f5(x)=-pi")
gp("f6(x)=6.")
#gp("set xrange[73.25:76]")
#gp.plot(pc,pd,pdv,pdbb,pprdbb,"f(x) with l lt 0 title ''","f2(x) with l lt 0 title ''","f3(x) with l lt 0 title ''","f4(x) with l lt 0 title ''","f5(x) with l lt 0 title ''")#,"f6(x) with l lt -1 title ''")
gp.plot(pc, pd, pdv, "f(x) with l lt 0 title ''", "f2(x) with l lt 0 title ''",
        "f3(x) with l lt 0 title ''", "f4(x) with l lt 0 title ''",
        "f5(x) with l lt 0 title ''")  #,"f6(x) with l lt -1 title ''")
gp.hardcopy("mag.ps", color="true", fontsize=20)

gp2("set autoscale")
gp2("set ylabel '{/Symbol D}v/v_{Alf}'")
gp2("set xlabel '{/Symbol b} [rad]'")
#gp2("set grid back")
gp2("set format y '%.2f'")
gp2("set yrange[-.8:.8]")
gp2("set y2range[0.:1000.]")
gp2("set y2tics auto")
gp2("set autoscale y2")
gp2("set xrange[0:3.2]")
gp2("set xtics ('0' 0,'pi/4' %f,'pi/2' %f,'pi3/4' %f,'pi' %f)" %
    (pi / 4., pi / 2., pi * 3. / 4., pi))
#gp2("c(x)=0.5*cos(x)")
#gp2.plot(pdvhist2[len(pdvhist2)-1],pdvhisttheo,pdvhist[len(pdvhist)-1],pdvhisttheovs)
コード例 #29
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
コード例 #30
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()
コード例 #31
0
    gp.replot(plotmaxdens[plotion[ion+1]])

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

gp.replot(plotratio)
gp.replot(plotcratio)
plotmeancharge=[]
print "plotelem = ",plotelem
for elem in plotelem:
    print "elem = ",elem
    tmpplotmeancharge=Data(meancharge[elem])
    tmpplotmeancharge.set_option_colonsep("title",  "'meancharge %s'" %(elemnames[elem]))
    tmpplotmeancharge.set_option_colonsep("with",  "points")
    plotmeancharge.append(tmpplotmeancharge)
gp("unset logscale y")
gp.plot(plotmeancharge[0])
for elem in range(len(plotelem)-1):
    gp.replot(plotmeancharge[elem+1])
#Alle Ionen in Range plotten

"""
for ion in range(8):
    gp.replot(plotdata[ion+1])
    gp.replot(plotvelocity[ion+1])
    gp.replot(plottemp[ion+1])
gp.hardcopy("test.ps",color="true")
"""
gp.hardcopy("meancharge.ps",color="true")
コード例 #32
0
ファイル: plot_vdf_dist.py プロジェクト: annefi/PUI-fun
gp("unset logscale y")

gp("set autoscale")
#gp("set yrange[1:18000000]")
gpvel=[]
for ion in range(numberions):
    gptmpvel=Data(fitvel[ion])
    gptmpvel.set_option_colonsep("title",  "'%s'"%(ion_names[ion]))
    gpvel.append(gptmpvel)

gp("set title 'velocity'")
gp.plot(gpvel[2])
for ion in range(numberions-3):
    if (plot_ion[ion+3]):
        gp.replot(gpvel[ion+3])
gp.hardcopy("velocity.ps", color=True, fontsize=18)

gptemp=[]
for ion in range(numberions):
    gptmptemp=Data(fittemp[ion])
    gptmptemp.set_option_colonsep("title",  "'%s'"%(ion_names[ion]))
    gptemp.append(gptmptemp)


#gp("set title 'temperature'")
#gp.plot(gptemp[0])
#for ion in range(numberions-1):
#    if (plot_ion[ion]):
#        gp.replot(gptemp[ion+1])
#gp.hardcopy("temperature.ps", color=True, fontsize=18)