Best Python code snippet using tempest_python
mems_testing.py
Source:mems_testing.py  
1import pya2import math3import numpy4class MicroHotPlateSensor(pya.PCellDeclarationHelper):5  def __init__(self):6    # Important: initialize the super class7    super(MicroHotPlateSensor, self).__init__()8    # declare the parameters9    #LayerParameters10    self.param("l", self.TypeLayer, "Hotplate material representation", default = pya.LayerInfo(1, 0, "HotPlateMat"))11    self.param("la", self.TypeLayer, "Hotplate Active Area", default = pya.LayerInfo(99, 500, "HotPlateAct"))12    self.param("ool", self.TypeLayer, "Oxide openings - etch", default = pya.LayerInfo(2,0, "Oxide opening"))13    #self.param("ld", self.TypeLayer, "Describtors layer", default = pya.LayerInfo(99,250))14    self.param("heatl", self.TypeLayer, "Heater material layer", default = pya.LayerInfo(5,0, "Heater"))15    self.param("cntl", self.TypeLayer, "Interconenctions layer", default = pya.LayerInfo(6,0, "Interconnections"))16    self.param("perfl", self.TypeLayer, "Perforation Layer", default = pya.LayerInfo(7, 0, "Perforation"))17    self.param("idcl", self.TypeLayer, "Top electrodes Layer", default = pya.LayerInfo(8,0,"Top IDCs"))18    self.param("lvia", self.TypeLayer, "Vias layer", default = pya.LayerInfo(9,0, "Vias"))19    20    21    #Geometry parameters22    self.param("ovsize", self.TypeList, "Overal size [x, y]", default=[250.0,250.0])23    self.param("size", self.TypeList, "HotPlate Size [x, y]", default = [100.0, 100.0])24    self.param("armLenght", self.TypeDouble, "Arm Lenght", default = 30.0)25    self.param("armWidth", self.TypeDouble, "Arm Width", default = 10.0)26    self.param("actOffset", self.TypeDouble, "Active area offset from edge", default = 5.0)27    self.param("showAct", self.TypeBoolean, "Show active area", choices = [["No", False],["Yes", True]], default= True)28     29    #Process parameters 30    self.param("etchDepth", self.TypeDouble, "Exp. etch depth", default=25.0)31    32    #Heater parameters33    self.param("genHeater", self.TypeBoolean, "Generate Heater", choices = [["No", False],["Yes", True]], default= True)34    self.param("heatType", self.TypeInt, "Heater type", choices = [["Hilbert", 0],["Spiral", 1]], default= 0)35    self.param("heatW", self.TypeDouble, "Heater wire width", default = 1.0)36    self.param("heatOrder", self.TypeInt, "Heater wire Hillbert order", default = 5)37    self.param("heatThick", self.TypeDouble, "Heater wire thickness", default = 0.050)38    #self.param("heatRho", self.TypeDouble, "Active area offset from edge", default = 10.6E-8)39    #self.param("heatRho", self.TypeDouble, "Active area offset from edge", default = 5.0)40    self.param("roundPath", self.TypeBoolean, "Round the heater path", choices = [["No", False],["Yes", True]], default= True)41    self.param("perfAct", self.TypeBoolean, "Perforation of the membrane in Hillbert sq", choices = [["No", False],["Yes", True]], default = True)42    self.param("perfSize", self.TypeDouble, "Perforation size", default = 2.5)43    #wireouts44 45    self.param("genWO", self.TypeBoolean, "Generate Wireouts to overal size", choices = [["No", False],["Yes", True]], default= True) 46    self.param("woW", self.TypeDouble, "Wireout width", default = 5.0)47    self.param("woOP", self.TypeDouble, "Wireout overpass", default = 0.0)48    #contacts49    self.param("genCnt", self.TypeBoolean, "Generate top contacts to overal size", choices = [["No", False],["Yes", True]], default= True) 50    self.param("cntWO", self.TypeDouble, "contact wireout width", default = 10.0)51    self.param("cntW", self.TypeDouble, "contact wire width", default = 1.5)52    self.param("cntB", self.TypeDouble, "contact Bar width", default = 10.0)53    self.param("cntSp", self.TypeDouble, "contact interdigital spacing", default = 1.25)54    #debuging55    self.param("debug", self.TypeBoolean, "Debug output", choices = [["No", False],["Yes", True]], default= True) 56    57    58    #def display_text_impl(self):59        # Provide a descriptive text for the cell60    #return "AMR_Disk(D={:.3f}, AsyV={}".format(self.dia, self.asy_vector)61  def coerce_parameters_impl(self):62    # TODO: use x to access parameter x and set_x to modify it's value63    rs = None64  def produce_impl(self):65    #Calculate layout database unit66    #dbu = self.layout.dbu67    dbu = 168    size = []69    if len(self.size) < 2:70        if self.debug:71            print("Size < 2 dimension")72        if len(self.size) == 0:73            if self.debug:74                print("paramter size has been adjusted to default - invalid data have provided")75            size = [100.0, 100.0]76        else:77            if self.debug:78                print("Size has been adjusted to {}:{}".format(self.size[0]/dbu, self.size[0]/dbu))79            size.append(float(self.size[0])/dbu)80            size.append(float(self.size[0])/dbu)81    else:82        size.append(float(self.size[0])/dbu)83        size.append(float(self.size[1])/dbu)84    ovSize = []85    if len(self.ovsize) < 2:86        if self.debug:87            print("overal size < 2 dimension")88        if len(self.ovsize) == 0:89            if self.debug:90                print("paramter size has been adjusted to default - invalid data have provided")91            ovSize = [100.0, 100.0]92        else:93            ovSize.append(float(self.ovsize[0])/dbu)94            ovSize.append(float(self.ovsize[0])/dbu)95    else:96        ovSize.append(float(self.ovsize[0])/dbu)97        ovSize.append(float(self.ovsize[1])/dbu)98    armLenght = self.armLenght/dbu99    armWidth = self.armWidth/dbu100    activeArea = [size[0] - self.actOffset, size[1] - self.actOffset]101    woW = self.woW/dbu102    woOP = self.woOP/dbu103    # Membrane Geometry:104    ## arm location on a rectangle = edgeArmOffset105    edgeArmOffset = armWidth / 2 * math.sqrt(2)106    if self.debug:107        print("Size 0:{:.3f}, {}, {}".format(size[0], armLenght, armWidth))108    ## arm starts at following points109    pointArmA = pya.DPoint(size[0]/2 - edgeArmOffset, size[1]/2)110    pointArmD = pya.DPoint(size[0]/2, size[1]/2 - edgeArmOffset)111    ## arm ends in the point P - might be usefull as a connector point112    pointP = pya.DPoint(size[0]/2+armLenght/math.sqrt(2), size[1]/2+armLenght/math.sqrt(2))113    ## arm edge points offsets from the center point P114    armEndPointoffset = armWidth/2/math.sqrt(2)    115    ## Arm edge points in relation to the P point116    117    pointArmB = pya.DPoint(pointP.x-armEndPointoffset, pointP.y+armEndPointoffset)118    pointArmC = pya.DPoint(pointP.x+armEndPointoffset, pointP.y-armEndPointoffset)119    120    ## Lets Try to assemble the membrane as 1/4121    polyPoints = []122    polyPoints.append(pya.DPoint(0.0, 0.0))123    polyPoints.append(pya.DPoint(0.0, size[1]/2))124    polyPoints.append(pointArmA)125    polyPoints.append(pointArmB)126    polyPoints.append(pointArmC)127    polyPoints.append(pointArmD)128    polyPoints.append(pya.DPoint(size[0]/2, 0.0))129    #Lets put it there130    shapeSet = []131    132    Poly = pya.DPolygon(polyPoints)133    shapeSet.append(Poly)134    135    t=pya.DCplxTrans(1.0, 180, False, 0.0, 0.0)136    Poly1 = pya.DPolygon(polyPoints)137    Poly1.transform(t)138    shapeSet.append(Poly1)139        140    t=pya.DCplxTrans(1.0, 0, True, 0.0, 0.0)141    Poly2 = pya.DPolygon(polyPoints)142    Poly2.transform(t)143    shapeSet.append(Poly2)144    145    t=pya.DCplxTrans(1.0, 180, True, 0.0, 0.0)146    Poly3 = pya.DPolygon(polyPoints)147    Poly3.transform(t)148    shapeSet.append(Poly3)149    150    tr=pya.DCplxTrans(1000.0)151    region = pya.Region(shapeSet)152    region.merge()153    region.transform(tr)154    155    self.cell.shapes(self.l_layer).insert(region)156    #Active Area 157    if self.showAct:158        actBox = pya.DBox(-activeArea[0]/2, -activeArea[1]/2, activeArea[0]/2, activeArea[1]/2)159        self.cell.shapes(self.la_layer).insert(actBox)160    161    # Etch area - a rectangele limited by the membrane shape and P point162    etchBox = pya.DBox(-pointP.x, -pointP.y, pointP.x, pointP.y)163    etchRegion = pya.Region(etchBox)164    etchRegion.transform(tr)165    tempRegion = region ^ etchRegion166    etchRegion = tempRegion & etchRegion167    self.cell.shapes(self.ool_layer).insert(etchRegion)168    # Heater wire169    if self.genHeater:170        if self.heatType == 0:171            #Hilbert is defined only for square areas. We would fit whatever is smaller172            173            if activeArea[0] != activeArea[1]:174                if (activeArea[0] > activeArea[1]):175                    wireArea = activeArea[1]/2176                else:177                    wireArea = activeArea[0]/2178            else:179                wireArea = activeArea[0]/2180            181            #issue num2:182            #  the diagonal contact placemnet is required183            #  so we have to calculate space for the return path184            #  segment separation 1sqg => seg = wireArea / 2^n + 1185            Hcnt = 2 ** self.heatOrder + 1186            Hseg = wireArea / (Hcnt)187            print("Hseq: {:.3f}".format(Hseg))188            wireAreaRed = wireArea - Hseg189            a=wireAreaRed+wireAreaRed*1j190            b=wireAreaRed-wireAreaRed*1j191            z = 0192            for i in range(1,self.heatOrder+1):193                w=1j*z.conjugate()194                z = numpy.array([w-a, z-b, z+a, b-w])/2195            z= z.flatten()196            X = [x.real for x in z]197            Y = [x.imag for x in z]198            heatPoints = []199            for i in range (0, len(X)):200                heatPoints.append(pya.DPoint(X[i], Y[i]))201            #lets add the return path202            #  start with calculation of intersection to the beam203            #  linEqa = -1*(pointP.y / pointP.x) - valid only for Square204            #  205            #print("Linear equation is y = {:.3f}.x".format(linEqa))206            heatInitial = heatPoints[0]207            pointS1 = pya.DPoint(-size[0]/2, size[1]/2)208            #pointS2 = pya.DPoint(activeArea[0]/2, -activeArea[1]/2)209            if self.debug:210                print("P:{:.3f},{:.3f} ; S:{:.3f},{:.3f}".format(-pointP.x, pointP.y, pointS1.x, pointS1.y))211            linEqa = (pointP.y-pointS1.y)/(-pointP.x-pointS1.x)212            linEqb = pointP.y - linEqa*-pointP.x 213            if self.debug:214                print("Line equation is: y={:.3f}x+{:.3f}".format(linEqa,linEqb))215            heatPoints.insert(0, pya.DPoint(heatPoints[0].x - 2*Hseg, heatPoints[0].y))216            heatPoints.insert(0, pya.DPoint(heatPoints[0].x, linEqa*(heatPoints[0].x+Hseg)+linEqb))217            heatPoints.append(pya.DPoint(heatPoints[len(heatPoints)-1].x, \218                linEqa*(heatPoints[len(heatPoints)-1].x+Hseg)-linEqb))219            heatPoints.append(pya.DPoint(pointP.x - Hseg, -pointP.y)) #arm contacts220            heatPoints.insert(0, pya.DPoint(-pointP.x - Hseg, pointP.y))221            222            #probably somewhere here is a good time to calculate perforations 223            # teoretically first opening should be -Heg/2 to the left of the very first 224            # point and should repeat in X and Y axis with interval of Hseg225            # 226            # center is HeatPoints[2] -Hseg/2 ?227            if self.perfAct:228                perfW = self.perfSize/2 / dbu229                #perfCenter = pya.DPoint(heatPoints[2].x - Hseg, heatPoints[2].y - Hseg)230                #perfBox = pya.DBox(perfCenter.x-perfW, perfCenter.y-perfW, perfCenter.x+perfW, perfCenter.y-perfW)231                elCell = self.layout.create_cell("Perforator")232                perfBox = pya.DPolygon(pya.DBox(-perfW, -perfW, perfW, perfW))233                if self.roundPath:234                    perfBox = perfBox.round_corners(Hseg/2, Hseg/2, 32)235                elCell.shapes(self.perfl_layer).insert(perfBox)236                #lets make an array of them 237                x_vect = pya.DVector(2*Hseg, 0.0)238                y_vect = pya.DVector(0.0, 2*Hseg)239                t = pya.DCplxTrans(heatInitial.x, heatInitial.y+Hseg)240                perfArr = pya.DCellInstArray(elCell.cell_index(), t, x_vect, y_vect, Hcnt-1, Hcnt-2)241                self.cell.insert(perfArr)242                #move to the right coordinates243                pathT = pya.DCplxTrans(Hseg, 0)244                heatPath = pya.DPath(heatPoints, self.heatW)245                heatPathT = heatPath.transformed(pathT)246                if self.roundPath:247                    heatPathT = heatPath.round_corners(Hseg/2,32, 0.001)248                    heatCenter = heatPathT.bbox().center()249                    print(heatCenter)250                    print("Rounded Path center: {}:{}".format(heatCenter.x, heatCenter.y))251                    pathTr = pya.DCplxTrans(-heatCenter.x, -heatCenter.y)252                    heatPathT = heatPathT.transformed(pathTr)253                self.cell.shapes(self.heatl_layer).insert(heatPathT)        254        else:255            print("Wire definition has not been found!")256            #TODO ... other types of heaters257    if self.genWO:258        #we would make a wire connection from the P point to the edge of the membrane 259        # overpass on both sides as an option260        # it has to be realized as a set of the 4 path261        print("Overal size: {}:{}".format(ovSize[0], ovSize[1]))262        woPathA = pya.DPath([pointP, pya.DPoint(ovSize[0]/2, ovSize[1]/2)],woW, woOP, woOP)263        woPathB = pya.DPath([pya.DPoint(-pointP.x, pointP.y), pya.DPoint(-ovSize[0]/2, ovSize[1]/2)],\264            woW, woOP, woOP)265        woPathC = pya.DPath([pya.DPoint(-pointP.x, -pointP.y), pya.DPoint(-ovSize[0]/2, -ovSize[1]/2)],\266            woW, woOP, woOP)267        woPathD = pya.DPath([pya.DPoint(pointP.x, -pointP.y), pya.DPoint(ovSize[0]/2, -ovSize[1]/2)],\268            woW, woOP, woOP)269        self.cell.shapes(self.cntl_layer).insert(woPathA)270        self.cell.shapes(self.cntl_layer).insert(woPathB)  271        self.cell.shapes(self.cntl_layer).insert(woPathC)  272        self.cell.shapes(self.cntl_layer).insert(woPathD)  273    274    if self.genCnt:275        # Ok that would be fun ... 276        #   so at first we should be able to find how many of the IGC we would be able to fit277        #   in between of the perforations (maybe we should count also for the minimal separation)278        #   principally:279        #       single IGS pair consists of 2 wires and 2 gaps = IGSpairW?280        #       testing condition is therefore IGSCnt = floor((Hseg - perfW) / IGSpairW)281        cntW = self.cntW / dbu282        cntSp = self.cntSp / dbu283        cntB = self.cntB / dbu284        cntBunchW = 2*(cntW+cntSp)285        cntCnt = math.floor((2*Hseg-2*perfW)/cntBunchW)286        if self.debug:287            print("IDC W={}".format(cntBunchW))288            print("IDCs per bunch: {}".format(cntCnt))289        if cntCnt == 0:290            print("Error: Interdigital contacts with given specs could not be realized because of geometric containts!")291        else:292            #lets make a subcell with interdigital pair293            #   so first calculate the active area - contact bars to get the lenght294            #   contacts singles295            cntCell = self.layout.create_cell("IDC_subcell")296            cntArrCell = self.layout.create_cell("IDC_cell")297            #cntLenght = activeArea - 2*cntB - cntSp298            cntPath_p1 = pya.DPoint((cntSp+cntW)/2, activeArea[1]/2-cntB)299            cntPath_p2 = pya.DPoint((cntSp+cntW)/2, -activeArea[1]/2+cntSp+cntB) #TODO tohle je asi blbe ... 300            cntPath_pA =  [cntPath_p1, cntPath_p2]301            cntPath_pB =  [cntPath_p1 * -1, cntPath_p2 * -1]302            303            cntPath_A = pya.DPath(cntPath_pA, cntW, 0.0, 0.0)304            cntPath_B = pya.DPath(cntPath_pB, cntW, 0.0, 0.0)305            cntCell.shapes(self.idcl_layer).insert(cntPath_A)306            cntCell.shapes(self.idcl_layer).insert(cntPath_B)307            #now lets make bunches of cntCnt and center them 308            # TODO: tady jsem skoncil ... potreba projit odstavec pod309            #BEGIN310            x_vect = pya.DVector(cntBunchW, 0.0)311            y_vect = pya.DVector(0.0, 0.0)312            if self.debug:313                print("IDC bunch Vectors: {}, {}, {}, {}".format(\314                    x_vect.x, x_vect.y, y_vect.x, y_vect.y))315            t = pya.DCplxTrans(0, 0)316            cntArr = pya.DCellInstArray(cntCell.cell_index(), t, x_vect, y_vect, cntCnt, 1)317            318            #center the origins on top of each other319            #   here we have a bunch of IDCs320            cntArr_center = cntArr.bbox(self.layout).center()321            if self.debug:322                print("Bunch center: {},{}".format(cntArr_center.x, cntArr_center.y))323            t=pya.DCplxTrans(1.0, 0, False, -cntArr_center.x, -cntArr_center.y)324            cntArr.transform(t)325            cntArrCell.insert(cntArr)326            327            #   move the array to the position of Hilb. initial and paste it into the overal array328            329            a_vect = pya.DVector(2*Hseg, 0.0)330            b_vect = pya.DVector(0.0, 0.0)331            cntLoct = pya.DCplxTrans(1.0,0,False, heatInitial.x-Hseg, 0.0)332            cntArrAll = pya.DCellInstArray(cntArrCell.cell_index(), cntLoct, a_vect, b_vect, 10, 1)333            self.cell.insert(cntArrAll)334            #Top and bottom contact 335            #  by principle the bar-contact should be horizontally oriented across the active zone336            #  then they should continue to the respective P-points (upright, lowerleft)337            338            #  Contact bar would be a box from the edge to the edge of active area with a width of 339            #  cntB 340            # pointCNT1A = pya.DPoint(activeArea[0]/2, activeArea[1]/2)341            # if self.debug:342            #     print("P:{:.3f},{:.3f} ; CNT:{:.3f},{:.3f}".format(-pointP.x, pointP.y, pointCNT1A.x, pointCNT1A.y))343            # linCntEqa = (pointP.y-pointCNT1A.y)/(-pointP.x-pointCNT1A.x)344            # linCntEqb = pointP.y - linCntEqa*-pointP.x 345            # if self.debug:346            #     print("CNT line equation is: y={:.3f}x+{:.3f}".format(linEqa,linEqb))347            348            # pointCNT1B =349            # Contact Bars350            cntBarW = self.cntB/dbu351            cntWoW = self.cntWO/dbu352            shapeSetCNT = []353            #cntBarA 354            shapeSetCNT.append(pya.DBox(-activeArea[0]/2, activeArea[1]/2-cntBarW,\355                activeArea[0]/2, activeArea[1]/2))356            #cntBarB357            shapeSetCNT.append(pya.DBox(-activeArea[0]/2, -activeArea[1]/2,\358                activeArea[0]/2, -activeArea[1]/2+cntBarW))359            pointS2 = pya.DPoint(activeArea[0]/2, activeArea[1]/2)360            #cntWOPathA361            shapeSetCNT.append(pya.DPath([pointS2,pointP], cntWoW, cntWoW/2, cntWoW).polygon())362            #cntWOPathB363            shapeSetCNT.append(pya.DPath([-pointS2,-pointP], cntWoW, cntWoW/2, cntWoW).polygon())364            for shape in shapeSetCNT:365                self.cell.shapes(self.idcl_layer).insert(shape)366            #Vias 367            #TODO: repair position of the vias368            cntViaW = cntWoW * 0.9/2 # 10% smaller then the wire369            tr = pya.DCplxTrans(1.0, 45.0, False, pya.DVector(pointP))370            cntViaA = pya.DPolygon(pya.DBox(-cntViaW, -cntViaW,\371                cntViaW, cntViaW)).transform(tr)372            tr = pya.DCplxTrans(1.0, 45.0, False, pya.DVector(-pointP))373            cntViaB = pya.DPolygon(pya.DBox(-cntViaW, -cntViaW,\374                cntViaW, cntViaW)).transformed(tr)375            self.cell.shapes(self.lvia_layer).insert(cntViaA)376            self.cell.shapes(self.lvia_layer).insert(cntViaB)377            378            379            380            #tr=pya.DCplxTrans(1000.0)381            #regionCNT = pya.Region(shapeSetCNT)382            #regionCNT.merge()383            #regionCNT.transform(tr)384            # not working -- some expansion happening there. 385            386            387            388                        389            #END390        391          392        #elCell.shapes(self.perfl_layer).insert(perfBox)393        #lets make an array of them 394        #x_vect = pya.DVector(Hseg, 0.0)395        #y_vect = pya.DVector(0.0, Hseg)396        #t = pya.DCplxTrans(0, 0)397        #perfArr = pya.DCellInstArray(elCell.cell_index(), t, x_vect, y_vect, Hcnt, Hcnt)398        #self.cell.insert(perfArr)399class MicroHotPlateSensorHK(pya.PCellDeclarationHelper):400  def __init__(self):401    # Important: initialize the super class402    super(MicroHotPlateSensorHK, self).__init__()403    # declare the parameters404    #LayerParameters405    self.param("l", self.TypeLayer, "Hotplate material representation", default = pya.LayerInfo(1, 0, "HotPlateMat"))406    self.param("la", self.TypeLayer, "Hotplate Active Area", default = pya.LayerInfo(99, 0, "HotPlateAct"))407    self.param("loa", self.TypeLayer, "Hotplate Overal Area", default = pya.LayerInfo(99, 500, "uHotPlate_Overal"))408    self.param("ool", self.TypeLayer, "Oxide openings - etch", default = pya.LayerInfo(2,0, "Oxide opening"))409    self.param("ld", self.TypeLayer, "Describtors layer", default = pya.LayerInfo(99,250))410    self.param("heatl", self.TypeLayer, "Heater material layer", default = pya.LayerInfo(5,0, "Heater wires"))411    self.param("wol", self.TypeLayer, "WireOut layer", default = pya.LayerInfo(6,0, "wireout"))412    self.param("perfl", self.TypeLayer, "Perforation Layer", default = pya.LayerInfo(7, 0, "Perforation"))413    self.param("idcl", self.TypeLayer, "Top electrodes Layer", default = pya.LayerInfo(8,0,"Top IDCs"))414    #self.param("lvia", self.TypeLayer, "Vias layer", default = pya.LayerInfo(9,0, "Vias"))415    416    417    #Geometry parameters418    self.param("ovsize", self.TypeList, "Overal size [x, y]", default=[250.0,250.0])419    self.param("size", self.TypeList, "HotPlate Size [x, y]", default = [100.0, 100.0])420    self.param("armWidth", self.TypeDouble, "Arm Width", default = 10.0)421    self.param("armBMS", self.TypeDouble, "Beam to Side separation", default = 10.0)422    self.param("actOffset", self.TypeDouble, "Active area offset from edge", default = 5.0)423    self.param("showAct", self.TypeBoolean, "Show active area", choices = [["No", False],["Yes", True]], default= True)424    self.param("showOvA", self.TypeBoolean, "Show overal area", choices = [["No", False],["Yes", True]], default= True) 425    #Process parameters 426    self.param("etchDepth", self.TypeDouble, "Exp. etch depth", default=25.0)427    428    #Heater parameters429    self.param("genHeater", self.TypeBoolean, "Generate Heater", choices = [["No", False],["Yes", True]], default= True)430    self.param("heatType", self.TypeInt, "Heater type", choices = [["Hilbert", 0],["Meander", 1],["Spiral", 2]], default= 0)431    self.param("heatW", self.TypeDouble, "Heater wire width", default = 1.0)432    self.param("heatOrder", self.TypeInt, "Heater wire Hillbert order", default = 3)433    self.param("heatSp", self.TypeDouble, "Heater wire spacing (other then Hilbert)", default = 10.0)434    self.param("heatThick", self.TypeDouble, "Heater wire thickness (nm)", default = 0.050)435    self.param("heatRho", self.TypeDouble, "Resistivity", default = 10.6E-8)436    self.param("roundPath", self.TypeBoolean, "Round the heater path", choices = [["No", False],["Yes", True]], default= True)437    self.param("perfAct", self.TypeBoolean, "Perforation of the membrane in Hillbert sq", choices = [["No", False],["Yes", True]], default = True)438    self.param("perfSize", self.TypeDouble, "Perforation size", default = 2.5)439    self.param("perfMult", self.TypeInt, "Perforation multiplier", default = 2)440    #wireouts441    self.param("genWO", self.TypeBoolean, "Generate Wireouts to overal size", choices = [["No", False],["Yes", True]], default= True) 442    self.param("woW", self.TypeDouble, "Wireout width", default = 5.0)443    self.param("woOP", self.TypeDouble, "Wireout overpass", default = 0.0)444    #contacts445    self.param("genCnt", self.TypeBoolean, "Generate top contacts to overal size", choices = [["No", False],["Yes", True]], default= True) 446    self.param("cntWO", self.TypeDouble, "contact wireout width", default = 10.0)447    self.param("cntW", self.TypeDouble, "contact wire width", default = 1.5)448    self.param("cntB", self.TypeDouble, "contact Bar width", default = 10.0)449    self.param("cntSp", self.TypeDouble, "contact interdigital spacing", default = 1.25)450    #debuging451    self.param("printInfo", self.TypeBoolean, "Info output", choices = [["No", False],["Yes", True]], default= True)452    self.param("debug", self.TypeBoolean, "Debug output", choices = [["No", False],["Yes", True]], default= True) 453    454    455    #def display_text_impl(self):456        # Provide a descriptive text for the cell457    #return "AMR_Disk(D={:.3f}, AsyV={}".format(self.dia, self.asy_vector)458  def coerce_parameters_impl(self):459    # TODO: use x to access parameter x and set_x to modify it's value460    rs = None461  def produce_impl(self):462    size = []463    if len(self.size) < 2:464        if self.debug:465            print("Size < 2 dimension")466        if len(self.size) == 0:467            if self.debug:468                print("paramter size has been adjusted to default - invalid data have provided")469            size = [100.0, 100.0]470        else:471            if self.debug:472                print("Size has been adjusted to {}:{}".format(self.size[0]/dbu, self.size[0]/dbu))473            size.append(float(self.size[0]))474            size.append(float(self.size[0]))475    else:476        size.append(float(self.size[0]))477        size.append(float(self.size[1]))478    ovSize = []479    if len(self.ovsize) < 2:480        if self.debug:481            print("overal size < 2 dimension")482        if len(self.ovsize) == 0:483            if self.debug:484                print("paramter size has been adjusted to default - invalid data have provided")485            ovSize = [100.0, 100.0]486        else:487            ovSize.append(float(self.ovsize[0]))488            ovSize.append(float(self.ovsize[0]))489    else:490        ovSize.append(float(self.ovsize[0]))491        ovSize.append(float(self.ovsize[1]))492    Text = "Info:\n"493    Text += "OvArea {:.3f}, {:.3f} um\n". format(ovSize[0], ovSize[1])494    495    #armLenght = self.armLenght496    armWidth = self.armWidth497    armBSS = self.armBMS498    activeArea = [size[0] - self.actOffset, size[1] - self.actOffset]499    #Active Area500    if self.debug:501        print("----------      Helpers section      ----------")502    actBox = pya.DBox(-activeArea[0]/2, -activeArea[1]/2,\503         activeArea[0]/2, activeArea[1]/2)504    if self.showAct:505        self.cell.shapes(self.la_layer).insert(actBox)506    507    #Overal Area508    ovBox = pya.DBox(-ovSize[0]/2, -ovSize[1]/2,\509         ovSize[0]/2, ovSize[1]/2)510    if self.showOvA:511        self.cell.shapes(self.loa_layer).insert(ovBox)512    if self.debug:513        print("Active Area: {:.3f}, {:.3f} um". format(activeArea[0], activeArea[1]))514        print("Overal Area: {:.3f}, {:.3f} um". format(ovSize[0], ovSize[1]))515    Text += "ActArea {:.3f}, {:.3f} um\n". format(activeArea[0], activeArea[1])    516    #woW = self.woW/dbu517    #woOP = self.woOP/dbu518    Text += "Beam {:.3f} um\n". format(armWidth)519    # Membrane Geometry:520    if self.debug:521        print("---------- Membrane geometry section ----------")522    memParts=[]523    #   Firstly generate the centerpart524    memCenter = pya.Polygon(pya.DPolygon(pya.DBox(-size[0]/2, -size[1]/2, size[0]/2, size[1]/2)))525    526    memParts.append(memCenter)527    #   Time for beams528    #   Calculate the BeamArmcenter to the membrane edge, alias beam to memrane spacing529    memBMS = [(ovSize[0]-size[0])/2 -armBSS -armWidth/2,\530        (ovSize[1]-size[1])/2 -armBSS -armWidth/2]531    if self.debug:532        print("Spacing in between membrane and beam X:{:.3f}um, Y:{:.3f}um".format(memBMS[0]-armWidth/2, memBMS[1]-armWidth/2))533    Text += "memBMS: {:.3f}, {:.3f} um\n". format(memBMS[0]-armWidth/2, memBMS[1]-armWidth/2)534    pointUR = pya.DPoint((size[0]-armWidth)/2, size[1]/2)535    memBeam1 = pya.Polygon(pya.DPath([\536        pointUR,\537        pya.DPoint((size[0]-armWidth)/2, size[1]/2+memBMS[1]),\538        pya.DPoint(-ovSize[0]/2, size[1]/2+memBMS[1])], armWidth).polygon())539    memParts.append(memBeam1)540    pointUL = pya.DPoint(-size[0]/2, (size[1]/2)-armWidth/2)541    memBeam2 = pya.Polygon(pya.DPath([\542        pointUL,\543        pya.DPoint(-size[0]/2-memBMS[0], size[1]/2-armWidth/2),\544        pya.DPoint(-size[0]/2-memBMS[0], -ovSize[1]/2)], armWidth).polygon())545    memParts.append(memBeam2)546    pointLL = pya.DPoint((-size[0]+armWidth)/2, -size[1]/2)547    memBeam3 = pya.Polygon(pya.DPath([\548        pointLL,\549        pya.DPoint((-size[0]+armWidth)/2, -size[1]/2-memBMS[1]),\550        pya.DPoint(ovSize[0]/2, -size[1]/2-memBMS[1])], armWidth).polygon())551    memParts.append(memBeam3)552    pointLR = pya.DPoint(size[0]/2, -(size[1]-armWidth)/2)553    memBeam4 = pya.Polygon(pya.DPath([\554        pointLR,\555        pya.DPoint(size[0]/2+memBMS[0], -size[1]/2+armWidth/2),\556        pya.DPoint(size[0]/2+memBMS[0], ovSize[1]/2)], armWidth).polygon())557    memParts.append(memBeam4)558    #here it would be probably useful to put them all into one polygon object (hopefully it\559    # would work ;))560    if self.debug:561        print("Members of the device layer:")562        for member in memParts:563            print(member)564        #     self.cell.shapes(self.l_layer).insert(member)565    tr=pya.DCplxTrans(1000.0) #workaround for difference in DBU566    region = pya.Region(memParts)567    region.merge()568    region.transform(tr)   569    self.cell.shapes(self.l_layer).insert(region)570    571        572    # Etch area - in this variant the overal size of membrane573    if self.debug:574        print("----------     Oxide Etch section     ----------")575    etchRegion = pya.Region(ovBox)576    etchRegion.transform(tr)577    578    tempRegion = region ^ etchRegion579    etchRegion = tempRegion & etchRegion580    self.cell.shapes(self.ool_layer).insert(etchRegion)581    #Heater wire582    if self.debug:583        print("----------       Heater section       ----------")584    if self.genHeater:585        586        if self.heatType == 0:587            Text += "Heater Hilbert: {} order\n". format(self.heatOrder)588            #Hilbert is defined only for square areas. We would fit whatever is smaller589            if self.debug:590                print("Heater type >> Hilbert")591            if activeArea[0] != activeArea[1]:592                if (activeArea[0] > activeArea[1]):593                    wireArea = activeArea[1]/2 + self.actOffset/2 -armWidth/2 594                else:595                    wireArea = activeArea[0]/2 + self.actOffset/2 -armWidth/2596            else:597                wireArea = activeArea[0]/2 + self.actOffset/2 -armWidth/2598            599            if self.debug:600                print("Wire Area: {}, {}um".format(wireArea, wireArea))601            #issue num2:602            #  the diagonal contact placemnet is required603            #  so we have to calculate space for the return path604            #  segment separation 1sqg => seg = wireArea / 2^n + 1605            Hcnt = 2 ** self.heatOrder + 1606            Hseg = wireArea / (Hcnt)607            if self.debug:608                print("Hseq: {:.3f}".format(Hseg))609            wireAreaRed = wireArea - Hseg610            a=wireAreaRed+wireAreaRed*1j611            b=wireAreaRed-wireAreaRed*1j612            z = 0613            for i in range(1,self.heatOrder+1):614                w=1j*z.conjugate()615                z = numpy.array([w-a, z-b, z+a, b-w])/2616            z= z.flatten()617            X = [x.real for x in z]618            Y = [x.imag for x in z]619            heatPoints = []620            for i in range (0, len(X)):621                heatPoints.append(pya.DPoint(X[i], Y[i]))622            heatInitial = heatPoints[0]623            heatPoints.insert(0, pya.DPoint(heatPoints[0].x - 2*Hseg,\624                heatPoints[0].y))625            heatPoints.insert(0, pointLL)626            heatPoints.append(pya.DPoint(heatPoints[len(heatPoints)-1].x + 2*Hseg,\627                heatPoints[len(heatPoints)-1].y))628            heatPoints.append(pointUR)629            heatPath = pya.DPath(heatPoints, self.heatW)630            print("Electrical parameters:")631            heatThick = self.heatThick * 1E-9632            heatPerim = heatPath.perimeter()633            heatRes = self.heatRho * heatPerim / (heatThick*self.heatW)634            print("Overal lenght of the heater wire: {:.3e} um".format(heatPerim))635            print("Overal resistance of the heater wire: {:.3e} ohm".format(heatRes))636            Text += "heatLen: {:.3e} um \n". format(heatPerim)637            Text += "heatRes: {:.3e} ohm\n". format(heatRes)638            if self.roundPath:639                heatPathT = heatPath.round_corners(Hseg/2,32, 0.001)640                heatCenter = heatPathT.bbox().center()641                pathTr = pya.DCplxTrans(1, 270, False, 0.0, 0.0)642                if self.debug:643                    print("Rounded Path center: {}:{}".format(heatCenter.x, heatCenter.y))644                #pathTr = pya.DCplxTrans(-2*Hseg, 0)645                heatPathT = heatPathT.transformed(pathTr)646                647            else:648                heatCenter = heatPath.bbox().center()649                pathTr = pya.DCplxTrans(1, 270, False, 0.0, 0.0)650                #pathTr = pya.DCplxTrans(-heatCenter.x-2*Hseg, -heatCenter.y)651                #heatPathT = heatPath652                heatPathT = heatPath.transformed(pathTr)      653            654            self.cell.shapes(self.heatl_layer).insert(heatPathT)        655     656        if self.heatType == 1: #Meander 657            #Hilbert is defined only for square areas. We would fit whatever is smaller658            659            if self.debug:660                print("Heater type >> Meander")661            662            #Idea is that we would reuse the wirearea 663            wireArea = [activeArea[0]/2 + self.actOffset/2 -armWidth/2,\664                activeArea[1]/2 ]665            666            wireBox = pya.DBox(-wireArea[0], -wireArea[1],\667                wireArea[0], wireArea[1])668            if self.showAct:669                self.cell.shapes(self.la_layer).insert(wireBox)670            671            672            #lets try to get something like spacing 673            heatSp = self.heatSp674            segCnt = (wireArea[0]*2) / heatSp675            if self.debug:676                print("Segment count prior to decision point: {:.3f}".format(segCnt))677            #Hmmm and problems begins - we need strictly to be odd number of horizontal segments\678            # which is kinda a problem to solve>>679            k = round((segCnt-1)/2)680            #k = round((segCnt)/2)681            segCnt = k*2 + 1682            segStp = (wireArea[0]*2) / (segCnt-1)   683            684            if self.debug:685                print("Adjusted segment count : {}".format(segCnt))686            print("###Warning###: \n Spacing has been adjusted to {:.3f} from the {:.3f} to match the structure dimensions".format(segStp, heatSp))687            Text += "Type Meander: \nW {:3e}\nSP {:3e}um\n". format(self.heatW, segStp )688            heatPoints = []689            for step in range(0, int((segCnt+1)/2)):690                print("Step: {}".format(step)) 691                692                xpos = step * segStp693                if step != int((segCnt+1)/2)-1:694                    ypos = activeArea[1]/2 - self.heatW/2695                else:696                    ypos = size[1]/2697                if self.debug:698                    print("Calculating heater position: {}, {}".format(xpos, ypos))699                # so right hand rotation >>> firt poit is going up700                if step % 2 == 0:701                    if self.debug:702                        print("Even step")703                    pointA = pya.DPoint(xpos,   ypos)704                    pointB = pya.DPoint(-xpos, -ypos)705                    lastEven = True706                else:707                    if self.debug:708                        print("Odd step")709                    pointA = pya.DPoint(xpos, -ypos)710                    pointB = pya.DPoint(-xpos,  ypos)711                    lastEven = False712                print("Pass points {}, {}".format(pointA, pointB))713                heatPoints.insert(0, pointB)714                heatPoints.append(pointA)715                print("Pass heatpoints {}".format(heatPoints))716                # if roundcorners:717                #     da = math.pi / pts718                #     if step % 2 == 0:719                #         for a in range(pts, 0, -1):720                #             points.append([pointA[0]+spacing/2 * math.cos(a * da)+spacing/2, pointA[1]+spacing/2 * math.sin(a * da)])721                #         for a in range(0, pts):722                #             points.insert(0, [pointB[0]+spacing/2 * math.cos(-a * da)-spacing/2, pointB[1]+spacing/2 * math.sin(-a * da)])723                #     else:724                #         for a in range(pts, 0, -1):725                #             points.append([pointA[0]+spacing/2 * math.cos(-a * da)+spacing/2, pointA[1]+spacing/2 * math.sin(-a * da)])726                #         for a in range(0, pts):727                #             points.insert(0, [pointB[0]+spacing/2 * math.cos(a * da)-spacing/2, pointB[1]+spacing/2 * math.sin(a * da)])728                if step != int((segCnt+1)/2)-1:729                  pointAsep = pya.DPoint(pointA.x+segStp, pointA.y)730                  pointBsep = pya.DPoint(pointB.x-segStp, pointB.y)731                  heatPoints.insert(0, pointBsep)732                  heatPoints.append(pointAsep)733                else:734                  print("Last segment")735                  #heatPoints.insert(0, pointB)736                  #heatPoints.append(pointA)737                738                739            heatPath = pya.DPath(heatPoints, self.heatW)740            if heatPoints[0].y > 0.0:741                if self.debug:742                  print("Meander has to be mirrored!")743                pathTr = pya.DCplxTrans(1, 90, True, 0.0, 0.0)744                heatPath = heatPath.transformed(pathTr)745            else:746                pathTr = pya.DCplxTrans(1, 90, False, 0.0, 0.0)747                heatPath = heatPath.transformed(pathTr)748            if self.roundPath:749                heatPath = heatPath.round_corners(segStp/2,32, 0.001)750                # TODO: rounding causes last points to be for unknown reason ommited751                # some kind of workaround needed ... 752            if self.debug:753                print("overal lenght of the heater wire: {:.3f}".format(heatPath.perimeter()))754            self.cell.shapes(self.heatl_layer).insert(heatPath)755                # in certain cases the meander is formed in incompatible rotation756                # it would be more then usefull to rotate it insted of complete recalculation757                # of coordinates. 758            heatThick = self.heatThick * 1E-9759            heatPerim = heatPath.perimeter()760            heatRes = self.heatRho * heatPerim / (heatThick*self.heatW)761            print("Overal lenght of the heater wire: {:.3e} um".format(heatPerim))762            print("Overal resistance of the heater wire: {:.3e} ohm".format(heatRes))763            Text += "heatLen: {:.3e} um \n". format(heatPerim)764            Text += "heatRes: {:.3e} ohm\n". format(heatRes)765        if self.heatType == 2: #Meander Circle766            #Hilbert is defined only for square areas. We would fit whatever is smaller767            if self.debug:768                print("Heater type >> Meander Circular")769            770            #Idea is that we would reuse the wirearea 771            wireArea = [activeArea[0]/2 + self.actOffset/2 -armWidth/2,\772                activeArea[1]/2 ]773            774            wireBox = pya.DBox(-wireArea[0], -wireArea[1],\775                wireArea[0], wireArea[1])776            wireTr = pya.DCplxTrans(1, 90, False, 0.0, 0.0)777            wireBox = wireBox.transformed(wireTr)778            if self.showAct:779                self.cell.shapes(self.la_layer).insert(wireBox)780            781            782            #lets try to get something like spacing 783            heatSp = self.heatSp784            segCnt = (wireArea[0]*2) / heatSp785            if self.debug:786                print("Segment count prior to decision point: {:.3f}".format(segCnt))787            #Hmmm and problems begins - we need strictly to be odd number of horizontal segments\788            # which is kinda a problem to solve>>789            k = round((segCnt-1)/2)790            #k = round((segCnt)/2)791            segCnt = k*2 + 1792            segStp = (wireArea[0]*2) / (segCnt-1)   793            794            if self.debug:795                print("Adjusted segment count : {}".format(segCnt))796            print("###Warning###: \n Spacing has been adjusted to {:.3f} from the {:.3f} to match the structure dimensions".format(segStp, heatSp))797            heatPoints = []798            for step in range(0, int((segCnt+1)/2)):799                print("Step: {}".format(step)) 800                801                xpos = step * segStp802                if step != int((segCnt+1)/2)-1:803                    #ypos = activeArea[1]/2 - self.heatW/2804                    ypos = math.sqrt(abs((wireArea[0])**2 - xpos**2))805                else:806                    ypos = size[1]/2807                if self.debug:808                    print("Calculating heater position: {}, {}".format(xpos, ypos))809                # so right hand rotation >>> firt poit is going up810                if step % 2 == 0:811                    if self.debug:812                        print("Even step")813                    pointA = pya.DPoint(xpos,   ypos)814                    pointB = pya.DPoint(-xpos, -ypos)815                    lastEven = True816                else:817                    if self.debug:818                        print("Odd step")819                    pointA = pya.DPoint(xpos, -ypos)820                    pointB = pya.DPoint(-xpos,  ypos)821                    lastEven = False822                print("Pass points {}, {}".format(pointA, pointB))823                heatPoints.insert(0, pointB)824                heatPoints.append(pointA)825                print("Pass heatpoints {}".format(heatPoints))826                # if roundcorners:827                #     da = math.pi / pts828                #     if step % 2 == 0:829                #         for a in range(pts, 0, -1):830                #             points.append([pointA[0]+spacing/2 * math.cos(a * da)+spacing/2, pointA[1]+spacing/2 * math.sin(a * da)])831                #         for a in range(0, pts):832                #             points.insert(0, [pointB[0]+spacing/2 * math.cos(-a * da)-spacing/2, pointB[1]+spacing/2 * math.sin(-a * da)])833                #     else:834                #         for a in range(pts, 0, -1):835                #             points.append([pointA[0]+spacing/2 * math.cos(-a * da)+spacing/2, pointA[1]+spacing/2 * math.sin(-a * da)])836                #         for a in range(0, pts):837                #             points.insert(0, [pointB[0]+spacing/2 * math.cos(a * da)-spacing/2, pointB[1]+spacing/2 * math.sin(a * da)])838                if step != int((segCnt+1)/2)-1:839                  pointAsep = pya.DPoint(pointA.x+segStp, pointA.y)840                  pointBsep = pya.DPoint(pointB.x-segStp, pointB.y)841                  heatPoints.insert(0, pointBsep)842                  heatPoints.append(pointAsep)843                else:844                  print("Last segment")845                  #heatPoints.insert(0, pointB)846                  #heatPoints.append(pointA)847                848                849            heatPath = pya.DPath(heatPoints, self.heatW)850            if heatPoints[0].y > 0.0:851                if self.debug:852                  print("Meander has to be mirrored!")853                pathTr = pya.DCplxTrans(1, 90, True, 0.0, 0.0)854                heatPath = heatPath.transformed(pathTr)855            else:856                pathTr = pya.DCplxTrans(1, 90, False, 0.0, 0.0)857                heatPath = heatPath.transformed(pathTr)858            859            if self.roundPath:860                heatPath = heatPath.round_corners(segStp/2,32, 0.001)861                # TODO: rounding causes last points to be for unknown reason ommited862                # some kind of workaround needed ... 863            if self.debug:864                print("overal lenght of the heater wire: {:.3f}".format(heatPath.perimeter()))865            self.cell.shapes(self.heatl_layer).insert(heatPath)866                # in certain cases the meander is formed in incompatible rotation867                # it would be more then usefull to rotate it insted of complete recalculation868                # of coordinates. 869            heatThick = self.heatThick * 1E-9870            heatPerim = heatPath.perimeter()871            heatRes = self.heatRho * heatPerim / (heatThick*self.heatW)872            print("Overal lenght of the heater wire: {:.3e} um".format(heatPerim))873            print("Overal resistance of the heater wire: {:.3e} ohm".format(heatRes))874            Text += "heatLen: {:.3e} um \n". format(heatPerim)875            Text += "heatRes: {:.3e} ohm\n". format(heatRes)876        else:877            print("Wire definition has not been found!")878            #TODO ... other types of heaters879    if self.genWO:880        #we would make a wire connection from the P point to the edge of the membrane 881        # overpass on both sides as an option882        # it has to be realized as a set of the 4 path883        if self.debug:884            print("Wirouts for heater activated")885        woW = self.woW886        woParts = []887                888        woPath2 = pya.DPath([\889            pointUL,\890            pya.DPoint(-size[0]/2-memBMS[0], size[1]/2-armWidth/2),\891            pya.DPoint(-size[0]/2-memBMS[0], -ovSize[1]/2)], woW).round_corners(woW, 32, 0.001)  892        woParts.append(woPath2)893    894        woPath4 = pya.DPath([\895            pointLR,\896            pya.DPoint(size[0]/2+memBMS[0], -size[1]/2+armWidth/2),\897            pya.DPoint(size[0]/2+memBMS[0], ovSize[1]/2)], woW).round_corners(woW, 32, 0.001)  898        woParts.append(woPath4) 899        # 1 and 3 are measuremnt paths900        # woPath1 = pya.DPath([\901        #     pointUR,\902        #     pya.DPoint((size[0]-armWidth)/2, size[1]/2+memBMS[1]),\903        #     pya.DPoint(-ovSize[0]/2, size[1]/2+memBMS[1])], woW)904        # woParts.append(woPath1)905        # woPath3 = pya.DPath([\906        #     pointLL,\907        #     pya.DPoint((-size[0]+armWidth)/2, -size[1]/2-memBMS[1]),\908        #     pya.DPoint(ovSize[0]/2, -size[1]/2-memBMS[1])], woW)909        # woParts.append(woPath3)910        for member in woParts:911            self.cell.shapes(self.wol_layer).insert(member)     912    913    if self.genCnt:914        # Ok that would be fun ... 915        #   so at first we should be able to find how many of the IGC we would be able to fit916        #   in between of the perforations (maybe we should count also for the minimal separation)917        #   principally:918        #       single IGS pair consists of 2 wires and 2 gaps = IGSpairW?919        #       testing condition is therefore IGSCnt = floor((Hseg - perfW) / IGSpairW)920        cntW = self.cntW921        cntSp = self.cntSp922        cntB = self.cntB923        cntBunchW = 2*(cntW+cntSp)924        #Hseg = heatSp925        # if self.heatType == 0:926        #     cntCnt = math.floor((2*Hseg)/cntBunchW)927        # elif self.heatType == 1 or self.heatType == 2:928        #     cntCnt = math.floor(1)929        # else:930        #     cntCnt = 1931        # if self.debug:932        #     print("IDC W={}".format(cntBunchW))933        #     print("IDCs per bunch: {}".format(cntCnt))934        # if cntCnt == 0:935        #     print("Error: Interdigital contacts with given specs could not be realized because of geometric containts!")936        # else:937        #     #lets make a subcell with interdigital pair938        #     #   so first calculate the active area - contact bars to get the lenght939        #     #   contacts singles940        #     cntCell = self.layout.create_cell("IDC_subcell")941        #     cntArrCell = self.layout.create_cell("IDC_cell")942        #     #cntLenght = activeArea - 2*cntB - cntSp943        #     cntPath_p1 = pya.DPoint((cntSp+cntW)/2, activeArea[1]/2-cntB)944        #     cntPath_p2 = pya.DPoint((cntSp+cntW)/2, -activeArea[1]/2+cntSp+cntB) #TODO tohle je asi blbe ... 945        #     cntPath_pA =  [cntPath_p1, cntPath_p2]946        #     cntPath_pB =  [cntPath_p1 * -1, cntPath_p2 * -1]947            948        #     cntPath_A = pya.DPath(cntPath_pA, cntW, 0.0, 0.0)949        #     cntPath_B = pya.DPath(cntPath_pB, cntW, 0.0, 0.0)950        #     cntCell.shapes(self.idcl_layer).insert(cntPath_A)951        #     cntCell.shapes(self.idcl_layer).insert(cntPath_B)952        #     #now lets make bunches of cntCnt and center them 953        #     # TODO: tady jsem skoncil ... potreba projit odstavec pod954        #     #BEGIN955        #     x_vect = pya.DVector(cntBunchW, 0.0)956        #     y_vect = pya.DVector(0.0, 0.0)957        #     if self.debug:958        #         print("IDC bunch Vectors: {}, {}, {}, {}".format(\959        #             x_vect.x, x_vect.y, y_vect.x, y_vect.y))960        #     t = pya.DCplxTrans(0, 0)961        #     cntArr = pya.DCellInstArray(cntCell.cell_index(), t, x_vect, y_vect, cntCnt, 1)962            963        #     #center the origins on top of each other964        #     #   here we have a bunch of IDCs965        #     cntArr_center = cntArr.bbox(self.layout).center()966        #     if self.debug:967        #         print("Bunch center: {},{}".format(cntArr_center.x, cntArr_center.y))968        #     t=pya.DCplxTrans(1.0, 0, False, -cntArr_center.x, -cntArr_center.y)969        #     cntArr.transform(t)970        #     cntArrCell.insert(cntArr)971            972        #     #move the array to the position of Hilb. initial and paste it into the overal array973            974        #     a_vect = pya.DVector(self.heatSp, 0.0)975        #     b_vect = pya.DVector(0.0, 0.0)976        #     cntLoct = pya.DCplxTrans(1.0,0,False, 0.0, 0.0)977        #     cntArrAll = pya.DCellInstArray(cntArrCell.cell_index(), cntLoct, a_vect, b_vect, 5, 1)978        #     self.cell.insert(cntArrAll)979        #     #Top and bottom contact 980        #     #  by principle the bar-contact should be horizontally oriented across the active zone981        #     982            983        # Contact Bars984        cntBarW = self.cntB985        cntWoW = self.cntWO986        shapeSetCNT = []987        #cntBarA 988        shapeSetCNT.append(pya.DBox(-activeArea[0]/2, activeArea[1]/2-cntBarW,\989            activeArea[0]/2, activeArea[1]/2))990        #cntBarB991        shapeSetCNT.append(pya.DBox(-activeArea[0]/2, -activeArea[1]/2,\992            activeArea[0]/2, -activeArea[1]/2+cntBarW))993        # 1 and 3 are measuremnt paths994        woPath1 = pya.DPath([\995            pya.DPoint(pointUR.x, activeArea[1]/2),\996            pointUR,\997            pya.DPoint((size[0]-armWidth)/2, size[1]/2+memBMS[1]),\998            pya.DPoint(-ovSize[0]/2, size[1]/2+memBMS[1])], cntWoW).round_corners(cntWoW, 32, 0.001)    999        shapeSetCNT.append(woPath1)1000        woPath3 = pya.DPath([\1001            pya.DPoint(pointLL.x, -activeArea[1]/2),\1002            pointLL,\1003            pya.DPoint((-size[0]+armWidth)/2, -size[1]/2-memBMS[1]),\1004            pya.DPoint(ovSize[0]/2, -size[1]/2-memBMS[1])], cntWoW).round_corners(cntWoW, 32, 0.001)    1005        shapeSetCNT.append(woPath3)1006        for shape in shapeSetCNT:1007            self.cell.shapes(self.idcl_layer).insert(shape)1008    #     #     #Vias 1009    #     #     #TODO: repair position of the vias1010    #     #     cntViaW = cntWoW * 0.9/2 # 10% smaller then the wire1011    #     #     tr = pya.DCplxTrans(1.0, 45.0, False, pya.DVector(pointP))1012    #     #     cntViaA = pya.DPolygon(pya.DBox(-cntViaW, -cntViaW,\1013    #     #         cntViaW, cntViaW)).transform(tr)1014    #     #     tr = pya.DCplxTrans(1.0, 45.0, False, pya.DVector(-pointP))1015    #     #     cntViaB = pya.DPolygon(pya.DBox(-cntViaW, -cntViaW,\1016    #     #         cntViaW, cntViaW)).transformed(tr)1017    #     #     self.cell.shapes(self.lvia_layer).insert(cntViaA)1018    #     #     self.cell.shapes(self.lvia_layer).insert(cntViaB) 1019    if self.printInfo:1020        # Text = "Info:\n"1021        # Text += "OvArea {:.3f}, {:.3f} um". format(ovSize[0], ovSize[1])1022        # Text += "ActiveArea {:.3f}, {:.3f} um". format(activeArea[0], activeArea[1])1023        # Text += "ActiveArea {:.3f}, {:.3f} um". format(activeArea[0], activeArea[1])1024        print("TextMarker")1025        print(Text)1026        textMark = pya.DText(Text, ovSize[0]/2, -ovSize[1]/2)1027        self.cell.shapes(self.ld_layer).insert(textMark)1028        1029class CEITEC_TESTS(pya.Library):1030  def __init__(self):1031    # TODO: change the description1032    self.description = "CEITEC_Tests"1033    # register the PCell declarations1034    # TODO: change the names1035    #self.layout().register_pcell("MicroHotPlate", MicroHotPlateSensor())1036    self.layout().register_pcell("MicroHotPlateHK", MicroHotPlateSensorHK())1037    # TODO: register more PCell declarations1038    # register our library with the name "PCellLib"1039    # TODO: change the library name1040    self.register("CEITEC_TESTS")1041# class CEITEC_Basic(pya.Library):1042#   def __init__(self):1043#     # TODO: change the description1044#     self.description = "CEITEC_Basic"1045#     # register the PCell declarations1046#     # TODO: change the names1047#     self.layout().register_pcell("ShapeAreaFill", ShapeAreaFill())1048#     # TODO: register more PCell declarations1049#     # register our library with the name "PCellLib"1050#     # TODO: change the library name1051#     self.register("CEITEC_Basic")1052# CEITEC_Electrical()1053# CEITEC_Basic()...PostProcess3.py
Source:PostProcess3.py  
1#Calculate monthly and annual building performance metrics2import random3import sys4import os5import numpy6import matplotlib.pyplot as plt7import matplotlib.dates as mdates89#Define file names1011fileName1 = "Output/Perf-Metrics-Case-8-Jan.txt"12fileName2 = "Output/Perf-Metrics-Case-8-Feb.txt"13fileName3 = "Output/Perf-Metrics-Case-8-Mar.txt"14fileName4 = "Output/Perf-Metrics-Case-8-Apr.txt"15fileName5 = "Output/Perf-Metrics-Case-8-May.txt"16fileName6 = "Output/Perf-Metrics-Case-8-Jun.txt"17fileName7 = "Output/Perf-Metrics-Case-8-Jul.txt"18fileName8 = "Output/Perf-Metrics-Case-8-Aug.txt"19fileName9 = "Output/Perf-Metrics-Case-8-Sep.txt"20fileName10 = "Output/Perf-Metrics-Case-8-Oct.txt"21fileName11 = "Output/Perf-Metrics-Case-8-Nov.txt"22fileName12 = "Output/Perf-Metrics-Case-8-Dec.txt"2324#Load all data in a matrix25data1 = numpy.loadtxt(fileName1)2627TotalSensHeatDemand1 = data1[0]28TotalGasConsumpHeat1 = data1[1]29TotalElecHeatDemand1 = data1[2]30TotalSensCoolDemand1 = data1[3]31TotalElecCoolDemand1 = data1[4]32TotalSensWaterHeatDemand1 = data1[5]33TotalGasConsumpWaterHeat1 = data1[6]34TotalElecDomesticDemand1 = data1[7]35TotalElecProducedPV1 = data1[8]36TotalElecProducedWT1 = data1[9]3738data2 = numpy.loadtxt(fileName2)3940TotalSensHeatDemand2 = data2[0]41TotalGasConsumpHeat2 = data2[1]42TotalElecHeatDemand2 = data2[2]43TotalSensCoolDemand2 = data2[3]44TotalElecCoolDemand2 = data2[4]45TotalSensWaterHeatDemand2 = data2[5]46TotalGasConsumpWaterHeat2 = data2[6]47TotalElecDomesticDemand2 = data2[7]48TotalElecProducedPV2 = data2[8]49TotalElecProducedWT2 = data2[9]5051data3 = numpy.loadtxt(fileName3)5253TotalSensHeatDemand3 = data3[0]54TotalGasConsumpHeat3 = data3[1]55TotalElecHeatDemand3 = data3[2]56TotalSensCoolDemand3 = data3[3]57TotalElecCoolDemand3 = data3[4]58TotalSensWaterHeatDemand3 = data3[5]59TotalGasConsumpWaterHeat3 = data3[6]60TotalElecDomesticDemand3 = data3[7]61TotalElecProducedPV3 = data3[8]62TotalElecProducedWT3 = data3[9]6364data4 = numpy.loadtxt(fileName4)6566TotalSensHeatDemand4 = data4[0]67TotalGasConsumpHeat4 = data4[1]68TotalElecHeatDemand4 = data4[2]69TotalSensCoolDemand4 = data4[3]70TotalElecCoolDemand4 = data4[4]71TotalSensWaterHeatDemand4 = data4[5]72TotalGasConsumpWaterHeat4 = data4[6]73TotalElecDomesticDemand4 = data4[7]74TotalElecProducedPV4 = data4[8]75TotalElecProducedWT4 = data4[9]7677data5 = numpy.loadtxt(fileName5)7879TotalSensHeatDemand5 = data5[0]80TotalGasConsumpHeat5 = data5[1]81TotalElecHeatDemand5 = data5[2]82TotalSensCoolDemand5 = data5[3]83TotalElecCoolDemand5 = data5[4]84TotalSensWaterHeatDemand5 = data5[5]85TotalGasConsumpWaterHeat5 = data5[6]86TotalElecDomesticDemand5 = data5[7]87TotalElecProducedPV5 = data5[8]88TotalElecProducedWT5 = data5[9]8990data6 = numpy.loadtxt(fileName6)9192TotalSensHeatDemand6 = data6[0]93TotalGasConsumpHeat6 = data6[1]94TotalElecHeatDemand6 = data6[2]95TotalSensCoolDemand6 = data6[3]96TotalElecCoolDemand6 = data6[4]97TotalSensWaterHeatDemand6 = data6[5]98TotalGasConsumpWaterHeat6 = data6[6]99TotalElecDomesticDemand6 = data6[7]100TotalElecProducedPV6 = data6[8]101TotalElecProducedWT6 = data6[9]102103data7 = numpy.loadtxt(fileName7)104105TotalSensHeatDemand7 = data7[0]106TotalGasConsumpHeat7 = data7[1]107TotalElecHeatDemand7 = data7[2]108TotalSensCoolDemand7 = data7[3]109TotalElecCoolDemand7 = data7[4]110TotalSensWaterHeatDemand7 = data7[5]111TotalGasConsumpWaterHeat7 = data7[6]112TotalElecDomesticDemand7 = data7[7]113TotalElecProducedPV7 = data7[8]114TotalElecProducedWT7 = data7[9]115116data8 = numpy.loadtxt(fileName8)117118TotalSensHeatDemand8 = data8[0]119TotalGasConsumpHeat8 = data8[1]120TotalElecHeatDemand8 = data8[2]121TotalSensCoolDemand8 = data8[3]122TotalElecCoolDemand8 = data8[4]123TotalSensWaterHeatDemand8 = data8[5]124TotalGasConsumpWaterHeat8 = data8[6]125TotalElecDomesticDemand8 = data8[7]126TotalElecProducedPV8 = data8[8]127TotalElecProducedWT8 = data8[9]128129data9 = numpy.loadtxt(fileName9)130131TotalSensHeatDemand9 = data9[0]132TotalGasConsumpHeat9 = data9[1]133TotalElecHeatDemand9 = data9[2]134TotalSensCoolDemand9 = data9[3]135TotalElecCoolDemand9 = data9[4]136TotalSensWaterHeatDemand9 = data9[5]137TotalGasConsumpWaterHeat9 = data9[6]138TotalElecDomesticDemand9 = data9[7]139TotalElecProducedPV9 = data9[8]140TotalElecProducedWT9 = data9[9]141142data10 = numpy.loadtxt(fileName10)143144TotalSensHeatDemand10 = data10[0]145TotalGasConsumpHeat10 = data10[1]146TotalElecHeatDemand10 = data10[2]147TotalSensCoolDemand10 = data10[3]148TotalElecCoolDemand10 = data10[4]149TotalSensWaterHeatDemand10 = data10[5]150TotalGasConsumpWaterHeat10 = data10[6]151TotalElecDomesticDemand10 = data10[7]152TotalElecProducedPV10 = data10[8]153TotalElecProducedWT10 = data10[9]154155data11 = numpy.loadtxt(fileName11)156157TotalSensHeatDemand11 = data11[0]158TotalGasConsumpHeat11 = data11[1]159TotalElecHeatDemand11 = data11[2]160TotalSensCoolDemand11 = data11[3]161TotalElecCoolDemand11 = data11[4]162TotalSensWaterHeatDemand11 = data11[5]163TotalGasConsumpWaterHeat11 = data11[6]164TotalElecDomesticDemand11 = data11[7]165TotalElecProducedPV11 = data11[8]166TotalElecProducedWT11 = data11[9]167168data12 = numpy.loadtxt(fileName12)169170TotalSensHeatDemand12 = data12[0]171TotalGasConsumpHeat12 = data12[1]172TotalElecHeatDemand12 = data12[2]173TotalSensCoolDemand12 = data12[3]174TotalElecCoolDemand12 = data12[4]175TotalSensWaterHeatDemand12 = data12[5]176TotalGasConsumpWaterHeat12 = data12[6]177TotalElecDomesticDemand12 = data12[7]178TotalElecProducedPV12 = data12[8]179TotalElecProducedWT12 = data12[9]180181AnnualTotalSensHeatDemand = TotalSensHeatDemand1+TotalSensHeatDemand2+TotalSensHeatDemand3+TotalSensHeatDemand4+TotalSensHeatDemand5+ \182               TotalSensHeatDemand6+TotalSensHeatDemand7+TotalSensHeatDemand8+TotalSensHeatDemand9+TotalSensHeatDemand10+ \183               TotalSensHeatDemand11+TotalSensHeatDemand12184185AnnualTotalGasConsumpHeat = TotalGasConsumpHeat1+TotalGasConsumpHeat2+TotalGasConsumpHeat3+TotalGasConsumpHeat4+TotalGasConsumpHeat5+ \186               TotalGasConsumpHeat6+TotalGasConsumpHeat7+TotalGasConsumpHeat8+TotalGasConsumpHeat9+TotalGasConsumpHeat10+ \187               TotalGasConsumpHeat11+TotalGasConsumpHeat12188189AnnualTotalElecHeatDemand = TotalElecHeatDemand1+TotalElecHeatDemand2+TotalElecHeatDemand3+TotalElecHeatDemand4+TotalElecHeatDemand5+ \190               TotalElecHeatDemand6+TotalElecHeatDemand7+TotalElecHeatDemand8+TotalElecHeatDemand9+TotalElecHeatDemand10+ \191               TotalElecHeatDemand11+TotalElecHeatDemand12192193AnnualTotalSensCoolDemand = TotalSensCoolDemand1+TotalSensCoolDemand2+TotalSensCoolDemand3+TotalSensCoolDemand4+TotalSensCoolDemand5+ \194               TotalSensCoolDemand6+TotalSensCoolDemand7+TotalSensCoolDemand8+TotalSensCoolDemand9+TotalSensCoolDemand10+ \195               TotalSensCoolDemand11+TotalSensCoolDemand12196197AnnualTotalElecCoolDemand = TotalElecCoolDemand1+TotalElecCoolDemand2+TotalElecCoolDemand3+TotalElecCoolDemand4+TotalElecCoolDemand5+ \198               TotalElecCoolDemand6+TotalElecCoolDemand7+TotalElecCoolDemand8+TotalElecCoolDemand9+TotalElecCoolDemand10+ \199               TotalElecCoolDemand11+TotalElecCoolDemand12200201AnnualTotalSensWaterHeatDemand = TotalSensWaterHeatDemand1+TotalSensWaterHeatDemand2+TotalSensWaterHeatDemand3+TotalSensWaterHeatDemand4+TotalSensWaterHeatDemand5+ \202               TotalSensWaterHeatDemand6+TotalSensWaterHeatDemand7+TotalSensWaterHeatDemand8+TotalSensWaterHeatDemand9+TotalSensWaterHeatDemand10+ \203               TotalSensWaterHeatDemand11+TotalSensWaterHeatDemand12204205AnnualTotalGasConsumpWaterHeat = TotalGasConsumpWaterHeat1+TotalGasConsumpWaterHeat2+TotalGasConsumpWaterHeat3+TotalGasConsumpWaterHeat4+TotalGasConsumpWaterHeat5+ \206               TotalGasConsumpWaterHeat6+TotalGasConsumpWaterHeat7+TotalGasConsumpWaterHeat8+TotalGasConsumpWaterHeat9+TotalGasConsumpWaterHeat10+ \207               TotalGasConsumpWaterHeat11+TotalGasConsumpWaterHeat12208209AnnualTotalElecDomesticDemand = TotalElecDomesticDemand1+TotalElecDomesticDemand2+TotalElecDomesticDemand3+TotalElecDomesticDemand4+TotalElecDomesticDemand5+ \210               TotalElecDomesticDemand6+TotalElecDomesticDemand7+TotalElecDomesticDemand8+TotalElecDomesticDemand9+TotalElecDomesticDemand10+ \211               TotalElecDomesticDemand11+TotalElecDomesticDemand12212213AnnualTotalElecProducedPV = TotalElecProducedPV1+TotalElecProducedPV2+TotalElecProducedPV3+TotalElecProducedPV4+TotalElecProducedPV5+ \214               TotalElecProducedPV6+TotalElecProducedPV7+TotalElecProducedPV8+TotalElecProducedPV9+TotalElecProducedPV10+ \215               TotalElecProducedPV11+TotalElecProducedPV12216217AnnualTotalElecProducedWT = TotalElecProducedWT1+TotalElecProducedWT2+TotalElecProducedWT3+TotalElecProducedWT4+TotalElecProducedWT5+ \218               TotalElecProducedWT6+TotalElecProducedWT7+TotalElecProducedWT8+TotalElecProducedWT9+TotalElecProducedWT10+ \219               TotalElecProducedWT11+TotalElecProducedWT12220221AnnualTotalGasConsump = AnnualTotalGasConsumpHeat + AnnualTotalGasConsumpWaterHeat222AnnualTotalNetElec = AnnualTotalElecHeatDemand + AnnualTotalElecCoolDemand + AnnualTotalElecDomesticDemand - \223    AnnualTotalElecProducedPV - AnnualTotalElecProducedWT224225#Print results to screen "LaTeX Ready"226print("TotalSensHeatDemand: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \227            % (TotalSensHeatDemand1, TotalSensHeatDemand2, TotalSensHeatDemand3, TotalSensHeatDemand4, TotalSensHeatDemand5,228               TotalSensHeatDemand6, TotalSensHeatDemand7, TotalSensHeatDemand8, TotalSensHeatDemand9, TotalSensHeatDemand10,229               TotalSensHeatDemand11, TotalSensHeatDemand12, AnnualTotalSensHeatDemand))230231print("TotalGasConsumpHeat: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \232            % (TotalGasConsumpHeat1, TotalGasConsumpHeat2, TotalGasConsumpHeat3, TotalGasConsumpHeat4, TotalGasConsumpHeat5,233               TotalGasConsumpHeat6, TotalGasConsumpHeat7, TotalGasConsumpHeat8, TotalGasConsumpHeat9, TotalGasConsumpHeat10,234               TotalGasConsumpHeat11, TotalGasConsumpHeat12, AnnualTotalGasConsumpHeat))235236print("TotalElecHeatDemand: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \237            % (TotalElecHeatDemand1, TotalElecHeatDemand2, TotalElecHeatDemand3, TotalElecHeatDemand4, TotalElecHeatDemand5,238               TotalElecHeatDemand6, TotalElecHeatDemand7, TotalElecHeatDemand8, TotalElecHeatDemand9, TotalElecHeatDemand10,239               TotalElecHeatDemand11, TotalElecHeatDemand12, AnnualTotalElecHeatDemand))240241print("TotalSensCoolDemand: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \242            % (TotalSensCoolDemand1, TotalSensCoolDemand2, TotalSensCoolDemand3, TotalSensCoolDemand4, TotalSensCoolDemand5,243               TotalSensCoolDemand6, TotalSensCoolDemand7, TotalSensCoolDemand8, TotalSensCoolDemand9, TotalSensCoolDemand10,244               TotalSensCoolDemand11, TotalSensCoolDemand12, AnnualTotalSensCoolDemand))245246print("TotalElecCoolDemand: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \247            % (TotalElecCoolDemand1, TotalElecCoolDemand2, TotalElecCoolDemand3, TotalElecCoolDemand4, TotalElecCoolDemand5,248               TotalElecCoolDemand6, TotalElecCoolDemand7, TotalElecCoolDemand8, TotalElecCoolDemand9, TotalElecCoolDemand10,249               TotalElecCoolDemand11, TotalElecCoolDemand12, AnnualTotalElecCoolDemand))250251print("TotalSensWaterHeatDemand: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \252            % (TotalSensWaterHeatDemand1, TotalSensWaterHeatDemand2, TotalSensWaterHeatDemand3, TotalSensWaterHeatDemand4, TotalSensWaterHeatDemand5,253               TotalSensWaterHeatDemand6, TotalSensWaterHeatDemand7, TotalSensWaterHeatDemand8, TotalSensWaterHeatDemand9, TotalSensWaterHeatDemand10,254               TotalSensWaterHeatDemand11, TotalSensWaterHeatDemand12, AnnualTotalSensWaterHeatDemand))255256print("TotalGasConsumpWaterHeat: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \257            % (TotalGasConsumpWaterHeat1, TotalGasConsumpWaterHeat2, TotalGasConsumpWaterHeat3, TotalGasConsumpWaterHeat4, TotalGasConsumpWaterHeat5,258               TotalGasConsumpWaterHeat6, TotalGasConsumpWaterHeat7, TotalGasConsumpWaterHeat8, TotalGasConsumpWaterHeat9, TotalGasConsumpWaterHeat10,259               TotalGasConsumpWaterHeat11, TotalGasConsumpWaterHeat12, AnnualTotalGasConsumpWaterHeat))260261print("TotalElecDomesticDemand: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \262            % (TotalElecDomesticDemand1, TotalElecDomesticDemand2, TotalElecDomesticDemand3, TotalElecDomesticDemand4, TotalElecDomesticDemand5,263               TotalElecDomesticDemand6, TotalElecDomesticDemand7, TotalElecDomesticDemand8, TotalElecDomesticDemand9, TotalElecDomesticDemand10,264               TotalElecDomesticDemand11, TotalElecDomesticDemand12, AnnualTotalElecDomesticDemand))265266print("TotalElecProducedPV: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \267            % (TotalElecProducedPV1, TotalElecProducedPV2, TotalElecProducedPV3, TotalElecProducedPV4, TotalElecProducedPV5,268               TotalElecProducedPV6, TotalElecProducedPV7, TotalElecProducedPV8, TotalElecProducedPV9, TotalElecProducedPV10,269               TotalElecProducedPV11, TotalElecProducedPV12, AnnualTotalElecProducedPV))270271print("TotalElecProducedWT: %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f & %5.2f" \272            % (TotalElecProducedWT1, TotalElecProducedWT2, TotalElecProducedWT3, TotalElecProducedWT4, TotalElecProducedWT5,273               TotalElecProducedWT6, TotalElecProducedWT7, TotalElecProducedWT8, TotalElecProducedWT9, TotalElecProducedWT10,274               TotalElecProducedWT11, TotalElecProducedWT12, AnnualTotalElecProducedWT))275276print("AnnualTotalGasConsump and AnnualTotalNetElec: %5.2f & %5.2f " \
...weight_renderer.py
Source:weight_renderer.py  
1import os2import numpy as np3import cv24import torch5PTH_DATA_PATH = "../models/"6SAVE_PATH = "../models/model_images/"7def plot_weight(pth_data_path, save_path, shape_name, diff):8    if not diff:9        name = shape_name[0]10        data = torch.load(f'{pth_data_path}{name}.pth')11        i = 012        for k, v in data.items():13            if i % 3 == 2:14                v = v.cpu().numpy()15                max_norm = np.max(np.abs(v))16                heat_map = v / max_norm * 127.5 + 127.517                heat_map = np.uint8(heat_map)18                heat_map = cv2.applyColorMap(heat_map, cv2.COLORMAP_JET)19                # Scale20                # heat_map = cv2.resize(heat_map, (map_size[0]*4, map_size[1]*4), interpolation=cv2.INTER_NEAREST)21                cv2.imwrite(f'{save_path}{name}_{i // 3 + 1}.png', heat_map)22                print(f'Heatmap path = {save_path}{name}_{i // 3 + 1}.png')23            i = i + 124    else:25        name_1 = shape_name[0]26        name_2 = shape_name[1]27        data1 = torch.load(f'{pth_data_path}{name_1}.pth')28        data2 = torch.load(f'{pth_data_path}{name_2}.pth')29        items1 = list(data1.items())30        items2 = list(data2.items())31        for i in range(len(data1)):32            if i % 3 == 2:33                k1, v1 = items1[i]34                k2, v2 = items2[i]35                v1 = v1.cpu().numpy()36                # print(v1, flush=True)37                v2 = v2.cpu().numpy()38                # print(v2, flush=True)39                result = v1 - v240                # print(result, flush=True)41                max_norm = np.max(np.abs(result))42                heat_map = result / max_norm * 127.5 + 127.543                heat_map = np.uint8(heat_map)44                heat_map = cv2.applyColorMap(heat_map, cv2.COLORMAP_JET)45                # Scale46                # heat_map = cv2.resize(heat_map, (map_size[0]*4, map_size[1]*4), interpolation=cv2.INTER_NEAREST)47                cv2.imwrite(f'{save_path}{name_1}_{name_2}_{i // 3 + 1}.png', heat_map)48                print(f'Heatmap path = {save_path}{name_1}_{name_2}_{i // 3 + 1}.png')49if __name__ == '__main__':50    difference = True51    name = []52    print('Enter shape name:')53    name.append(input())54    if difference:55        print('Enter another shape name:')56        name.append(input())57    print('Plotting results...')58    plot_weight(PTH_DATA_PATH, SAVE_PATH, name, difference)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
