当前位置: 首页>>代码示例>>Python>>正文


Python pylab.array方法代码示例

本文整理汇总了Python中pylab.array方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.array方法的具体用法?Python pylab.array怎么用?Python pylab.array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylab的用法示例。


在下文中一共展示了pylab.array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
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 
开发者ID:ankitaggarwal011,项目名称:PiScope,代码行数:18,代码来源:PiScope.py

示例2: _increase_contrast

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
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 
开发者ID:mikevoets,项目名称:jama16-retina-replication,代码行数:23,代码来源:preprocess.py

示例3: __init__

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def __init__(self, max_y_splines=100, simple=0):
        # create this class, then add spline curves to it    

        # the splines are stored in a dictionary with the key
        # as the parameter and the value is the spline_single
        self.x_splines = {}   # supplied by you
        self.y_splines = [{},{},{},{},{}] # generated by this class, index is x-derivative
        self.max_y_splines = max_y_splines # this sets the minimum x_parameter spacing of the y-splines
        self.xmin = None      # set the minimum and maximum values over which this is valid
        self.xmax = None
        self.ymin = None
        self.ymax = None
        self.xlabel = None
        self.ylabel = None
        self.zlabel = None
        self._path = "(spline array not saved)"
        self.simple=simple 
开发者ID:Spinmob,项目名称:spinmob,代码行数:19,代码来源:_spline.py

示例4: scale_x

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def scale_x(scale, axes="current"):
    """

    This function scales lines horizontally.

    """

    if axes=="current": axes = _pylab.gca()

    # get the lines from the plot
    lines = axes.get_lines()

    # loop over the lines and trim the data
    for line in lines:
        if isinstance(line, _mpl.lines.Line2D):
            line.set_xdata(_pylab.array(line.get_xdata())*scale)

    # update the title
    title = axes.title.get_text()
    title += ", x_scale="+str(scale)
    axes.title.set_text(title)

    # zoom to surround the data properly
    auto_zoom() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:26,代码来源:_pylab_tweaks.py

示例5: spot_diagram

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def spot_diagram(s):
    """Plot the spot diagram for the given surface, or element.

    Args:
        s: Object (usually :class:`~pyoptools.raytrace.comp_lib.CCD`)
            whose spot diagram will be plotted.
    """
    hl=s.hit_list
    X=[]
    Y=[]
    COL=[]
    if len(hl) >0:
        for i in hl:
            p=i[0]
            # Hitlist[1] points to the incident ray
            col=wavelength2RGB(i[1].wavelength)
            X.append(p[0])
            Y.append(p[1])
            COL.append(col)
    max=array(X+Y).max
    min=array(X+Y).min
    plot(X,Y,"o",)
    axis("equal") 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:25,代码来源:plotutils.py

示例6: spot_diagram_c

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def spot_diagram_c(s):
    """Plot the spot diagram for the given surface, or element using
    the rays colors.

    Args:
        s: Object (usually :class:`~pyoptools.raytrace.comp_lib.CCD`)
            whose spot diagram will be plotted.
 
    """
    hl=s.hit_list
    X=[]
    Y=[]
    COL=[]
    if len(hl) >0:
        for i in hl:
            p=i[0]
            # Hitlist[1] points to the incident ray
            col=wavelength2RGB(i[1].wavelength)
            plot(p[0],p[1],"o",color=col)
            #X.append(p[0])
            #Y.append(p[1])
            #COL.append(col)
    #max=array(X+Y).max
    #min=array(X+Y).min
    axis("equal") 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:27,代码来源:plotutils.py

示例7: _process_segment

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def _process_segment(self, model, dataset, page, page_xywh, page_id, input_file, orig_img_size, n):
        for i, data in enumerate(dataset):
            w,h = orig_img_size
            generated = model.inference(data['label'], data['inst'], data['image'])
            dewarped = array(generated.data[0].permute(1,2,0).detach().cpu())
            bin_array = array(255*(dewarped>ocrolib.midrange(dewarped)),'B')
            dewarped = ocrolib.array2pil(bin_array)
            dewarped = dewarped.resize((w,h))                        
            
            page_xywh['features'] += ',dewarped'  
            
            file_id = input_file.ID.replace(self.input_file_grp, self.image_grp)
            if file_id == input_file.ID:
                file_id = concat_padded(self.image_grp, n)
        
            file_path = self.workspace.save_image_file(dewarped,
                                   file_id,
                                   page_id=page_id,
                                   file_grp=self.image_grp,
                                   force=self.parameter['force']
                )     
            page.add_AlternativeImage(AlternativeImageType(filename=file_path, comments=page_xywh['features'])) 
