コード例 #1
0
def plotMFIdistsBetaEps(bclust=2.2, kmaxFP=10 ** 9, nMax=200, pimrange=[0.0, 5.0, 1.0], beta=1.25, fignums=[0, 1]):
    # def plotMFIdistsBetaEps(bclust=2.2, kmaxFP=10**9, nMax=200, pimlist=[0.0,1.0, 2.0, 3.0, 4.0, 4.9], beta=1.25, fignums=[0,1]):
    # (this function is probably redundant. same as ...Beta(), but fix beta and range over pim.) we know we get nice PL
    # when we vary the shape dimension. what about if we fix D (beta) and vary eps. with the fractal-footprint?
    #
    # fig 5 in PRE pub.
    #
    # pimrange=[0.0,4.9,1.]
    # "beta" version, use footprint ~ n**beta 1<beta<2.0 (or maybe 2.25 or something).
    # for now, fixed epsilon (pim), fixed rho.
    # rhorange = [minrho, maxrho, dRho]
    # note: bcluse is slope of b-distribution, beta is the exponent for shape area/raduis (n) scaling.
    fsize = 20
    thisfont = pltf.FontProperties(size=fsize)
    thisfont2 = pltf.FontProperties(size=fsize - 2)
    #
    fpmodel = 2  # aka, MFI with fractal dimension treatment (as opposed to solid shapes, etc.)
    rho = 1.0  # basically, this puts all the empty sites into the fractal/branching structure.
    thisrho = rho
    bofpim = []
    for fignum in fignums:
        plt.figure(fignum)
        plt.clf()
        plt.xlabel("$log_{10}(k)$", size=fsize + 2)
        plt.ylabel("$log_{10}(N(k))$", size=fsize + 2)
        #
        # starts=[]
        #
    primeRhos = [0.1, 0.3, 0.5, 0.7, 0.9, 1.0]
    # thisrho=rhorange[0]
    icount = 0
    # while thisrho<=rhorange[1]:
    # for beta in betas:
    pim = pimrange[0]
    pim0 = pim
    while pim0 <= pimrange[1]:
        # for pim in pimlist:
        # X=getMFIsquarePropModel(bclust, thisrho, pim, kmaxFP, nMax, fpmodel)
        pim = pim0
        if pim > 4.9:
            pim = 4.9
        print "prams: %s, %s, %s, %s, %s, %s, %s" % (bclust, thisrho, pim, kmaxFP, nMax, fpmodel, beta)
        # pim=pimrange[0]+float(icount)*pimrange[2]
        X = getMFIsquarePropModel(bclust, thisrho, pim, kmaxFP, nMax, fpmodel, beta)
        print "beta=%f, len=%d" % (beta, len(X))
        x = []
        y1 = []
        y2 = []
        # xstart=25
        xstart = 15
        sxtop = 500
        for rw in X:
            # print rw
            x += [math.log10(rw[2])]
            # print rw[3]
            y1 += [math.log10(rw[3])]
            y2 += [math.log10(rw[4])]
        lf1 = yp.linefit([x[xstart:], y1[xstart:]])
        lf2 = yp.linefit([x[xstart:], y2[xstart:]])
        lf1.doFit()
        lf2.doFit()
        # lf1.doFit(None, None, 3)
        # lf2.doFit(None, None, 3)
        #
        dotsies = yp.integerSpacedPoints([x[1:], y1[1:]], 0.5)
        dotsies[0] += [x[-1]]
        dotsies[1] += [y1[-1]]
        if fpmodel > 1:
            bofpim += [[pim, beta, lf1.a, -lf1.b, lf1.meanVar(), lf2.a, -lf2.b, lf2.meanVar()]]
        else:
            bofpim += [[pim, lf1.a, -lf1.b, lf1.meanVar(), lf2.a, -lf2.b, lf2.meanVar()]]
        plt.figure(fignums[0])
        # plt.title('$\\beta=2.2$')
        # plt.plot(x[1:],y1[1:],'%s.-' % yp.pycolor(icount), label='$\\rho = %s, \\epsilon=%s, D=%s, b=%s$' % (str(thisrho), str(pim), str(beta), str(-lf1.b)[0:5]), lw=2)		# beta!=2
        plt.plot(
            dotsies[0],
            dotsies[1],
            "%s%s" % (yp.pycolor(icount), yp.fitMarkerShortList[icount % len(yp.fitMarkerShortList)]),
            label="$\\epsilon=%s, b=%s$" % (str(pim), str(-lf1.b)[0:5]),
            ms=10,
        )
        plt.plot(x[1:], y1[1:], "%s-" % yp.pycolor(icount), lw=2, ms=10)  # beta!=2
        plt.plot(
            [x[0], x[xstart], x[-1]],
            [lf1.a + lf1.b * x[0], lf1.a + lf1.b * x[xstart], lf1.a + lf1.b * x[-1]],
            "%s|-" % yp.pycolor(icount),
            ms=15,
        )
        plt.figure(fignums[1])
        # plt.title('$\\beta=2.0$')
        # plt.plot(x[1:], y2[1:], '%s.-' % yp.pycolor(icount), label='$\\rho = %s, \\epsilon=%s, D=%s, b=%s$' % (str(thisrho), str(pim), str(beta), str(-lf2.b)[0:5]), lw=2)		# beta=2 approximation
        plt.plot(
            x[1:],
            y2[1:],
            "%s.-" % yp.pycolor(icount),
            label="$\\epsilon=%s, b=%s$" % (str(pim), str(-lf2.b)[0:5]),
            lw=2,
            ms=10,
        )  # beta=2
        plt.plot(
            [x[0], x[xstart], x[-1]],
            [lf2.a + lf2.b * x[0], lf2.a + lf2.b * x[xstart], lf2.a + lf2.b * x[-1]],
            "%s|-" % yp.pycolor(icount),
            ms=15,
        )
        icount += 1
        pim0 += pimrange[2]
        #
        # thisrho+=rhorange[2]
        #
    for fignum in fignums:
        plt.figure(fignum)
        ax = plt.gca()
        plt.subplots_adjust(bottom=0.15)
        plt.setp(ax.get_xticklabels(), fontsize=fsize)
        plt.setp(ax.get_yticklabels(), fontsize=fsize)

        # lgd=plt.legend(loc='best', numpoints=1, title='$D=1.25$', prop=thisfont2, ncol=1)
        lgd = plt.legend(loc="best", numpoints=1, prop=thisfont2, ncol=1)
        lgd.set_title("$D=1.25$")
        plt.setp(lgd.get_title(), fontsize=fsize)
        if fignum > 0:
            continue
        plt.savefig(
            "writeup/mfi-aps/mfi-PRE-letter/figs/mfi-fractalType-varEps-bc%s-D125.png" % str(bclust).replace(".", "")
        )
        plt.savefig(
            "writeup/mfi-aps/mfi-PRE-letter/figs/mfi-fractalType-varEps-bc%s-D125.eps" % str(bclust).replace(".", "")
        )
    plt.show()

    return bofpim
