Exemplo n.º 1
0
def linkstable():
    N=Nodes()
    a,h,F=AtoKh_old(N)
    H=get_quant(0.99)
    CP=get_quant(1.0)
    D=H*0.4
    #for f in F:
    #    print f[0],"to",f[1]," & ",round(h[2*f[2]]/1000,2)," & ",round(D[2*f[2]]/1000,2)," & ",round(H[2*f[2]]/1000,2)," &",round(CP[2*f[2]]/1000,2)," & ",f[1],"to",f[0]," & ",round(h[1+2*f[2]]/1000,2)," & ",round(D[1+2*f[2]]/1000,2)," & ",round(H[1+2*f[2]]/1000,2)," &",round(CP[1+2*f[2]]/1000,2),"\\\\"
    print "Total of today's is ", sum(biggestpair(h))
    print "Total of Interme's is ", sum(biggestpair(D))
    print "Total of 99p's is ", sum(biggestpair(H))
    print "Total of copper plate's is ", sum(biggestpair(CP))
Exemplo n.º 2
0
def show_hist(link,tit,mean=None,filename='results/copper_flows.npy',b=250):
    plt.close()
    if mean==None:
        mean=1.0    
    flows=np.load(filename)   
    f=[]
#    ax=subplot(1,1,1)
    for i in flows[link]:
        if i>1 or i<-1:
            f.append(i/mean)
    zzone=[-get_quant(0.9999)[link*2+1],get_quant(0.9999)[link*2]]
    zone=[-get_quant(0.999)[link*2+1],get_quant(0.999)[link*2]]
    one=[-get_quant(0.99)[link*2+1],get_quant(0.99)[link*2]]
    five=[-get_quant(0.95)[link*2+1],get_quant(0.95)[link*2]]
    plt.close()
    ax=subplot(1,1,1)
    a=hist(f,bins=(max(f)-min(f))/(0.01*0.9/2.5),normed=0,histtype='stepfilled',color=rolor,weights=np.zeros((len(f)))+ 1./70128)
    plt.ylabel('P($F_l$)',size="large")
    plt.xlabel(r'Directed power flow [normalised]',size="large")
    plt.text(-1.46,.009,"France to Spain",size="large")
    #plt.title(r'Histogram of Power Flows : '+str(tit))
    vlines(zzone[0]/mean,0,0.0015,color='r',linewidth=1.2)
    plt.text(zzone[0]/mean*1.05,.0018,'0.01% Q',size=11)
    vlines(zone[0]/mean,0,0.003,color='r',linewidth=1.2)
    plt.text(zone[0]/mean*1.05,.0032,'0.1% Q',size=11)
    vlines(one[0]/mean,0,0.004,color='r',linewidth=1.2)
    plt.text(one[0]/mean*1.2,.0042,'1.0% Q',size=11)
    vlines(five[0]/mean,0,.0055,color='r',linewidth=1.2)
    plt.text(five[0]/mean*1.25,.0057,'5.0% Q',size=11)
    vlines(five[1]/mean,0,.0055,color='r',linewidth=1.2)
    plt.text(five[1]/mean*0.9,.0057,'95% Q',size=11)
    vlines(one[1]/mean,0,0.0040,color='r',linewidth=1.2)
    plt.text(one[1]/mean*0.8,0.0042,'99% Q',size=11)
    vlines(zone[1]/mean,0,0.003,color='r',linewidth=1.2)
    plt.text(zone[1]/mean*0.8,0.0032,'99.9% Q',size=11)
    vlines(zzone[1]/mean,0,0.0015,color='r',linewidth=1.2)
    plt.text(zzone[1]/mean*0.99,0.0017,'99.99% Q',size=11)
    plt.setp(ax.get_xticklabels(), fontsize=12) # rotation='vertical',
    plt.setp(ax.get_yticklabels(), fontsize=12)
    gcf().set_size_inches([1.3*dcolwidth,1.3*dcolwidth*0.5])
    plt.ylim(0,.01001)
    plt.xlim(-1.5,1.0)
    plt.grid(which="major",axis='x')
#    plt.axis([-5.35,5.65,0,0.5])#plt.axis([0.5, 1, 0, 38000])
    plt.tight_layout()
    savefig('./figures/' + str(link) +'.eps', dpi=400)
    plt.close()
    #show()
    filename='results/99PCap_flows.npy'
    plt.close()
    if mean==None:
        mean=1.0    
    flows=np.load(filename)   
    f=[]
#    ax=subplot(1,1,1)
    for i in flows[link]:
        if i>1 or i<-1:
            f.append(i/mean)
    print 
    plt.close()
    ax=subplot(1,1,1)
    a=hist(f,bins=(max(f)-min(f))/(0.01*0.9/2.5),normed=0,histtype='stepfilled',color=rolor,weights=np.zeros((len(f)))+ 1./70128)
    plt.ylabel('P($F_l$)',size="large")
    plt.xlabel(r'Transmission Magnitude ($\langle L_{DE} \rangle$)',size="large")
    plt.text(-0.48,2.35,"Germany to Denmark",size="large")
    #plt.title(r'Histogram of Power Flows : '+str(tit))
    plt.setp(ax.get_xticklabels(), fontsize=12) # rotation='vertical',
    plt.setp(ax.get_yticklabels(), fontsize=12)
    gcf().set_size_inches([1.3*dcolwidth,1.3*dcolwidth*0.5])
    plt.axis([-0.5,0.4,0.0,2.5])#plt.axis([0.5, 1, 0, 38000])
    plt.grid(True)
    plt.tight_layout()
    savefig('./figures/' + str(tit) +'_constr.eps', dpi=400)
    plt.close()