Example #1
0
        F[-1].append(fit)

# plot fit and save estimates
for f in F:
    rtmc=[]
    plt.figure(figsize=(16,12))
    for vp in range(4):
        d=rts[vp,rejs[vp,:]==1]
        d=d[d>0]
        plt.subplot(2,2,vp+1)
        x=np.linspace(1,30,31)
        plt.hist(d,bins=x,facecolor='w')
        plt.ylim([0,140])
        plt.xlim([0,30])
        w=f[vp].extract()
        varc=np.square(w['rtsc'])
        vard=np.square(w['rtsd'])
        rtmc.append([np.exp(w['rtmc']+varc/2.),
                     np.exp(w['rtmd']+vard/2.),
                     #np.sqrt((np.exp(varc)-1)*np.exp(2*w['rtmc']+varc)),
                     #np.sqrt((np.exp(vard)-1)*np.exp(2*w['rtmd']+vard)),
                     w['csrate'],w['dsrate'],
                     w['rtmc'],w['rtsc']])
        plt.plot(x-0.5,d.size*lognorm(mu=w['rtmc'].mean(),
                    sigma=w['rtsc'].mean()).pdf(x-0.5))
    rtmc=np.array(rtmc,ndmin=2)
np.save(os.getcwd().rstrip('code')+'evaluation/rtmc',rtmc)
np.save(os.getcwd().rstrip('code')+'evaluation/rejs',rejs)
np.save(os.getcwd().rstrip('code')+'evaluation/rts',rts)
np.save(os.getcwd().rstrip('code')+'evaluation/acc',acc)
Example #2
0
def plotBehData():
    plt.close()
    from matustools.matustats import lognorm
    rtmc=np.load(inpath+'rtmc.npy')
    rejs=np.load(inpath+'rejs.npy')
    rts=np.load(inpath+'rts.npy')
    acc=np.load(inpath+'acc.npy')
    figure(size=3,aspect=0.6)
    ax = plt.subplot2grid((2,3), (0, 0), colspan=2)
    #subplot(3,1,1)
    formatAxes(ax)
    #ax=plt.gca()
    vp=0
    d=rts[vp,rejs[vp,:]==1]
    d=d[d>0]
    x=np.linspace(1,30,30)
    hist(d,bins=x,normed=True)
    ax.plot(x-0.5,lognorm(mu=rtmc[vp,-2,:].mean(),
                sigma=rtmc[vp,-1,:].mean()).pdf(x-0.5),'k')
    plt.xlabel(FIG[0][1][0])
    plt.ylabel(FIG[0][1][1])
    subplotAnnotate(loc='ne',nr=0)
    #plt.subplot(2,2,i+1);i+=1
    for k in range(4):
        subplot(2,3,[4,5,3,6][k])
        
        
        plt.xlabel(FIG[0][2+k][0])
        #else:plt.gca().set_xticklabels([])
        #if k==0:
        #    print FIG[0][1+k]
        plt.ylabel(FIG[0][2+k][1])
        #elif k>1: 
        if k==1 or k==0: plt.ylim([6,20])
        else: plt.ylim([0.75,1])
        #if k==2:plt.ylabel(FIG[0][2+k][1])
        #if k%2==1: plt.gca().set_yticklabels([])
        
        errorbar(rtmc[:,k,:].T,x=range(1,5))
        subplotAnnotate(loc='ne',nr=k+1)
    plt.subplots_adjust(wspace=0.01,hspace=-0.2)
    plt.savefig(figpath+FIG[0][0],dpi=DPI,bbox_inches='tight')

    figure(size=2,aspect=0.4)
    for vp in range(4):
        sel= ~np.isnan(rts[vp,:])
        d=np.int32(acc[vp,sel]==1)
        d=np.reshape(d,(d.size/10.,10))
        y=d.mean(1)
        x=np.arange(y.size)*10
        plt.plot(x+(vp-1.5)*1,y+(vp-1.5)*0.01,'+',ms=5,mew=1)
    plt.ylim([0.2,1.05])
    plt.gca().set_xticks(range(0,y.size*10,40))
    plt.grid(True,axis='x')
    plt.xlim([-4,250])
    plt.xlabel(FIG[1][1][0])
    plt.ylabel(FIG[1][1][1])
    leg=plt.legend(FIG[1][1][2],loc=0,numpoints=1,frameon=True,
                   ncol=4)#,fontsize='small',labelspacing=0)
    box=leg.get_frame()
    box.set_linewidth(0.)
    box.set_facecolor([0.9]*3)
    plt.savefig(figpath+FIG[1][0],dpi=DPI,bbox_inches='tight')
    plt.close('all')