Python pylab.arange() Examples
The following are 8
code examples of pylab.arange().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pylab
, or try the search function
.
Example #1
Source File: PiScope.py From PiScope with MIT License | 6 votes |
def draw(self): self.read() #read current values #self.read_test() #testing reading print "Plotting..." if len(self.channels) == 1: NumberSamples = min(len(self.values), self.scale1.get()) CurrentXAxis = pylab.arange(len(self.values) - NumberSamples, len(self.values), 1) self.line1[0].set_data(CurrentXAxis, pylab.array(self.values[-NumberSamples:])) self.ax.axis([CurrentXAxis.min(), CurrentXAxis.max(), 0, 3.5]) elif len(self.channels) == 2: NumberSamplesx = min(len(self.valuesx), self.scale1.get()) NumberSamplesy = min(len(self.valuesy), self.scale1.get()) self.line1[0].set_data(pylab.array(self.valuesx[-NumberSamplesx:]), pylab.array(self.valuesy[-NumberSamplesy:])) self.drawing.draw() self.root.after(25, self.draw) return
Example #2
Source File: preprocess.py From jama16-retina-replication with MIT License | 6 votes |
def _increase_contrast(image): """ Helper function for increasing contrast of image. """ # Create a local copy of the image. copy = image.copy() maxIntensity = 255.0 x = arange(maxIntensity) # Parameters for manipulating image data. phi = 1.3 theta = 1.5 y = (maxIntensity/phi)*(x/(maxIntensity/theta))**0.5 # Decrease intensity such that dark pixels become much darker, # and bright pixels become slightly dark. copy = (maxIntensity/phi)*(copy/(maxIntensity/theta))**2 copy = array(copy, dtype=uint8) return copy
Example #3
Source File: criteria.py From spectrum with BSD 3-Clause "New" or "Revised" License | 6 votes |
def CAT(N, rho, k): r"""Criterion Autoregressive Transfer Function : .. math:: CAT(k) = \frac{1}{N} \sum_{i=1}^k \frac{1}{\rho_i} - \frac{\rho_i}{\rho_k} .. todo:: validation """ from numpy import zeros, arange cat = zeros(len(rho)) for p in arange(1, len(rho)+1): rho_p = float(N)/(N-p)*rho[p-1] s = 0 for j in range(1, p+1): rho_j = float(N)/(N-j)*rho[j-1] s = s + 1./rho_j #print(s, s/float(N), 1./rho_p) cat[p-1] = s/float(N) - 1./rho_p return cat
Example #4
Source File: lineshape_analysis.py From quantum-python-lectures with MIT License | 6 votes |
def compare_lineshapes(wL,wG): """ create a plot comparing voigt with lorentzian and gaussian wL and wG are widths of Lorentzian and Gaussian, respectively """ # generate some lineshape to analyse later x = arange(-20,20,0.01) yL,yG,yV = generate_lineshapes(x,0,wL,0,wG) y_noise = random.randn(len(x))*0.1 yV += y_noise fig = figure(2) clf() ax = fig.add_subplot(111) ax.plot(x,yL/yL.max(),'b',lw=2,label='Lorentzian') ax.plot(x,yG/yG.max(),'r',lw=2,label='Gaussian') ax.plot(x,yV/yV.max(),'g--',lw=2,label='Voigt') # Add legend: loc=0 means find best position ax.legend(loc=0) ax.set_xlabel('Detuning (arb.)') ax.set_ylabel('Intensity (arb.)')
Example #5
Source File: PiScope.py From PiScope with MIT License | 5 votes |
def setup(self, channels): print "Setting up the channels..." self.channels = channels # Setup oscilloscope window self.root = Tkinter.Tk() self.root.wm_title("PiScope") if len(self.channels) == 1: # Create x and y axis xAchse = pylab.arange(0, 4000, 1) yAchse = pylab.array([0]*4000) # Create the plot fig = pylab.figure(1) self.ax = fig.add_subplot(111) self.ax.set_title("Oscilloscope") self.ax.set_xlabel("Time") self.ax.set_ylabel("Amplitude") self.ax.axis([0, 4000, 0, 3.5]) elif len(self.channels) == 2: # Create x and y axis xAchse = pylab.array([0]*4000) yAchse = pylab.array([0]*4000) # Create the plot fig = pylab.figure(1) self.ax = fig.add_subplot(111) self.ax.set_title("X-Y Plotter") self.ax.set_xlabel("Channel " + str(self.channels[0])) self.ax.set_ylabel("Channel " + str(self.channels[1])) self.ax.axis([0, 3.5, 0, 3.5]) self.ax.grid(True) self.line1 = self.ax.plot(xAchse, yAchse, '-') # Integrate plot on oscilloscope window self.drawing = FigureCanvasTkAgg(fig, master=self.root) self.drawing.show() self.drawing.get_tk_widget().pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1) # Setup navigation tools tool = NavigationToolbar2TkAgg(self.drawing, self.root) tool.update() self.drawing._tkcanvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1) return
Example #6
Source File: criteria.py From spectrum with BSD 3-Clause "New" or "Revised" License | 5 votes |
def MDL(N, rho, k): r"""Minimum Description Length .. math:: MDL(k) = N log \rho_k + p \log N :validation: results """ from numpy import log #p = arange(1, len(rho)+1) mdl = N* log(rho) + k * log(N) return mdl
Example #7
Source File: recipe-576501.py From code with MIT License | 5 votes |
def replotf(self): """This replots the function given the coefficient array c.""" x = M.arange(-1,1.,.001) M.ioff() M.figure(self.ffig.number) M.cla() M.plot(x, f(x,self.c)) M.title(fstring(self.c)) M.draw()
Example #8
Source File: lineshape_analysis.py From quantum-python-lectures with MIT License | 5 votes |
def main(wL,wG): #generate data x = arange(-30,30,0.2) yL,yG,yV = generate_lineshapes(x,0,wL,0,wG) y_noise = random.randn(len(x))*0.03 yV += y_noise fit_lineshape(x,yV)