def draw_single_pages() : 
    def make_lines(ndata,fullpage_metric) :
        # make horizontal data sets for metric and mean
        fullpage = np.ones_like(ndata) * fullpage_metric
        m = np.ones_like(ndata) * np.mean(ndata)
        print "mean=",np.mean(ndata)
        return np.column_stack((ndata,fullpage,m))

    base = "300_winder_rast/imagesAndgTruth/"
    # draw a few results from single pages
    outfilename = "winder_full_rast_double_2col300_1.png"
    if not os.path.exists(outfilename): 
        ndata = datfile.load(base+"Double_Column/300dpi/2col300_1/2col300_1.dat")
        plotit( make_lines(ndata,1.0),
                    outfilename, title="Winder RAST DoubleColumn 2col300_1", fmt="-" )

    outfilename = "winder_full_rast_double_pic_2col300_2.png"
    if not os.path.exists(outfilename): 
        ndata = datfile.load(base+"Double_Column_Pictures/300dpi/2colpic300_2/2colpic300_2.dat")
        plotit( make_lines(ndata,.78), outfilename, 
                title="Winder RAST Double Column Picture 2col300_2", 
                fmt="-" )

    outfilename = "winder_full_rast_double_sci_2col300_3.png"
    if not os.path.exists(outfilename): 
        ndata = datfile.load(base+"Double_Column_Pictures_Scientific/300dpi/2colpic300_3/2colpic300_3.dat")
        plotit( make_lines(ndata,.56), outfilename, 
                title="Winder RAST Double Column Scientific Picture 2col300_3", 
                fmt="-" )
def get_winder_class_results(class_dir) :
    # load all .dat files corresponding to each class of image in the Winder
    # data set

    # gather all the datafiles from the fullpage winder
    fullpage_winder = datfile.find_all(class_dir)

    class_data = []
    class_names = []
    for datfilename in fullpage_winder : 
        ndata = datfile.load(datfilename)
        basename = get_basename(datfilename)
        class_data.append( np.mean(ndata) )
        class_names.append( basename.replace( "_"," ") )

    return (class_data,class_names)
def load_all_datfiles( dirname ) : 
    metrics = None

    for root,dirs,files in os.walk(dirname) :
#        print "root=",root
#        print "dirs=",dirs
#        print "files=",files
        for f in files : 
            path=os.path.join(root,f)
            if path.endswith(".dat") : 
#                print "path=",os.path.join(root,f)
                ndata = datfile.load( path )
#                print ndata

                if metrics is None : 
                    metrics = ndata
                    ndata = None
                else :
                    metrics = np.append( metrics, ndata )

    return metrics
def main() : 
    if len(sys.argv) < 2 : 
        usage()
        return

    metrics = None

    for datfile_name in sys.argv[1:] : 
        print datfile_name
        ndata = datfile.load( datfile_name ) 
#        print ndata
        if metrics is None : 
            metrics = ndata
            ndata = None
        else :
            metrics = np.append( metrics, ndata )
        print metrics

    print metrics.shape

    np.save('metrics.npy',metrics)
    make_histogram( metrics, "out.png" )