示例#1
0
def markersColors(numColors):
    '''return the markers and colors used for plotting.'''

    # He4 Pore PRL Colors
#    colors = ['#556270','#1C3249','#4ECDC4','#19857D','#C7F464','#FF6B6B','#A62323'] #556270

    # http://www.graphviz.org/content/color-names
    if numColors == 1:
        numColors+=1;
    #colors  = loadgmt.getColorList('cb/div','Spectral_08',numColors)
    #colors  = loadgmt.getColorList('cb/div','PiYG_07',numColors)
    colors  = loadgmt.getColorList('cb/qual','Set1_09',numColors)

    # colors.reverse()
    markers = loadgmt.getMarkerList()

    return markers,colors
示例#2
0
def main(): 

    # parse the command line options
    args = docopt(__doc__)

    fileNames = args['<file>']
    skip = int(args['--skip'])
    period = int(args['--period'])
    estimator = args['--estimator']
    leglabel = args['--legend'] and args['--legend']
    error = args['--error'] and float(args['--error'])
    val = args['--hline'] and float(args['--hline'])


    # if labels are not assigned, we default to the PIMCID
    if not leglabel:
        leglabel = []
        for n,fileName in enumerate(fileNames):
            leglabel.append(fileName[-13:-4])

    # We count the number of lines in the estimator file to make sure we have
    # some data and grab the headers
    headers = pimchelp.getHeadersDict(fileNames[0])

    # If we don't choose an estimator, provide a list of possible ones
    if estimator not in headers:
        errorString = "Need to specify one of:\n"
        for head,index in headers.iteritems():
            errorString += "\"%s\"" % head + "   "
        parser.error(errorString)

    numFiles = len(fileNames)
    col = list([headers[estimator]])

    # Attempt to find a 'pretty name' for the label, otherwise just default to
    # the column heading
    label = pimchelp.Description()
    try:
        yLong = label.estimatorLongName[estimator]
    except:
        yLong = estimator
    try:
        yShort = label.estimatorShortName[estimator]
    except:
        yShort = estimator

    # get a label for a possible horizontal line
    if args['--hline']:
        if args['--hlabel']:
            hlabel = args['--hlabel']
        else:
            hlabel = yShort.split()[0] + ' = ' + args['--hline']

    # First we load and store all the data 
    data = []
    for fileName in fileNames:

        dataFile = open(fileName,'r');
        dataLines = dataFile.readlines();
        dataFile.close()

        if len(dataLines) > 2:
            data.append(loadtxt(fileName,usecols=col,unpack=True))

    # ============================================================================
    # Figure 1 : column vs. MC Steps
    # ============================================================================
    figure(1)
    connect('key_press_event',kevent.press)

    colors  = loadgmt.getColorList('cw/1','cw1-029',max(numFiles,2))
    #colors  = loadgmt.getColorList('cw/1','cw1-013',max(numFiles,2))
    #colors  = loadgmt.getColorList('oc','rainbow',max(numFiles,2))
    #colors  = loadgmt.getColorList('grass','bgyr',max(numFiles,2))
    colors = ["#70D44A", "#BE5AD4", "#D04537", "#81D0D5", "#393A2E", "#C49ECA", 
              "#C5CB7A", "#523767", "#D39139", "#C8488C", "#CB817A", "#73D999", 
              "#6F2836", "#6978CF", "#588569", "#CDC3AD", "#5C7890", "#7F5327", 
              "#D0D33D", "#5B7D2E"]
    colors = ["#53B0AD", "#D74C20", "#CD53DA", "#58C038", "#5F4B7A", "#49622A", 
              "#CE4379", "#D2912E", "#7970D2", "#749AC9", "#7D5121", "#5EAC72", 
              "#CB85AA", "#853B46", "#396465", "#A5A33E", "#D47F5B", "#BA4EA5", 
              "#C93F44", "#5D9937"]
    colors =["#CAC5E8", "#E1D273", "#82DFCE", "#F1AF92", "#E1E7CF", "#92C798", 
            "#CDF197", "#DDD199", "#ECB1D1", "#91C7DE", "#E3AF6E", "#ECAAAC", 
            "#CEB29C", "#B2BCA9", "#B0C778", "#DBCDD7", "#B5DEE0", "#A5ECB4", 
            "#C5E6C0", "#E5CCC0"] 
    colors = ["#688EAF", "#FC991D", "#7DEB74", "#FA6781", "#8B981D", "#BB7548", 
            "#AD8FE4", "#96E4AA", "#D669B0", "#E1C947", "#A78200", "#7C9FE4", 
            "#957DA6", "#75BF38", "#C3B059", "#51C17A", "#79AEBB", "#2790AC", 
            "#688ECE", "#749DB7"]
    colors += colors
    colors += colors
    colors += colors
    print len(colors)

    for n,cdata in enumerate(data):
        plot(cdata[skip:],marker='s',color=colors[n],markeredgecolor=colors[n],\
             markersize=4,linestyle='-',linewidth=1.0)

    ylabel(yLong)
    xlabel("MC Bin Number")

    # ============================================================================
    # Figure 2 : running average of column vs. MC Bins
    # ============================================================================
    figure(2)
    connect('key_press_event',kevent.press)

    n = 0
    for n,cdata in enumerate(data):
        if size(cdata) > 1:
            
            # Get the cumulative moving average
            if args['--error']:
                cma = cumulativeMovingAverage(cdata[skip:])
                sem = error*ones_like(cma)
            elif args['--nobin']:
                cma,sem = cumulativeMovingAverageWithError(cdata[skip:])
            else:
                cma = cumulativeMovingAverage(cdata[skip:])
                ave,err = getStats(cdata[skip:])
                sem = err*ones_like(cma)
                print '%s:  %s = %8.4E +- %8.4E' % (leglabel[n],yShort, ave,err) 

            sma = simpleMovingAverage(50,cdata[skip:])
            x = range(int(0.10*len(cma)),len(cma))
            plot(x,cma[x],color=colors[n],linewidth=1.0,marker='None',linestyle='-',
                label=leglabel[n])
            fill_between(x, cma[x]-sem[x], cma[x]+sem[x],color=colors[n], alpha=0.1)
            n += 1

    # Add a possible horizontal line indicating some value
    if args['--hline']:
        axhline(y=val,color='gray',linewidth=2.5, label=hlabel)

    ylabel(yLong)
    xlabel("MC Bin Number")
    tight_layout()
    leg = legend(loc='best', frameon=False, prop={'size':16},markerscale=2, ncol=2)
    for l in leg.get_lines():
        l.set_linewidth(4.0)

    # Perform a Welch's t-test
    if args['--ttest']:
        # We only perform the Welch's t test if we have multiple samples we are
        # comparing
        N = len(data)
        if N > 1:
            tval = zeros([N,N])
            p = zeros([N,N])

            for i in range(N):
                for j in range(i+1,N):
                    tval[i,j],p[i,j] = stats.ttest_ind(data[i][skip:], data[j][skip:], 
                                               equal_var=False)

        # ============================================================================
        # Figure 3 : plot the estimator histogram along with t-test values
        # ============================================================================
        fig = figure(3)
        connect('key_press_event',kevent.press)
        for i in range(N):
            n, bins, patches = hist(data[i], 100, normed=True, facecolor=colors[i], 
                                    alpha=0.75, label=leglabel[i],
                                    edgecolor='w')
        # Add the p-values from the t-test
        y = 0.92
        if N > 1:
            figtext(0.78, y, 't-test p values', horizontalalignment='center', 
                 verticalalignment='top', fontsize=15, backgroundcolor='white')

            for i in range(N):
                for j in range(i+1,N):
                    y -= 0.03
                    lab = 'p(' + leglabel[i] + ' - ' + leglabel[j] + ') = ' + '%4.2f'%p[i,j]
                    figtext(0.78, y, lab, horizontalalignment='center', 
                         verticalalignment='top', fontsize=12,
                       backgroundcolor='white')

        legend(loc='upper left', fontsize=15, frameon=False)
        xlabel(yLong)
        ylabel(r'$P($' + estimator + r'$)$')
 

            
    show()
