Ejemplo n.º 1
0
 def CompareTwoCellsComments(address1,key1,address2,key2,threshold,outputname, outputname2, outputname3):
     preCB = XMLinterpreter(address1)
     preAC = XMLinterpreter(address2)
     condition  = [True, True, False, False]
     CB = CellCointainer(preCB, condition)
     AC = CellCointainer(preAC, condition)
     comments1 = CB.commentWithKeywordExtract(key1)
     comments2 = AC.commentWithKeywordExtract(key2)
     comments1.sort(key = lambda x:x[1])
     comments2.sort(key = lambda x:x[1])
     comments1a = XMLutility.sortNodes(comments1)
     CBAC =XMLutility.compareTwoCellForFirst(CB.scale,comments1, comments2, threshold, 1)
     CBACsorted =XMLutility.sortNodes(CBAC)
     
    # CBACsorted = XMLutility.dictToCluster(CBACsorted, 200)
     CBACsorted1 =XMLutility.DLtoDDtoDCL(CBAC,200)
     XMLutility.TempCvsCprinter(comments1a, CBACsorted1, outputname, key1)
     
     XMLutility.TempCvsCgrapher(comments1a, CBACsorted1)
     
     #print CBACsorted
     with open(outputname2, 'wt') as out:
         pprint.pprint(CBACsorted1, stream=out)
         
     printCBAC = XMLutility.XMLTempPrinter(CB.Parameter, CBACsorted, outputname3)
Ejemplo n.º 2
0
 def CompareTwoCellsNodeAndPrintMidPoint(address1, address2, threshold, outputname):
     preCB = XMLinterpreter(address1)
     preAC = XMLinterpreter(address2)
     condition  = [True, False, False, False]
     CB = CellCointainer(preCB, condition)
     AC = CellCointainer(preAC, condition)
     
     CBAC =XMLutility.compareTwoCellandReturnMidPoint(CB.allNodesExtract(1), AC.allNodesExtract(1), threshold, 1)
     CBACsorted =XMLutility.sortNodes(CBAC)
     #print CBACsorted
     CBACsorted = XMLutility.dictToCluster(CBACsorted, 200)
     printCBAC = XMLutility.XMLTempPrinter1(CB.Parameter, CBACsorted, outputname)
     print CBACsorted
Ejemplo n.º 3
0
 def CompareTwoCellsCommentsAndChangeComment(address1,key1,address2,key2,threshold,filename):
     preCB = XMLinterpreter(address1)
     preAC = XMLinterpreter(address2)
     condition  = [True, True, True, True]
     CB = CellCointainer(preCB, condition)
     AC = CellCointainer(preAC, condition)
     comments1 = CB.commentWithKeywordExtract(key1)
     comments2 = AC.commentWithKeywordExtract(key2)
     comments1.sort(key = lambda x:x[1])
     comments2.sort(key = lambda x:x[1])
     
     CBAC =XMLutility.commentChanger(CB.scale,comments1, comments2, threshold)
     CBACsorted =XMLutility.sortNodes(CBAC)
     CB.Comments = CBACsorted
     XMLutility.CellPrinter(CB, filename)#
Ejemplo n.º 4
0
 def CompareTwoCellsCommentAndEdgeAndPrint(address1, address2, threshold, outputname, *args):
     preCB = XMLinterpreter(address1)
     preAC = XMLinterpreter(address2)
     condition  = [True, True, True, False]
     CB = CellCointainer(preCB, condition)
     AC = CellCointainer(preAC, condition)
     comments = CB.commentWithKeywordExtract(*args)
     comments.sort(key = lambda x:x[1])
     edges = AC.allEdgesExtract(1)
     
     
     CBAC =XMLutility.compareTwoCellandReturnMidPoint(comments, edges, threshold, 1)
     CBACsorted =XMLutility.sortNodes(CBAC)
     CBACsorted = XMLutility.dictToCluster(CBACsorted, threshold)
     printCBAC = XMLutility.XMLTempPrinter1(CB.Parameter, CBACsorted, outputname)