开发者ID:OCR-D,项目名称:ocrd_anybaseocr,代码行数:24,代码来源:ocrd_anybaseocr_dewarp.py

示例8: setup

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
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 
开发者ID:ankitaggarwal011,项目名称:PiScope,代码行数:41,代码来源:PiScope.py

示例9: plot_fixed_x

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def plot_fixed_x(self, x_values, x_derivative=0, steps=1000, smooth=0, simple='auto', ymin="auto", ymax="auto", format=True, clear=1):
        """
        plots the data at fixed x-value, so z vs x
        """
        if simple=='auto': simple=self.simple
        
        # get the min and max
        if ymin=="auto": ymin = self.ymin
        if ymax=="auto": ymax = self.ymax
        if clear: _pylab.gca().clear()

        if not type(x_values) in [type([]), type(_pylab.array([]))]: x_values = [x_values]

        for x in x_values:
    
            # define a new simple function to plot, then plot it
            def f(y): return self.evaluate(x, y, x_derivative, smooth, simple)
            _pylab_help.plot_function(f, ymin, ymax, steps, 0, False)

            # label it
            a = _pylab.gca()
            a.set_xlabel(self.ylabel)
            if x_derivative: a.set_ylabel(str(x_derivative)+" "+str(self.xlabel)+" derivative of "+self.zlabel)
            else:            a.set_ylabel(self.zlabel)
            a.set_title(self._path+"\nSpline array plot at fixed x = "+self.xlabel)
            a.get_lines()[-1].set_label("x ("+self.xlabel+") = "+str(x))

        if format: _s.format_figure()
        return a 
开发者ID:Spinmob,项目名称:spinmob,代码行数:31,代码来源:_spline.py

示例10: plot_fixed_y

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def plot_fixed_y(self, y_values, x_derivative=0, steps=1000, smooth=0, simple='auto', xmin="auto", xmax="auto", format=True, clear=1):
        """
        plots the data at a fixed y-value, so z vs y
        """
        if simple=='auto': simple=self.simple


        # get the min and max
        if xmin=="auto": xmin = self.xmin
        if xmax=="auto": xmax = self.xmax
        if clear: _pylab.gca().clear()

        if not type(y_values) in [type([]), type(_pylab.array([]))]: y_values = [y_values]

        for y in y_values:
            # define a new simple function to plot, then plot it
            def f(x): return self.evaluate(x, y, x_derivative, smooth, simple)
            _pylab_help.plot_function(f, xmin, xmax, steps, 0, True)

            # label it
            a = _pylab.gca()
            th = "th"
            if x_derivative == 1: th = "st"
            if x_derivative == 2: th = "nd"
            if x_derivative == 3: th = "rd"
            if x_derivative: a.set_ylabel(str(x_derivative)+th+" "+self.xlabel+" derivative of "+self.zlabel+" spline")
            else:            a.set_ylabel(self.zlabel)
            a.set_xlabel(self.xlabel)
            a.set_title(self._path+"\nSpline array plot at fixed y "+self.ylabel)
            a.get_lines()[-1].set_label("y ("+self.ylabel+") = "+str(y))
        if format: _s.format_figure()
        return a 
开发者ID:Spinmob,项目名称:spinmob,代码行数:34,代码来源:_spline.py

示例11: load_spline_array

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def load_spline_array(path=None, text="Give me a spline array to load, jerkface! No, YOU'RE the jerkface."):
    a = _s.load_object(path, text)

    b = copy_spline_array(a)
    b._path = a._path
    _s.save_object(b, b._path)

    return b 
开发者ID:Spinmob,项目名称:spinmob,代码行数:10,代码来源:_spline.py