示例#3
0
def main():

    # define the mapping between short names and label names 
    shortFlags = ['n','T','N','t','u','V','L','W','D']
    parMap = {'n':'Initial Density', 'T':'Temperature', 'N':'Initial Number Particles',
              't':'Imaginary Time Step', 'u':'Chemical Potential', 'V':'Container Volume',
              'L':'Container Length', 'W':'Virial Window', 'M':'Update Length'}  #'M':'Update Slices (Mbar)'}

    # setup the command line parser options 
    parser = OptionParser() 
    parser.add_option("-T", "--temperature", dest="T", type="float",
                      help="simulation temperature in Kelvin") 
    parser.add_option("-N", "--number-particles", dest="N", type="int",
                      help="number of particles") 
    parser.add_option("-n", "--density", dest="n", type="float",
                      help="number density in Angstroms^{-d}")
    parser.add_option("-t", "--imag-time-step", dest="tau", type="float",
                      help="imaginary time step")
    parser.add_option("-u", "--chemical-potential", dest="mu", type="float",
                      help="chemical potential in Kelvin") 
    parser.add_option("-L", "--Lz", dest="L", type="float",
                      help="Length in Angstroms") 
    parser.add_option("-V", "--volume", dest="V", type="float",
                      help="volume in Angstroms^d") 
    parser.add_option("-r", "--reduce", dest="reduce",
                      choices=['T','N','n','u','t','L','V','W','M'], 
                      help="variable name for reduction [T,N,n,u,t,L,V,W,M]") 
    parser.add_option("--canonical", action="store_true", dest="canonical",
                      help="are we in the canonical ensemble?")
    parser.add_option("-p", "--plot", action="store_true", dest="plot",
                      help="do we want to produce data plots?") 
    parser.add_option("-R", "--radius", dest="R", type="float",
                      help="radius in Angstroms") 
    parser.add_option("-s", "--skip", dest="skip", type="int",
                      help="number of measurements to skip") 
    parser.add_option("-e", "--estimator", dest="estimator", type="str",
                      help="specify a single estimator to reduce") 
    parser.add_option("-i", "--pimcid", dest="pimcid", type="str",
                      help="specify a single pimcid") 
    parser.set_defaults(canonical=False)
    parser.set_defaults(plot=False)
    parser.set_defaults(skip=0)

    # parse the command line options and get the reduce flag
    (options, args) = parser.parse_args() 

    # Determine the working directory
    if args:
        baseDir = args[0]
        if baseDir == '.':
            baseDir = ''
    else:
        baseDir = ''

    skip = options.skip
    
    if (not options.reduce):
        parser.error("need a correct reduce flag (-r,--reduce): [T,N,n,u,t,L,V,W,D]")

    # Check that we are in the correct ensemble
    pimchelp.checkEnsemble(options.canonical)

    dataName,outName = pimchelp.getFileString(options)
    reduceFlag = []
    reduceFlag.append(options.reduce)
    reduceFlag.append(parMap[options.reduce])

    # Create the PIMC analysis helper and fill up the simulation parameters maps
    pimc = pimchelp.PimcHelp(dataName,options.canonical,baseDir=baseDir)
    pimc.getSimulationParameters()

    # Form the full output file name
    if options.R == None:
        outName += '.dat'
    else:
        outName += '-R-%04.1f.dat' % options.R

    # possible types of estimators we may want to reduce
    estList = ['estimator', 'super', 'obdm', 'pair', 'radial', 'number', 
               'radwind', 'radarea', 'planedensity', 'planearea',
               'planewind','virial','linedensity','linepotential']
    estDo = {e:False for e in estList}

    # if we specify a single estimator, only do that one
    if options.estimator:
        estDo[options.estimator] = True
    # otherwise test to see if the file exists
    else:
        for e in estList:
            if pimc.getFileList(e):
                estDo[e] = True
            else:
                estDo[e] = False

    # We first reduce the scalar estimators and output them to disk
    if estDo['estimator']:
        head1,scAve1,scErr1 = getScalarEst('estimator',pimc,outName,reduceFlag,skip=skip)

    if estDo['virial']:
        head1,scAve1,scErr1 = getScalarEst('virial',pimc,outName,reduceFlag,skip=skip)

    if estDo['super']:
        head2,scAve2,scErr2 = getScalarEst('super',pimc,outName,reduceFlag,skip=skip)

    # Now we do the normalized one body density matrix
    if estDo['obdm']:
        x1,ave1,err1 = getVectorEst('obdm',pimc,outName,reduceFlag,'r [A]','n(r)',skip=skip)

    # Now we do the pair correlation function
    if estDo['pair']:
        x2,ave2,err2 = getVectorEst('pair',pimc,outName,reduceFlag,'r [A]','g(r)',skip=skip)

    # The radial Density
    if estDo['radial']:
        x3,ave3,err3 = getVectorEst('radial',pimc,outName,reduceFlag,'r [A]','rho(r)',skip=skip)

    # Compute the number distribution function and compressibility if we are in
    # the grand canonical ensemble
    if estDo['number']:
        x4,ave4,err4 = getVectorEst('number',pimc,outName,reduceFlag,'N','P(N)',skip=skip)