Ejemplo n.º 5
0
    def Transformation2(self,addressTop, addressBot, victimCellss):
        condition = [True, True, True, True]
        preCelltop = XMLinterpreter(addressTop)
        Celltop = CellCointainer(preCelltop, condition)
        Nodestop= Celltop.allNodesExtract(0)

        preCellbot = XMLinterpreter(addressBot)
        Cellbot = CellCointainer(preCellbot, condition)
        Nodesbot= Cellbot.allNodesExtract(0)
        
        coef = Transformation.getPlaneCoef2(Nodestop)
        
        Nodestop = Transformation.convertCoord(coef, Nodestop)
        Nodesbot = Transformation.convertCoord(coef, Nodesbot)
        
        topX = Transformation.getAvgPoint(Nodestop)[2]
        botX = Transformation.getAvgPoint(Nodesbot)[2]
Ejemplo n.º 6
0
    def Transformation(addressTop, addressBot, cutterCells, victimCells):
        condition = [True, True, True, True]
        preCelltop = XMLinterpreter(addressTop)
        Celltop = CellCointainer(preCelltop, condition)
        Nodestop= Celltop.allNodesExtract(0)

        preCellbot = XMLinterpreter(addressBot)
        Cellbot = CellCointainer(preCellbot, condition)
        Nodesbot= Cellbot.allNodesExtract(0)
        
        coef = Transformation.getPlaneCoef2(Nodestop)
        
        Nodestop = Transformation.convertCoord(coef, Nodestop)
        Nodesbot = Transformation.convertCoord(coef, Nodesbot)
        
        topX = Transformation.getAvgPoint(Nodestop)[2]
        botX = Transformation.getAvgPoint(Nodesbot)[2]
        
        preCellcut = XMLinterpreter(cutterCells)
        Cellcut = CellCointainer(preCellcut, condition)
        Nodescut= Cellcut.Nodes  #dictionary
        
        preCellvic = XMLinterpreter(victimCells)
        Cellvic = CellCointainer(preCellvic, condition)
        Nodesvic= Cellvic.Nodes #dictionary
        
        #Nodesvic = Cellvic.commentWithKeywordExtractDict("ibbon")
        
        ###
        #NodesvicAid = Cellvic.Nodes
        ###
       
        
        #DicNodesCCells = {}
        #for item1 in Nodescut.keys():
        #    DicNodesCCells.setdefault(item1)
        #    temp = Transformation.convertCoord(coef, Nodescut[item1])
        #    
        #    DicNodesCCells[item1] = temp
        
        DicNodesVCells = {}
        
        for item2 in Nodesvic.keys():
            DicNodesVCells.setdefault(item2)
            temp1 = Transformation.convertCoord(coef, Nodesvic[item2])
            
            DicNodesVCells[item2] = temp1
            
            """##
        DicNodesVaidCells = {}
        
        for item3 in Nodesvic.keys(): 
            DicNodesVaidCells.setdefault(item3)
            temp2 = Transformation.convertCoord(coef, NodesvicAid[item3])
            
            DicNodesVaidCells[item3] = temp2
           
        
       
        for item4 in DicNodesVCells.keys():
            
            aEllipse = Covariance.toEllipse(DicNodesVCells[item4])
            
            cellcorX = Transformation.getAvgPoint(DicNodesVCells[item4])[2]
            Relength2 = (topX - cellcorX)/(topX - botX)
            
            
            plt.scatter( Relength2  , CONF95 * pi * aEllipse[2] * aEllipse[3])
        
        show()
        
        #cutVal = Transformation.findMin(DicNodesCCells)
        #DicNodesVCells = Transformation.cutCellX(DicNodesVCells, cutVal)
        
        """
        ells = []
        
        for item3 in DicNodesVCells.keys():
                       
            cellcorX = Transformation.getAvgPoint(DicNodesVCells[item3])[2]
            Relength2 = (topX - cellcorX)/(topX - botX)
            
            if Relength2 > 1.15:
                continue #showing mosaic bigger than 1.15
            
            aEllipse = Covariance.toEllipse(DicNodesVCells[item3])
            
            #output [ycor zcor Principle1 Principle2 Angle cellname]
           
            temparr = []            
            
            xcordz = aEllipse[0]
            ycordz = aEllipse[1]
            widthz = aEllipse[2] * 2 * math.sqrt(CONF95) #
            heightz = aEllipse[3] * 2 * math.sqrt(CONF95)  #  
            anglez = aEllipse[4]
            
            xyz = []
            xyz.append(xcordz)
            xyz.append(ycordz)
            
            temparr.append(Ellipse(xy =xyz, width =widthz, height= heightz, angle = anglez * 180/ pi )) 
            temparr.append(xyz)
            temparr.append(item3)
            ells.append(temparr)
            
            
            
        fig = figure()
        ax = fig.add_subplot(111, aspect='equal')
        
        for e in ells:
            ax.add_artist(e[0])
            e[0].set_clip_box(ax.bbox)
            e[0].set_alpha(rand())
            e[0].set_facecolor(rand(3))
            plt.text(e[1][0], e[1][1], e[2], ha="center", family='sans-serif', size=14)
            
        
        ax.set_xlim(-100000,200000)
        ax.set_ylim(000000,200000)
        show()
