コード例 #1
0
            lengths = sorted(values_per_length)
            plot_error = False
            if plot_error:
                if j == 1 or j == 5:
                    print '=' * 40
                    print 'sigma =', q, 'j =', j
                    for l in lengths:
                        print l, '&', '{:.3f}'.format(
                            (values_per_length[l] * q - q**(l - j) *
                             (q - 1)**(j - 1) * (q - 2)) /
                            (values_per_length[l] * q)), '\\\\ \\hline'
                    print '=' * 40
                lines = [
                    Line(lengths, [(values_per_length[l] * q - q**(l - j) *
                                    (q - 1)**(j - 1) * (q - 2)) /
                                   (values_per_length[l] * q)
                                   for l in lengths], 'Relative error'),
                ]
                art_plot(
                    lines=lines,
                    filename='b_j_results/{}/{}err{}.pdf'.format(q, q, j),
                    font_size=19,
                    xlabel=u'Длина слова $i$',
                    xlim=(min(lengths), max(lengths)),
                )
            else:
                lines = [
                    Line(
                        lengths,
                        [(q - 1)**(j - 1) * (q - 2) / q**j] * len(lengths),
                        '$\sigma^{-j}(\sigma - 1)^{j - 1}(\sigma - 2)$',
コード例 #2
0
ファイル: soic.py プロジェクト: JonasNorling/footprinter
    def generate(self, **kwargs):
        """Generate data using previously loaded name and parameters. Returns a list."""
        data = []
        params = self.params
        package = Package()

        body = params.l - 2*params.termlen
        package.description = "SOP-%d, %.02fmm pitch, %.2f mm body" % (
                                                    params.pincount, params.pitch, body)
    
        l = params.l # Package lead span
        # Positions and sizes of things relative to data center
        padtoe = l / 2 + params.JT
        padheel = l / 2 - params.footlen - params.JH
        padlen = padtoe - padheel
        padcenter = padtoe - padlen / 2.0
        padwidth = params.termwidth + params.JS
        pins_per_side = params.pincount // 2
        first_pad_x = - (pins_per_side - 1) * params.pitch / 2.0
        packagew = ((pins_per_side - 1) * params.pitch + 1.0) / 2.0 # About right, for small chips
        packageh = l / 2 - params.termlen
        courtyardw = packagew + params.courtyard_excess
        courtyardh = padtoe + params.courtyard_excess
        outlinew = packagew + params.silkwidth/2.0
        outlineh = packageh + params.silkwidth/2.0

        # Draw courtyard on package layer
        rect = Rectangle( (-courtyardw, -courtyardh), (courtyardw, courtyardh))
        rect.layer = "package"
        data.append(rect)

        # Draw package size on package layer
        rect = Rectangle( (-packagew, -packageh), (packagew, packageh))
        rect.layer = "package"
        data.append(rect)
        
        # Draw outline on silkscreen
        rect = Rectangle( (-outlinew, -outlineh), (outlinew, outlineh))
        rect.width = params.silkwidth
        data.append(rect)
        marksize = 0.75
        rect = Rectangle( (-outlinew, -marksize), (-outlinew + marksize, marksize))
        rect.width = params.silkwidth
        data.append(rect)
        
        # Draw orientation marker by pin 1 on silkscreen
        markx = first_pad_x - padwidth / 2.0 - params.silkwidth * 2
        line = Line( (markx, padcenter - params.silkwidth*2), (markx, padcenter))
        line.width = params.silkwidth
        data.append(line)

        # Add pads, starting with pin 1 in lower-left (negative X, positive Y) corner
        # Pads are drawn on the bottom side and rotated into place
        pinno = 1
        for side in range(0, 2):
            th = side * 180 # Coordinate system rotation for this side
    
            # Pad center coordinates
            x = first_pad_x
            y = padcenter
    
            for pin in range(0, pins_per_side):
                pad = Pad(pinno)
                pad.x = x
                pad.y = y
                pad.ysize = padlen
                pad.xsize = padwidth
                pad.rotate(th)
    
                data.append(pad)
    
                pinno += 1
                x += params.pitch

        # All done!
        package.data = data
        package.courtyard = ((-courtyardw, -courtyardh), (courtyardw, courtyardh))
    
        return package
コード例 #3
0
ファイル: qfp.py プロジェクト: JonasNorling/footprinter
    def generate(self, **kwargs):
        """Generate data using previously loaded name and parameters. Returns a list."""
        data = []
        params = self.params
        package = Package()

        package.description = "QFP-%d, %.02fmm pitch" % (
                                                    params.pincount, params.pitch)
    
        l = params.l1 # Package length along this dimension (FIXME: non-square packages)
        # Positions of things relative to data center
        padtoe = l / 2 + params.JT
        padheel = l / 2 - params.footlen - params.JH
        padlen = padtoe - padheel
        padcenter = padtoe - padlen / 2.0
        padwidth = params.termwidth + params.JS
        pins_per_side = params.pincount // 4
        first_pad_y = (pins_per_side - 1) * params.pitch / 2.0
        courtyardsize = padtoe + params.courtyard_excess
        outlinesize = l / 2 - params.termlen + params.silkwidth/2.0

        # Draw courtyard on package layer
        rect = Rectangle( (-courtyardsize, -courtyardsize), (courtyardsize, courtyardsize))
        rect.layer = "package"
        data.append(rect)

        # Draw package size on package layer
        for side in range(0, 4):
            chamfer = 0.5
            packagesize = l / 2 - params.termlen
            th = (270 + side * 90) % 360 # Coordinate system rotation for this side
            line = Line( (-packagesize + chamfer, packagesize), (packagesize - chamfer, packagesize) )
            line.layer = "package"
            line.rotate(th)
            data.append(line)
            line = Line( (packagesize - chamfer, packagesize), (packagesize, packagesize - chamfer) )
            line.layer = "package"
            line.rotate(th)
            data.append(line)

            leadblockw = pins_per_side * params.pitch / 2.0
            leadblockh = l / 2
            
            rect = Rectangle( (-leadblockw, leadblockh), (leadblockw, leadblockh - params.footlen), 0)
            rect.layer = "package"
            rect.rotate(th)
            data.append(rect)
            rect = Rectangle( (-leadblockw, leadblockh - params.footlen), (leadblockw, packagesize), 0)
            rect.layer = "package"
            rect.rotate(th)
            data.append(rect)
    
        # Draw outline on silkscreen
        linelen = outlinesize - first_pad_y - padwidth / 2 - params.silkwidth * 1.5
        for side in range(0, 4):
            th = (270 + side * 90) % 360 # Coordinate system rotation for this side
            line = Line( (-outlinesize, outlinesize), (-outlinesize + linelen, outlinesize) )
            line.width = params.silkwidth
            line.rotate(th)
            data.append(line)
            line = Line( (-outlinesize, outlinesize), (-outlinesize, outlinesize - linelen) )
            line.width = params.silkwidth
            line.rotate(th)
            data.append(line)

        # Draw orientation mark on silkscreen
        marklen = 1.0
        line = Line( (-outlinesize, outlinesize), (-outlinesize - marklen, outlinesize + marklen) )
        line.width = params.silkwidth
        data.append(line)
    
        # Add pads, starting with pin 1 in lower-left (negative X, positive Y) corner
        # Pads are drawn on the 0-degree (right) side and rotated into place
        pinno = 1
        for side in range(0, 4):
            th = (270 + side * 90) % 360 # Coordinate system rotation for this side
    
            # Pad center coordinates
            x = padcenter
            y = first_pad_y
    
            for pin in range(0, pins_per_side):
                pad = Pad(pinno)
                pad.x = x
                pad.y = y
                pad.ysize = padwidth
                pad.xsize = padlen
                pad.rotate(th)
    
                data.append(pad)
    
                pinno += 1
                y -= params.pitch

        # All done!
        package.data = data
        package.courtyard = ((-courtyardsize, -courtyardsize), (courtyardsize, courtyardsize))
    
        return package