示例12: image_neighbor_smooth

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def image_neighbor_smooth(xlevel=0.2, ylevel=0.2, image="auto"):
    """
    This will bleed nearest neighbor pixels into each other with
    the specified weight factors.
    """
    if image == "auto": image = _pylab.gca().images[0]

    Z = _n.array(image.get_array())

    # store this image in the undo list
    global image_undo_list
    image_undo_list.append([image, Z])
    if len(image_undo_list) > 10: image_undo_list.pop(0)

    # get the diagonal smoothing level (eliptical, and scaled down by distance)
    dlevel = ((xlevel**2+ylevel**2)/2.0)**(0.5)

    # don't touch the first column
    new_Z = [Z[0]*1.0]

    for m in range(1,len(Z)-1):
        new_Z.append(Z[m]*1.0)
        for n in range(1,len(Z[0])-1):
            new_Z[-1][n] = (Z[m,n] + xlevel*(Z[m+1,n]+Z[m-1,n]) + ylevel*(Z[m,n+1]+Z[m,n-1])   \
                                   + dlevel*(Z[m+1,n+1]+Z[m-1,n+1]+Z[m+1,n-1]+Z[m-1,n-1])   )  \
                                   / (1.0+xlevel*2+ylevel*2 + dlevel*4)

    # don't touch the last column
    new_Z.append(Z[-1]*1.0)

    # images have transposed data
    image.set_array(_n.array(new_Z))

    # update the plot
    _pylab.draw() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:37,代码来源:_pylab_tweaks.py

示例13: shift

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def shift(xshift=0, yshift=0, progressive=0, axes="gca"):
    """

    This function adds an artificial offset to the lines.

    yshift          amount to shift vertically
    xshift          amount to shift horizontally
    axes="gca"      axes to do this on, "gca" means "get current axes"
    progressive=0   progressive means each line gets more offset
                    set to 0 to shift EVERYTHING

    """

    if axes=="gca": axes = _pylab.gca()

    # get the lines from the plot
    lines = axes.get_lines()

    # loop over the lines and trim the data
    for m in range(0,len(lines)):
        if isinstance(lines[m], _mpl.lines.Line2D):
            # get the actual data values
            xdata = _n.array(lines[m].get_xdata())
            ydata = _n.array(lines[m].get_ydata())

            # add the offset
            if progressive:
                xdata += m*xshift
                ydata += m*yshift
            else:
                xdata += xshift
                ydata += yshift

            # update the data for this line
            lines[m].set_data(xdata, ydata)

    # zoom to surround the data properly

    auto_zoom() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:41,代码来源:_pylab_tweaks.py

示例14: scale_y

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def scale_y(scale, axes="current", lines="all"):
    """

    This function scales lines vertically.
    You can specify a line index, such as lines=0 or lines=[1,2,4]

    """

    if axes=="current": axes = _pylab.gca()

    # get the lines from the plot
    lines = axes.get_lines()

    # loop over the lines and trim the data
    for line in lines:
        if isinstance(line, _mpl.lines.Line2D):
            line.set_ydata(_pylab.array(line.get_ydata())*scale)

    # update the title
    title = axes.title.get_text()
    if not title == "":
        title += ", y_scale="+str(scale)
        axes.title.set_text(title)


    # zoom to surround the data properly
    auto_zoom() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:29,代码来源:_pylab_tweaks.py

示例15: set_yticks

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import array [as 别名]
def set_yticks(start, step, axes="gca"):
    """
    This will generate a tick array and apply said array to the axis
    """
    if axes=="gca": axes = _pylab.gca()

    # first get one of the tick label locations
    xposition = axes.yaxis.get_ticklabels()[0].get_position()[0]

    # get the bounds
    ymin, ymax = axes.get_ylim()

    # get the starting tick
    nstart = int(_pylab.floor((ymin-start)/step))
    nstop  = int(_pylab.ceil((ymax-start)/step))
    ticks = []
    for n in range(nstart,nstop+1): ticks.append(start+n*step)

    axes.set_yticks(ticks)

    # set the x-position
    for t in axes.yaxis.get_ticklabels():
        x, y = t.get_position()
        t.set_position((xposition, y))

    _pylab.draw() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:28,代码来源:_pylab_tweaks.py


注:本文中的pylab.array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。