Ejemplo n.º 7
0
    def areaVSrelength(addressTop, addressBot, victimCells):
        condition = [True, True, True, True]
        preCelltop = XMLinterpreter(addressTop)
        Celltop = CellCointainer(preCelltop, condition)
        Nodestop= Celltop.allNodesExtract(0)

        preCellbot = XMLinterpreter(addressBot)
        Cellbot = CellCointainer(preCellbot, condition)
        Nodesbot= Cellbot.allNodesExtract(0)
        
        coef = Transformation.getPlaneCoef2(Nodestop)
        
        Nodestop = Transformation.convertCoord(coef, Nodestop)
        Nodesbot = Transformation.convertCoord(coef, Nodesbot)
        
        topX = Transformation.getAvgPoint(Nodestop)[2]
        botX = Transformation.getAvgPoint(Nodesbot)[2]
        

        
        preCellvic = XMLinterpreter(victimCells)
        Cellvic = CellCointainer(preCellvic, condition)
        
        Nodesvic= Cellvic.commentWithKeywordExtractDict("utput") #dictionary// smaller
        print Nodesvic
        #Nodesvic = Cellvic.Nodes
        NodesvicAid = Cellvic.Nodes
        
        DicNodesVCells = {}
        DicNodesVaidCells = {}
        DicNodesError = {}
        ells = [] 
               
        for item1 in Nodesvic.keys():
            DicNodesVCells.setdefault(item1)
            
            temp1 = Transformation.convertCoord(coef, Nodesvic[item1])
            
            #temp1 = Transformation.convertCoord(coef, Transformation.cutCell2(Nodesvic[item2], 0.25, 0.75))
            
            cellcorX = Transformation.getAvgPoint(temp1)[2]
            Relength2 = (topX - cellcorX)/(topX - botX)
            DicNodesVCells[item1] = Relength2
            
            DicNodesError.setdefault(item1)
            
            stdev = Transformation.stdev1D(temp1)
            stdev = stdev/(topX-botX)
            DicNodesError[item1] = stdev
            
            
            
            DicNodesVaidCells.setdefault(item1)
            temp2 = Transformation.convertCoord(coef, NodesvicAid[item1])
            #temp2 = temp1
            
            aEllipse = Covariance.toEllipse(temp2)
            DicNodesVaidCells[item1] = CONF95 * pi * aEllipse[2] * aEllipse[3]
            
            #if DicNodesVCells[item1] < 1.2:
            #    continue #showing mosaic bigger than 1.15            
            

            aEllipse = Covariance.toEllipse(temp2)
            
            #output [ycor zcor Principle1 Principle2 Angle cellname]
           
            temparr = []            
            
            xcordz = aEllipse[0]
            ycordz = aEllipse[1]
            widthz = aEllipse[2] * 2 * math.sqrt(CONF95) #
            heightz = aEllipse[3] * 2 * math.sqrt(CONF95)  #  
            anglez = aEllipse[4]
            
            xyz = []
            xyz.append(xcordz)
            xyz.append(ycordz)
            
            
            
            temparr.append(Ellipse(xy =xyz, width =widthz, height= heightz, angle = anglez * 180/ pi )) 
            temparr.append(xyz)
            temparr.append(item1)
            ells.append(temparr)            
        """        
        ## del ##
        
        DicNodesVCells.setdefault("top")
             
        cellcorX = Transformation.getAvgPoint(Nodestop)[2]
        Relength2 = (topX - cellcorX)/(topX - botX)
        DicNodesVCells["top"] = Relength2
            
        DicNodesError.setdefault("top")
            
        stdev = Transformation.stdev1D(Nodestop)
        stdev = stdev/(topX-botX)
        DicNodesError["top"] = stdev
            
            
            
        DicNodesVaidCells.setdefault("top")
        temp2 = Transformation.convertCoord(coef, Nodestop)
            #temp2 = temp1
            
        aEllipse = Covariance.toEllipse(temp2)
        DicNodesVaidCells["top"] = CONF95 * pi * aEllipse[2] * aEllipse[3]
        



        DicNodesVCells.setdefault("bot")
             
        cellcorX = Transformation.getAvgPoint(Nodesbot)[2]
        Relength2 = (topX - cellcorX)/(topX - botX)
        DicNodesVCells["bot"] = Relength2
            
        DicNodesError.setdefault("bot")
            
        stdev = Transformation.stdev1D(Nodesbot)
        stdev = stdev/(topX-botX)
        DicNodesError["bot"] = stdev
            
            
            
        DicNodesVaidCells.setdefault("bot")
        temp2 = Transformation.convertCoord(coef, Nodesbot)
            #temp2 = temp1
            
        aEllipse = Covariance.toEllipse(temp2)
        DicNodesVaidCells["bot"] = CONF95 * pi * aEllipse[2] * aEllipse[3]
        
        """     
        
        ####
        """
        for item4 in DicNodesVCells.keys():
            #if DicNodesVCells[item4] > 1.0:
            #    continue
            
            
            plt.scatter( DicNodesVCells[item4], DicNodesVaidCells[item4], color = Transformation.color(0.8,DicNodesError[item4]), s = 130 )
            
            plt.text(DicNodesVCells[item4], DicNodesVaidCells[item4], item4, ha="center", family='sans-serif', size=10)
            #plt.errorbar(DicNodesVCells[item4], DicNodesVaidCells[item4], xerr = DicNodesError[item4], linestyle = "None", ecolor = Transformation.color(0.8,DicNodesError[item4]))
        show()
        """
        
        

        ###             
        """
            
        fig = figure()
        ax = fig.add_subplot(111, aspect='equal')
        
        
        for e in ells:
            print e
            ax.add_artist(e[0])
            e[0].set_clip_box(ax.bbox)
            e[0].set_alpha(0.3)
            e[0].set_facecolor(Transformation.color(0.8 ,DicNodesError[e[2]]))
            plt.text(e[1][0], e[1][1], e[2], ha="center", family='sans-serif', size=14)
            
        
        ax.set_xlim(-300000,300000)
        ax.set_ylim(-300000,300000)
        show()
        """