# I don't know why this isn't working, MCStat is giving me an error, will
    # return to this later. AGD 
        #kappa,kappaErr = getKappa(pimc,outName,reduceFlag)

    # The radially averaged Winding superfluid density
    if estDo['radwind']:
        x5,ave5,err5 = getVectorEst('radwind',pimc,outName,reduceFlag,'r [A]','rho_s(r)',skip=skip)

    # The radially averaged area superfliud density
    if estDo['radarea']:
        x6,ave6,err6 = getVectorEst('radarea',pimc,outName,reduceFlag,'r [A]','rho_s(r)',skip=skip)

    if estDo['planewind']:
        x7,ave7,err7 = getVectorEst('planewind',pimc,outName,reduceFlag,'n','rho_s(r)',skip=skip)

    if estDo['planearea']:
        x8,ave8,err8 = getVectorEst('planearea',pimc,outName,reduceFlag,'n','rho_s(r)',skip=skip)

    if estDo['planedensity']:
        x9,ave9,err9 = getVectorEst('planedensity',pimc,outName,reduceFlag,'n','rho(r)',skip=skip)

    if estDo['linedensity']:
        x10,ave10,err10 = getVectorEst('linedensity',pimc,outName,reduceFlag,\
                                       'r [A]','rho1d(r)',skip=skip)
    if estDo['linepotential']:
        x11,ave11,err11 = getVectorEst('linepotential',pimc,outName,reduceFlag,\
                                       'r [A]','V1d(r)',skip=skip)

    # Do we show plots?
    if options.plot:

        figNum = 1
        # Get the changing parameter that we are plotting against
        param = []
        for ID in pimc.id:
            param.append(float(pimc.params[ID][reduceFlag[1]]))
        numParams = len(param)
        markers = loadgmt.getMarkerList()
        colors  = loadgmt.getColorList('cw/1','cw1-029',10)

        # -----------------------------------------------------------------------------
        # Plot the averaged data
        # -----------------------------------------------------------------------------
        if estDo['estimator']:

            headLab = ['E/N','K/N','V/N','N', 'diagonal']
            dataCol = []
            for head in headLab:
                n = 0
                for h in head1:
                    if head == h:
                        dataCol.append(n)
                        break
                    n += 1
            yLabelCol = ['Energy / N', 'Kinetic Energy / N', 'Potential Energy / N',\
                    'Number Particles', 'Diagonal Fraction']

        
            # ============================================================================
            # Figure -- Various thermodynamic quantities
            # ============================================================================
            for n in range(len(dataCol)):
                figure(figNum)
                connect('key_press_event',kevent.press)
        
                errorbar(param, scAve1[:,dataCol[n]], yerr=scErr1[:,dataCol[n]],\
                        color=colors[n],marker=markers[n],markeredgecolor=colors[n],\
                        markersize=8,linestyle='None',capsize=4)
        
                xlabel('%s'%options.reduce)
                ylabel(yLabelCol[n])
                tight_layout()
                figNum += 1
    
        # ============================================================================
        # Figure -- The superfluid density
        # ============================================================================
        if estDo['super']:
            figure(figNum)
            connect('key_press_event',kevent.press)
        
            errorbar(param, scAve2[:,0], yerr=scErr2[:,0],\
                    color=colors[0],marker=markers[0],markeredgecolor=colors[0],\
                    markersize=8,linestyle='None',capsize=4)
        
            tight_layout()
            xlabel('%s'%options.reduce)
            ylabel('Superfluid Density')
    
        # ============================================================================
        # Figure -- The one body density matrix
        # ============================================================================
        if estDo['obdm']:
            figNum += 1
            figure(figNum)
            connect('key_press_event',kevent.press)
            ax = subplot(111)
    
            for n in range(numParams):
                lab = '%s = %s' % (options.reduce,param[n])
                errorbar(x1[n,:], (ave1[n,:]+1.0E-15), err1[n,:],color=colors[n],marker=markers[0],\
                        markeredgecolor=colors[n], markersize=8,linestyle='None',label=lab)
    
                #axis([0,21,1.0E-5,1.1])
            xlabel('r [Angstroms]')
            ylabel('One Body Density Matrix')
            tight_layout()
            legend(loc='best', frameon=False, prop={'size':16},ncol=2)
    
        # ============================================================================
        # Figure -- The pair correlation function
        # ============================================================================
        if estDo['pair']:
            figNum += 1
            figure(figNum)
            connect('key_press_event',kevent.press)
        
            for n in range(numParams):
                lab = '%s = %s' % (options.reduce,param[n])
                errorbar(x2[n,:], ave2[n,:], yerr=err2[n,:],color=colors[n],marker=markers[0],\
                        markeredgecolor=colors[n], markersize=8,linestyle='None',label=lab,capsize=6)
        
                #   axis([0,256,1.0E-5,1.2])
            xlabel('r [Angstroms]')
            ylabel('Pair Correlation Function')
            legend(loc='best', frameon=False, prop={'size':16},ncol=2)
            tight_layout()
    
        # We only plot the compressibility if we are in the grand-canonical ensemble
        if not options.canonical:
    
            # ============================================================================
            # Figure -- The Number distribution
            # ============================================================================
            if estDo['number']:
                figNum += 1
                figure(figNum)
                connect('key_press_event',kevent.press) 

                # Find which column contains the average number of particles
                for hn,h in enumerate(head1):
                    if h == 'N':
                        break

                for n in range(numParams): 
                    lab = '%s = %s' % (options.reduce,param[n]) 
                    aN = scAve1[n,hn] 
                    errorbar(x4[n,:]-aN, ave4[n,:], err4[n,:],color=colors[n],marker=markers[0],\
                             markeredgecolor=colors[n],\
                             markersize=8,linestyle='None',label=lab,capsize=6) 
        
                axis([-30,30,0.0,1.2])
                xlabel(r'$N-\langle N \rangle$')
                ylabel('P(N)')
                tight_layout()
                legend(loc='best', frameon=False, prop={'size':16},ncol=2)
        
                # ============================================================================
                # Figure -- The Compressibility
                # ============================================================================
                #figNum += 1
                #figure(figNum)
                #connect('key_press_event',kevent.press)

                #errorbar(param, kappa, yerr=kappaErr, color=colors[0],marker=markers[0],\
                #        markeredgecolor=colors[0], markersize=8,linestyle='None',capsize=6)
        
                #tight_layout()
                #xlabel('%s'%options.reduce)
                #ylabel(r'$\rho^2 \kappa$')
    
        # ============================================================================
        # Figure -- The radial density
        # ============================================================================
        if len(glob.glob('CYLINDER')) > 0:
            figNum += 1
            figure(figNum)
            connect('key_press_event',kevent.press)
            ax = subplot(111)
    
            for n in range(numParams):
                lab = '%s = %s' % (options.reduce,param[n])
                errorbar(x3[n,:], (ave3[n,:]+1.0E-15), err3[n,:],color=colors[n],marker=markers[0],\
                        markeredgecolor=colors[n], markersize=8,linestyle='None',label=lab)
    
                #axis([0,21,1.0E-5,1.1])
            tight_layout()
            xlabel('r [Angstroms]')
            ylabel('Radial Density')
            legend(loc='best', frameon=False, prop={'size':16},ncol=2)
    
        show()