コード例 #2
0
def plotMFIdistsBeta(
    bclust=2.2,
    kmaxFP=10 ** 9,
    nMax=200,
    pim=4.9,
    betas=[0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5],
    fignums=[0, 1],
    dosave=False,
):
    # "Fig-4" in PRE publication.
    #
    # "beta" version, use footprint ~ n**beta 1<beta<2.0 (or maybe 2.25 or something).
    # for now, fixed epsilon (pim), fixed rho.
    # rhorange = [minrho, maxrho, dRho]
    # note: bcluse is slope of b-distribution, beta is the exponent for shape area/raduis (n) scaling.
    fpmodel = 2
    rho = 1.0  # basically, this puts all the empty sites into the fractal/branching structure.
    thisrho = rho
    #
    fsize = 20
    thisfont = pltf.FontProperties(size=fsize)
    thisfont2 = pltf.FontProperties(size=fsize - 2)
    #
    bofpim = []
    for fignum in fignums:
        plt.figure(fignum)
        plt.clf()
        plt.xlabel("$log_{10}(k)$", size=fsize + 2)
        plt.ylabel("$log_{10}(N(k))$", size=fsize + 2)
        #
        # starts=[]
        #
    primeRhos = [0.1, 0.3, 0.5, 0.7, 0.9, 1.0]
    # thisrho=rhorange[0]
    icount = 0
    # while thisrho<=rhorange[1]:
    fitMarkerShortList = ["o", "^", "s", "p", "*", "h", "+", "H", "D", "x"]
    for beta in betas:
        # X=getMFIsquarePropModel(bclust, thisrho, pim, kmaxFP, nMax, fpmodel)
        print "prams: %s, %s, %s, %s, %s, %s, %s" % (bclust, thisrho, pim, kmaxFP, nMax, fpmodel, beta)
        X = getMFIsquarePropModel(bclust, thisrho, pim, kmaxFP, nMax, fpmodel, beta)
        print "beta=%f, len=%d" % (beta, len(X))
        x = []
        y1 = []
        y2 = []
        # xstart=25
        xstart = 2
        sxtop = 500
        for rw in X:
            # print rw
            x += [math.log10(rw[2])]
            # print rw[3]
            y1 += [math.log10(rw[3])]
            y2 += [math.log10(rw[4])]
        lf1 = yp.linefit([x[xstart:], y1[xstart:]])
        lf2 = yp.linefit([x[xstart:], y2[xstart:]])
        lf1.doFit()
        lf2.doFit()
        # lf1.doFit(None, None, 3)
        # lf2.doFit(None, None, 3)
        #
        if fpmodel > 1:
            bofpim += [[pim, beta, lf1.a, -lf1.b, lf1.meanVar(), lf2.a, -lf2.b, lf2.meanVar()]]
        else:
            bofpim += [[pim, lf1.a, -lf1.b, lf1.meanVar(), lf2.a, -lf2.b, lf2.meanVar()]]
        plt.figure(fignums[0])
        # plt.title('$\\beta=2.2$')
        # plt.plot(x[1:],y1[1:],'%s.-' % yp.pycolor(icount), label='$\\rho = %s, \\epsilon=%s, \\beta_s=%s, b=%s$' % (str(thisrho), str(pim), str(beta), str(-lf1.b)[0:5]), lw=2)		# beta!=2
        dotsies = yp.integerSpacedPoints([x[1:], y1[1:]], 0.5)
        dotsies[0] += [x[-1]]
        dotsies[1] += [y1[-1]]  # add end-bits for completeness.
        plt.plot(x[1:], y1[1:], "%s-" % yp.pycolor(icount), lw=2, ms=10)  # beta!=2
        plt.plot(
            dotsies[0],
            dotsies[1],
            "%s%s" % (yp.pycolor(icount), fitMarkerShortList[icount % len(fitMarkerShortList)]),
            label="$D=%s, b=%s$" % (str(beta), str(-lf1.b)[0:5]),
            ms=10,
        )
        plt.plot(
            [x[0], x[xstart], x[-1]],
            [lf1.a + lf1.b * x[0], lf1.a + lf1.b * x[xstart], lf1.a + lf1.b * x[-1]],
            "%s|-" % yp.pycolor(icount),
            ms=20,
            lw=2,
        )
        #
        plt.figure(fignums[1])
        # plt.title('$\\beta=2.0$')
        # plt.plot(x[1:], y2[1:], '%s.-' % yp.pycolor(icount), label='$\\rho = %s, \\epsilon=%s, \\beta_s=%s, b=%s$' % (str(thisrho), str(pim), str(beta), str(-lf2.b)[0:5]), lw=2)		# beta=2 approximation
        plt.plot(
            x[1:],
            y2[1:],
            "%s.-" % yp.pycolor(icount),
            label="$D=%s, b=%s$" % (str(beta), str(-lf2.b)[0:5]),
            lw=2,
            ms=10,
        )  # beta=2 approximation
        plt.plot(
            [x[0], x[xstart], x[-1]],
            [lf2.a + lf2.b * x[0], lf2.a + lf2.b * x[xstart], lf2.a + lf2.b * x[-1]],
            "%s|-" % yp.pycolor(icount),
            ms=15,
            lw=2,
        )
        icount += 1
        #
        # thisrho+=rhorange[2]
        #
    for fignum in fignums:
        plt.figure(fignum)
        ax = plt.gca()
        plt.subplots_adjust(bottom=0.15)
        plt.setp(ax.get_xticklabels(), fontsize=fsize)
        plt.setp(ax.get_yticklabels(), fontsize=fsize)

        # plt.legend(loc='best', numpoints=1, prop=thisfont2, ncol=1, title='$\\epsilon=4.9$')
        lgd = plt.legend(loc="best", numpoints=1, prop=thisfont2, ncol=1)
        lgd.set_title("$\\epsilon=4.9$")
        plt.setp(lgd.get_title(), fontsize=fsize)
        # mfi-fractalType-varEps-bc22-D125
        if fignum > 0:
            continue
        if dosave:
            plt.savefig(
                "writeup/mfi-aps/mfi-PRE-letter/figs/mfi-fractalType-eps49-bc%s-varD.png" % str(bclust).replace(".", "")
            )
            plt.savefig(
                "writeup/mfi-aps/mfi-PRE-letter/figs/mfi-fractalType-eps49-bc%s-varD.eps" % str(bclust).replace(".", "")
            )
    plt.show()
    return bofpim