#############convex haul###########################################    
    
        ells1 = []
        for item2 in DicNodesVCells.keys():

            
            #if DicNodesVCells[item2] < 1.2:
            #    continue #showing mosaic bigger than 1.15
## 
            newNode = []
            
            DicNodesVCells.setdefault(item2)
            
            temp1 = Transformation.convertCoord(coef, Nodesvic[item2])
            

            
            cellcorX = Transformation.getAvgPoint(temp1)[2]
            Relength2 = (topX - cellcorX)/(topX - botX)
            DicNodesVCells[item2] = Relength2
            
            DicNodesError.setdefault(item2)
            
            stdev = Transformation.stdev1D(temp1)
            stdev = stdev/(topX-botX)
            DicNodesError[item2] = stdev
            
            
            
            DicNodesVaidCells.setdefault(item2)
            temp2 = Transformation.convertCoord(coef, NodesvicAid[item2])
            #print Transformation.yzExtract(temp2)
            hull = ConvexHull(Transformation.yzExtract(temp2))
            
            newNode.append(hull)
            newNode.append(item2)
            newNode.append(Transformation.yzExtract(temp2))
            ells1.append(newNode)
            
        
            
        fig = figure()
        ax = fig.add_subplot(111, aspect='equal')
        
        for e in ells:
            
            #ax.add_artist(e[0])
            #e[0].set_clip_box(ax.bbox)
            #e[0].set_alpha(0.2)
            #e[0].set_facecolor(Transformation.color(0.8 ,DicNodesError[e[2]]))
            plt.text(e[1][0], e[1][1], e[2], ha="center", family='sans-serif', size=14)
                 
        
        
        
        for arr in ells1:
            
            points = arr[2]
            hull = arr[0]

            
            for vertex in hull.simplices:
 
                plt.plot([(points[(vertex[0])])[0], (points[(vertex[1])])[0]], [(points[(vertex[0])])[1],(points[(vertex[1])])[1]], c =Transformation.color(0.8 ,DicNodesError[arr[1]]) )
            
            
            #convex_hull_plot_2d(arr[0], ax)
        
        i = 0
        
        while i < (len(ells1) - 1):
            fIndex = i
            sIndex = i-1
            
            first = Transformation.verticesToPoints(ells1[fIndex][0], ells1[fIndex][2])
            second = Transformation.verticesToPoints(ells1[sIndex][0], ells1[sIndex][2])
            
            
            i = i + 1
            
            collidng = Transformation.ClipPolygon(first, second)
            for item in collidng:
                 plt.scatter( item[0], item[1], s = 130 )
        
        
        ax.set_xlim(-300000,300000)
        ax.set_ylim(-300000,300000)
        show()    