示例#4
0
def main(): 
    
    # setup the command line parser options 
    parser = argparse.ArgumentParser(description='Plot binning analysis for \
                                            MC Data for Scalar Estimators.')
    parser.add_argument('fileNames', help='Scalar estimator files', nargs='+')
    parser.add_argument('--estimator','-e', help='A list of estimator names \
                                            that are to be plotted.', type=str)
    parser.add_argument('--skip','-s', help='Number of measurements to be \
                        skipped in the binning analysis.', type=int, default=0)
    parser.add_argument('--scale', help='Option to compare binning results \
                        for different parameters', action='store_true')
    args = parser.parse_args()
    
    fileNames = args.fileNames
    scale = args.scale
    
    if len(fileNames) < 1:
        parser.error("Need to specify at least one scalar estimator file")
    
    # We count the number of lines in the estimator file to make sure we have
    # some data and grab the headers
    headers = pimchelp.getHeadersDict(fileNames[0])
    
    # If we don't choose an estimator, provide a list of possible ones
    if not args.estimator or args.estimator not in headers:
        errorString = "Need to specify one of:\n"
        for head,index in headers.iteritems():
            errorString += "\"%s\"" % head + "   "
        parser.error(errorString)
    
    numFiles = len(fileNames)
    col = list([headers[args.estimator]])
    
    # Attempt to find a 'pretty name' for the label, otherwise just default to
    # the column heading
    label = pimchelp.Description()
    try:
        yLong = label.estimatorLongName[args.estimator]
    except:
        yLong = args.estimator
    try:
        yShort = label.estimatorShortName[args.estimator]
    except:
        yShort = args.estimator
    
    # ============================================================================
    # Figure 1 : Error vs. bin level
    # ============================================================================
    figure(1)
    connect('key_press_event',kevent.press)
    
    colors  = loadgmt.getColorList('cw/1','cw1-029',max(numFiles,2))
    
    n = 0
    for fileName in fileNames:
        
        dataFile = open(fileName,'r');
        dataLines = dataFile.readlines();
        dataFile.close()
        
        if len(dataLines) > 2:
            data = loadtxt(fileName,usecols=col)
            if not pyutils.isList(data):
               data = list([data])
            
            delta = MCstat.bin(data[args.skip:])
            if n == 0:
                delta_ar = np.zeros((numFiles,delta.shape[0]))
            delta_ar[n,:] = delta.T
            #delta_ar[n,:len(delta)] = delta.T
            n += 1
    
    if n > 1:
        if scale:
            for m in range(n):
                plot(np.arange(len(delta_ar)),delta_ar[m],marker='s',markersize=4,\
                         linestyle='-',linewidth=1.0,color=colors[m],\
                         markeredgecolor=colors[m])
        else:
            Delta = np.average(delta_ar,0)
            dDelta = np.std(delta_ar,0)/np.sqrt(n)             
            errorbar(np.arange(len(Delta)),Delta,dDelta,marker='s',markersize=4,\
                     linestyle='-',linewidth=1.0,color=colors[0],\
                     markeredgecolor=colors[0])
            bin_ac = MCstat.bin_ac(Delta,dDelta)
            bin_conv = MCstat.bin_conv(Delta,dDelta)
            print 'Convergence Ratio: %1.2f+/-%1.2f'%(bin_conv['CF'],bin_conv['dCF'])
            print 'autocorrlelation time: %2.1f+/-%2.1f' % \
                                                (bin_ac['tau'],bin_ac['dtau'])
    else:
        plot(delta,marker='s',markersize=4,linestyle='-',linewidth=1.0,\
             color=colors[0],markeredgecolor=colors[0])
        print 'Convergence Ratio: %1.3f' % MCstat.bin_conv(delta)['CF']
        print 'autocorrlelation time: %3.3f' % MCstat.bin_ac(delta)['tau']
    
    ylabel(r"$\Delta_l$")
    xlabel("$l$")
    title("Bin scaling: "+yLong)
    
    show()
