pc4bims/circlepacking.py
def loglogDiagram(self, num=None):
        '''Method to show the log-log graph of the diameters and quantities
        of circular particles packed in a closed polygon in
        :math:`\\mathbb{R}^2`.

        Examples
        --------

            .. plot::

                from numpy import array
                from pc4bims.basegeom import Polygon
                from pc4bims.circlepacking import CirclePacking as CP
                coordinates = array([[1, 1], [2, 5], [4.5, 6], [6, 4], [8, 3],
                                     [7, 1], [4.5, 1], [4, 0]])
                polygon = Polygon(coordinates)
                boundCoords = polygon.boundCoords
                circlePacking = CP(boundCoords, 10)
                circlePacking.loglogDiagram()
        '''

        # Obtaining diameters histogram
        n = len(self.circlesInPoly)  # simple size
        # Number of bins according to Sturges equation
        numBins = math.floor(1 + math.log2(n))
        diams = [circle.diameter for circle in self.circlesInPoly]
        bins = np.linspace(min(diams), max(diams), numBins)
        hist, binEdges = np.histogram(diams, bins)
        nonZeroIndx = [i for i, k in enumerate(hist) if k != 0]
        histRed = hist[nonZeroIndx]
        histRedRel = [float(k)/n * 100 for k in histRed]
        nonZeroIndx4Bins = [k+1 for k in nonZeroIndx]
        binEdgesRed = binEdges[nonZeroIndx4Bins]
        if n is None:
            d, nD = binEdgesRed, histRedRel
        else:
            d, nD = binEdgesRed[:num], histRedRel[:num]
        # Logarithmic fit
        dLog2, nDLog2 = np.log2(d), np.log2(nD)
        bLog, mLog = polyfit(dLog2, nDLog2, deg=1)
        nDFitLog = mLog * dLog2 + bLog
        nDFit = 2**nDFitLog
        # plotting loglog
        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.plot(d, nD, 'ko', ms=3.5)
        ax.plot(d, nDFit, '--r', label='$f_{(x)}=$'+str(round(mLog, 2)) +
                                       '$x\ $'+str(round(bLog, 2)), lw=.8)
        ax.set_xscale('log', basex=2)
        ax.set_yscale('log', basey=2)
        ax.grid(ls='--', lw=0.5)
        ax.set_xlabel('$\log_{2}\ d$')
        ax.set_ylabel('$\log_{2}\ N_d$')
        ax.legend()
        # ax.axis('equal')
        # ax.set_aspect(1)
        ax.set_xlim((0.5*min(d), 1.5*max(d)))
        ax.set_ylim((0.5*min(nD), 1.5*max(nD)))
        return
Method to show the log-log graph of the diameters and quantities
        of circular particles packed in a closed polygon in
        :math:`\\mathbb{R}^2`.

        Examples
        --------

            .. plot::

                from numpy import array
                from pc4bims.basegeom import Polygon
                from pc4bims.circlepacking import CirclePacking as CP
                coordinates = array([[1, 1], [2, 5], [4.5, 6], [6, 4], [8, 3],
                                     [7, 1], [4.5, 1], [4, 0]])
                polygon = Polygon(coordinates)
                boundCoords = polygon.boundCoords
                circlePacking = CP(boundCoords, 10)
                circlePacking.loglogDiagram()
        
Method to show the log-log graph of the diameters and quantities
of circular particles packed in a closed polygon in
Method to show the log - log graph of the diameters and quantities of circular particles packed in a closed polygon in
def loglogDiagram(self, num=None):
        n = len(self.circlesInPoly)  
        numBins = math.floor(1 + math.log2(n))
        diams = [circle.diameter for circle in self.circlesInPoly]
        bins = np.linspace(min(diams), max(diams), numBins)
        hist, binEdges = np.histogram(diams, bins)
        nonZeroIndx = [i for i, k in enumerate(hist) if k != 0]
        histRed = hist[nonZeroIndx]
        histRedRel = [float(k)/n * 100 for k in histRed]
        nonZeroIndx4Bins = [k+1 for k in nonZeroIndx]
        binEdgesRed = binEdges[nonZeroIndx4Bins]
        if n is None:
            d, nD = binEdgesRed, histRedRel
        else:
            d, nD = binEdgesRed[:num], histRedRel[:num]
        dLog2, nDLog2 = np.log2(d), np.log2(nD)
        bLog, mLog = polyfit(dLog2, nDLog2, deg=1)
        nDFitLog = mLog * dLog2 + bLog
        nDFit = 2**nDFitLog
        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.plot(d, nD, 'ko', ms=3.5)
        ax.plot(d, nDFit, '--r', label='$f_{(x)}=$'+str(round(mLog, 2)) +
                                       '$x\ $'+str(round(bLog, 2)), lw=.8)
        ax.set_xscale('log', basex=2)
        ax.set_yscale('log', basey=2)
        ax.grid(ls='--', lw=0.5)
        ax.set_xlabel('$\log_{2}\ d$')
        ax.set_ylabel('$\log_{2}\ N_d$')
        ax.legend()
        ax.set_xlim((0.5*min(d), 1.5*max(d)))
        ax.set_ylim((0.5*min(nD), 1.5*max(nD)))
        return