Ejemplo n.º 8
0
    def transformationCSV(filename, addressTop, addressBot, cutterCells, victimCells):
        condition = [True, True, True, True]
        preCelltop = XMLinterpreter(addressTop)
        Celltop = CellCointainer(preCelltop, condition)
        Nodestop= Celltop.allNodesExtract(0)

        preCellbot = XMLinterpreter(addressBot)
        Cellbot = CellCointainer(preCellbot, condition)
        Nodesbot= Cellbot.allNodesExtract(0)
        
        coef = Transformation.getPlaneCoef2(Nodestop)
        
        Nodestop = Transformation.convertCoord(coef, Nodestop)
        Nodesbot = Transformation.convertCoord(coef, Nodesbot)
        
        topX = Transformation.getAvgPoint(Nodestop)[2]
        botX = Transformation.getAvgPoint(Nodesbot)[2]
        
  
        
        preCellcut = XMLinterpreter(cutterCells)
        Cellcut = CellCointainer(preCellcut, condition)
        Nodescut= Cellcut.Nodes  #dictionary
        
        preCellvic = XMLinterpreter(victimCells)
        Cellvic = CellCointainer(preCellvic, condition)
        Nodesvic= Cellvic.Nodes #dictionary
        
        #Nodesvic = Cellvic.commentWithKeywordExtractDict("ibbon")
        
        ###
        NodesvicAid = Cellvic.Nodes
        ###
       
        
        #DicNodesCCells = {}
        #for item1 in Nodescut.keys():
        #    DicNodesCCells.setdefault(item1)
        #    temp = Transformation.convertCoord(coef, Nodescut[item1])
        #    
        #    DicNodesCCells[item1] = temp
        
        DicNodesVCells = {}
        
        for item2 in Nodesvic.keys():
            DicNodesVCells.setdefault(item2)
            temp1 = Transformation.convertCoord(coef, Nodesvic[item2])
            
            DicNodesVCells[item2] = temp1
            
            """##
        DicNodesVaidCells = {}
        
        for item3 in Nodesvic.keys(): 
            DicNodesVaidCells.setdefault(item3)
            temp2 = Transformation.convertCoord(coef, NodesvicAid[item3])
            
            DicNodesVaidCells[item3] = temp2
            """##
        
        with open(filename, 'wb') as csvfile:
            fieldnames = ['relative_length', 'area']
            writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
            
            for item4 in DicNodesVCells.keys():
                
                
                #writer.writeheader()
                
                aEllipse = Covariance.toEllipse(DicNodesVCells[item4])
            
                cellcorX = Transformation.getAvgPoint(DicNodesVCells[item4])[2]
                Relength2 = (topX - cellcorX)/(topX - botX)
                area = CONF95 * pi * aEllipse[2] * aEllipse[3]
                writer.writerow({'relative_length':str(Relength2) , 'area':str(area)})