示例#5
0
def main(): 

    # parse the command line options
    args = docopt(__doc__)

    fileNames = args['<file>']
    skip = int(args['--skip'])
    period = int(args['--period'])
    estimators = args['--estimator']
    leglabel = args['--legend'] and args['--legend']
    error = args['--error'] and float(args['--error'])

    # number of estimators must equal number of filenames given
    if len(fileNames) != len(estimators):
        print "\nNumber of estimators must equal number of filenames supplied."
        print "Note that these must be in the same order!\n"
        sys.exit()
    
    # if labels are not assigned, we default to the PIMCID
    if not leglabel:
        leglabel = []
        for n,fileName in enumerate(fileNames):
            leglabel.append(fileName[-13:-4])
    
    numFiles = len(fileNames)
    
    # first load all of data from all files into a list
    col = []
    data = []
    for numEst in range(len(estimators)):
        headers = pimchelp.getHeadersDict(fileNames[numEst])
        col = list([headers[estimators[numEst]]])

        dataFile = open(fileNames[numEst],'r');
        dataLines = dataFile.readlines();
        dataFile.close()
    
        if len(dataLines) > 2:
            data.append(loadtxt(fileNames[numEst],usecols=col,unpack=True))

    # loop over files, loading them and plotting all data wanted.
    for numEst in range(len(estimators)):
     
        # We count the number of lines in the estimator file to make sure we have
        # some data and grab the headers
        headers = pimchelp.getHeadersDict(fileNames[numEst])
       
        # If we don't choose an estimator, provide a list of possible ones
        if estimators[numEst] not in headers:
            errorString = "Need to specify one of:\n"
            for head,index in headers.iteritems():
                errorString += "\"%s\"" % head + "   "
            parser.error(errorString)

        # Attempt to find a 'pretty name' for the label, otherwise just default to
        # the column heading
        label = pimchelp.Description()
        try:
            yLong = label.estimatorLongName[estimators[numEst]]
        except:
            yLong = estimators[numEst]
        try:
            yShort = label.estimatorShortName[estimators[numEst]]
        except:
            yShort = estimators[numEst]

        # ============================================================================
        # Figure 1 : column vs. MC Steps
        # ============================================================================
        figNum = 1
        
        if args['--pdf']:
            figure(figNum, dpi=40, figsize=(6,3.8))
        else:
            figure(figNum)
        connect('key_press_event',kevent.press)

        colors  = loadgmt.getColorList('oc','rainbow',max(numFiles,2))

        for n,cdata in enumerate(data):
            plot(cdata[skip:],marker='s',color=colors[n],markeredgecolor=colors[n],\
                 markersize=4,linestyle='-',linewidth=1.0, label=leglabel[n])

        ylabel(yLong)
        xlabel("MC Bin Number")
        if numEst == 0:
            legend(loc=3, frameon=False, ncol=2)

        if args['--pdf']:
            savefig('col_vs_MCSteps.pdf', format='pdf',
                    bbox_inches='tight')
            savefig('col_vs_MCSteps_trans.pdf', format='pdf',
                    bbox_inches='tight', transparent=True, dpi=40)
        else:
            savefig('col_vs_MCSteps_trans.png', format='png',
                    bbox_inches='tight', transparent=True)

        # ============================================================================
        # Figure 2 : running average of column vs. MC Bins
        # ============================================================================
        figNum += 1
        
        if args['--pdf']:
            figure(figNum, dpi=40, figsize=(6,3.8))
        else:
            figure(figNum, figsize=(6,3.8))
        connect('key_press_event',kevent.press)

        n = 0
        for n,cdata in enumerate(data):
            
            if size(cdata) > 1:
                
                # Get the cumulative moving average
                if args['--error']:
                    cma = cumulativeMovingAverage(cdata[skip:])
                    sem = error*ones_like(cma)
                elif args['--bin']:
                    cma = cumulativeMovingAverage(cdata[skip:])
                    ave,err = getStats(cdata[skip:])
                    sem = err*ones_like(cma)
                    print '%s:  %s = %8.4E +- %8.4E' % (leglabel[n],yShort, ave,err) 
                else:
                    cma,sem = cumulativeMovingAverageWithError(cdata[skip:])

                sma = simpleMovingAverage(50,cdata[skip:])
                x = range(int(0.10*len(cma)),len(cma))
                plot(x,cma[x],color=colors[n],linewidth=1.0,marker='None',linestyle='-',
                    label=leglabel[n])
                fill_between(x, cma[x]-sem[x], cma[x]+sem[x],color=colors[n], alpha=0.1)
                #n += 1

        ylabel(yLong)
        xlabel("MC Bin Number")
        
        if numEst == 0:
            leg = legend(loc='best', frameon=False, prop={'size':12},markerscale=2, ncol=2)
        for l in leg.get_lines():
            l.set_linewidth(4.0)

        if args['--pdf']:
            savefig('runAve_vs_MCSteps.pdf', format='pdf',
                    bbox_inches='tight')
            savefig('runAve_vs_MCSteps_trans.pdf', format='pdf',
                    bbox_inches='tight',transparent=True, dpi=40)
        else:
            savefig('runAve_vs_MCSteps_trans.png', format='png',
                    bbox_inches='tight',transparent=True)

        # Perform a Welch's t-test
        if args['--ttest']:
            # We only perform the Welch's t test if we have multiple samples we are
            # comparing
            N = len(data)
            if N > 1:
                tval = zeros([N,N])
                p = zeros([N,N])

                for i in range(N):
                    for j in range(i+1,N):
                        tval[i,j],p[i,j] = stats.ttest_ind(data[i][skip:], data[j][skip:], 
                                equal_var=False)
            figNum += 1
            # ============================================================================
            # Figure 3 : plot the estimator histogram along with t-test values
            # ============================================================================
            if args['--pdf']:
                fig = figure(figNum, dpi=40, figsize=(6,3.8))
            else:
                fig = figure(figNum)
            connect('key_press_event',kevent.press)
            for i in range(N):
                n, bins, patches = hist(data[i], 100, normed=True, facecolor=colors[i], 
                        alpha=0.75, label=leglabel[i],
                        edgecolor='w')
            '''# Add the p-values from the t-test
            y = 0.92
            if N > 1:
                figtext(0.78, y, 't-test p values', horizontalalignment='center', 
                     verticalalignment='top', fontsize=15, backgroundcolor='white')

                for i in range(N):
                    for j in range(i+1,N):
                        y -= 0.03
                        lab = 'p(' + leglabel[i] + ' - ' + leglabel[j] + ') = ' + '%4.2f'%p[i,j]
                        figtext(0.78, y, lab, horizontalalignment='center', 
                             verticalalignment='top', fontsize=12,
                           backgroundcolor='white')'''

            #legend(loc='upper left', fontsize=15, frameon=False)
            if numEst == 0:
                legend(loc='upper left', frameon=False)
            xlabel(yLong)
            yLabb = estimators[numEst]
            if yLabb == 'Ecv/N':
                yLabb = 'E/N'
            ylabel(r'$P($' + yLabb + r'$)$')


            if args['--pdf']:
                savefig('ttest_histogram.pdf', format='pdf',
                        bbox_inches='tight')
                savefig('ttest_histogram_trans.pdf', format='pdf',
                        bbox_inches='tight', transparent=True, dpi=40)
            else:
                savefig('ttest_histogram_trans.png', format='png',
                        bbox_inches='tight', transparent=True)
    
        # ============================================================================
        # Figure 4 : autocorrelation
        # ============================================================================
        figNum += 1
        
        if args['--pdf']:
            figure(figNum, dpi=40, figsize=(6,3.8))
        else:
            figure(figNum)
        connect('key_press_event',kevent.press)

        colors  = loadgmt.getColorList('oc','rainbow',max(numFiles,2))

        mcTime = arange(0,len(cdata[skip:]),1)

        for n,cdata in enumerate(data):
            plot(mcTime,estimated_autocorrelation(cdata[skip:]),
                marker='s',color=colors[n],markeredgecolor=colors[n],
                markersize=4,linestyle='-',linewidth=1.0, label=leglabel[n])

        ylabel("Autocorrelation")
        xlabel("Data")
        if numEst == 0:
            legend(loc=3, frameon=False, ncol=2)

        '''if args['--pdf']:
            savefig('autocorrelation.pdf', format='pdf',
                    bbox_inches='tight')
            savefig('autocorrelation_trans.pdf', format='pdf',
                    bbox_inches='tight', transparent=True, dpi=40)
        else:
            savefig('autocorrelation_trans.png', format='png',
                    bbox_inches='tight', transparent=True)
        '''
        
    show()