def loglogDiagram ( self , num = None ) : n = len ( self . circlesInPoly ) numBins = math . floor ( 1 + math . log2 ( n ) ) diams = [ circle . diameter for circle in self . circlesInPoly ] bins = np . linspace ( min ( diams ) , max ( diams ) , numBins ) hist , binEdges = np . histogram ( diams , bins ) nonZeroIndx = [ i for i , k in enumerate ( hist ) if k != 0 ] histRed = hist [ nonZeroIndx ] histRedRel = [ float ( k ) / n * 100 for k in histRed ] nonZeroIndx4Bins = [ k + 1 for k in nonZeroIndx ] binEdgesRed = binEdges [ nonZeroIndx4Bins ] if n is None : d , nD = binEdgesRed , histRedRel else : d , nD = binEdgesRed [ : num ] , histRedRel [ : num ] dLog2 , nDLog2 = np . log2 ( d ) , np . log2 ( nD ) bLog , mLog = polyfit ( dLog2 , nDLog2 , deg = 1 ) nDFitLog = mLog * dLog2 + bLog nDFit = 2 ** nDFitLog fig = plt . figure ( ) ax = fig . add_subplot ( 111 ) ax . plot ( d , nD , 'ko' , ms = 3.5 ) ax . plot ( d , nDFit , '--r' , label = '$f_{(x)}=$' + str ( round ( mLog , 2 ) ) + '$x\ $' + str ( round ( bLog , 2 ) ) , lw = .8 ) ax . set_xscale ( 'log' , basex = 2 ) ax . set_yscale ( 'log' , basey = 2 ) ax . grid ( ls = '--' , lw = 0.5 ) ax . set_xlabel ( '$\log_{2}\ d$' ) ax . set_ylabel ( '$\log_{2}\ N_d$' ) ax . legend ( ) ax . set_xlim ( ( 0.5 * min ( d ) , 1.5 * max ( d ) ) ) ax . set_ylim ( ( 0.5 * min ( nD ) , 1.5 * max ( nD ) ) ) return
Method to show the log-log graph of the diameters and quantities
of circular particles packed in a closed polygon in
Method to show the log - log graph of the diameters and quantities of circular particles packed in a closed polygon in
'''Method to show the log-log graph of the diameters and quantities
        of circular particles packed in a closed polygon in
        :math:`\\mathbb{R}^2`.

        Examples
        --------

            .. plot::

                from numpy import array
                from pc4bims.basegeom import Polygon
                from pc4bims.circlepacking import CirclePacking as CP
                coordinates = array([[1, 1], [2, 5], [4.5, 6], [6, 4], [8, 3],
                                     [7, 1], [4.5, 1], [4, 0]])
                polygon = Polygon(coordinates)
                boundCoords = polygon.boundCoords
                circlePacking = CP(boundCoords, 10)
                circlePacking.loglogDiagram()
        ''' # Obtaining diameters histogram # simple size # Number of bins according to Sturges equation # Logarithmic fit # plotting loglog # ax.axis('equal') # ax.set_aspect(1)
self
num
math




from numpy import array
from pc4bims.basegeom import Polygon
from pc4bims.circlepacking import CirclePacking as CP
coordinates = array([[1, 1], [2, 5], [4.5, 6], [6, 4], [8, 3],
[7, 1], [4.5, 1], [4, 0]])
polygon = Polygon(coordinates)
boundCoords = polygon.boundCoords
circlePacking = CP(boundCoords, 10)
circlePacking.loglogDiagram()
from numpy import array from pc4bims . basegeom import Polygon from pc4bims . circlepacking import CirclePacking as CP coordinates = array ( [[ 1 1 ] [ 2 5 ] [ 4 . 5 6 ] [ 6 4 ] [ 8 3 ] [ 7 1 ] [ 4 . 5 1 ] [ 4 0 ]] ) polygon = Polygon ( coordinates ) boundCoords = polygon . boundCoords circlePacking = CP ( boundCoords 10 ) circlePacking . loglogDiagram ()