예제 #1
0
def main():

    if not consistentMap():
        print "The map is inconsistent with the C++ reader."
        ans = raw_input("Proceed? [y]/n")
        if ans in ["n", "no"]:
            sys.exit(1)

    else:
        print "Map consistent"

    stdoutToFile, mpiFlag, openGUI, n_cores = parseCML(sys.argv)
    codename = getCodename(sys.argv)
    makeJobScript = getJobFlag(sys.argv)

    print "MPI nodes: ", n_cores

    if len(sys.argv) == 1:
        CMLargs, dirs, superDir = parseFiles(openGUI, codename)
    else:
        dirs = [pjoin(paths.scratchPath, "QMC_SCRATCH")]
        setOutPath(sys.argv, dirs[0])
        CMLargs = [convertToCMLargs(sys.argv[1:])]

        superDir = None

    initRuns(CMLargs, dirs, superDir, stdoutToFile, mpiFlag, openGUI, n_cores,
             makeJobScript)
예제 #2
0
파일: runQMC.py 프로젝트: joebradly/QMC2
def main():
    
    if not consistentMap():
        print "The map is inconsistent with the C++ reader."
        ans = raw_input("Proceed? [y]/n")
        if ans in ["n", "no"]:
            sys.exit(1)

    else:
        print "Map consistent"
    
    stdoutToFile, mpiFlag, openGUI, n_cores = parseCML(sys.argv)
    codename = getCodename(sys.argv)
    makeJobScript = getJobFlag(sys.argv)

    print "MPI nodes: ", n_cores
    
    if len(sys.argv) == 1:
        CMLargs, dirs, superDir = parseFiles(openGUI, codename)
    else:
        dirs = [pjoin(paths.scratchPath, "QMC_SCRATCH")]
        setOutPath(sys.argv, dirs[0])
        CMLargs = [convertToCMLargs(sys.argv[1:])]
        
        superDir = None
    
    initRuns(CMLargs, 
             dirs, 
             superDir, 
             stdoutToFile, 
             mpiFlag,
             openGUI, 
             n_cores,
             makeJobScript)
예제 #3
0
파일: reCalcDist.py 프로젝트: liangjj/QMC2
def main():
    
    stdoutToFile, mpiFlag, openGUI, n_cores = parseCML(sys.argv)
    print "MPI Nodes: ", n_cores
    
    #path N binEdge
    if len(sys.argv) < 3 or len(sys.argv) > 6:
        print "Error in command line arguments. [rawdata, N, bin egdes ...]"
        sys.exit(1)    
        
    rawfile = sys.argv[1]

    if 'rawdata' not in rawfile:
        print "Selected file is not a distribution data file."
        sys.exit(1)
    
    N = sys.argv[2]
    bin_edge = sys.argv[3]
    
    name = re.findall("dist_rawdata_(.+).arma", rawfile)[0]
    n_p = re.findall("(\d+)c\d", name)[0]
    path = rawfile.split("walker_positions")[0]

    initRun(n_p, path, name, N, bin_edge, n_cores, mpiFlag, openGUI)
예제 #4
0
파일: reCalcDist.py 프로젝트: rainson/QMC2
def main():
    
    stdoutToFile, mpiFlag, openGUI, n_cores = parseCML(sys.argv)
    print "MPI Nodes: ", n_cores
    
    #path N binEdge
    if len(sys.argv) < 3 or len(sys.argv) > 6:
        print "Error in command line arguments. [rawdata, N, bin egdes ...]"
        sys.exit(1)    
        
    rawfile = sys.argv[1]

    if 'rawdata' not in rawfile:
        print "Selected file is not a distribution data file."
        sys.exit(1)
    
    N = sys.argv[2]
    bin_edge = sys.argv[3]
    
    name = re.findall("dist_rawdata_(.+).arma", rawfile)[0]
    n_p = re.findall("(\d+)c\d", name)[0]
    path = rawfile.split("walker_positions")[0]

    initRun(n_p, path, name, N, bin_edge, n_cores, mpiFlag, openGUI)
예제 #5
0
def main():

    stdoutToFile, mpiFlag, openGUI, n_cores = parseCML(sys.argv)
    
    openGUI = openGUI&(not forceTerminal)

    makeJobScript = getJobFlag(sys.argv)

    if forceTerminal: 
        display = displayTerminal
        selectFile = selectFileTerminal
        getYesNo = getYesNoTerminal
        getParams = getParamsTerminal
        
    else:
        display = lambda a : None
        selectFile = selectFileGUI
        getYesNo = getYesNoGUI
        getParams = getParamsGUI

    print "MPI nodes: ", n_cores
    
    if len(sys.argv) > 1:
        mainDir = sys.argv[1]
        if not os.path.exists(mainDir):
            print "First CML arg must be an existing path."
            sys.exit(1)
            
        fixedParams = {"dmc": [0,0,0], "vmc": [0,0,0]}
        
        #If we supply the correct CML args, we can
        #draw all runs under one comb, saving time.
        if len(sys.argv) > 2:
            for arg in sys.argv[2:]:
                key, val = arg.split("=")
                try:
                    fixedParams[key] = eval(val)
                except:
                    print "Invalid CML arg: ", arg
                    sys.exit(1)
            
            print "successfully initialized blocking runs in path:"
            print mainDir
            print 
            print "with parameters:"
            print fixedParams
            print
            proceed = raw_input("Continue? [y]")
            
            if proceed in ["", "y", "Y", "yes"]:
                initializeCoumbRuns(mainDir, fixedParams, 
                                    n_cores, mpiFlag,
                                    makeJobScript)
                sys.exit(0)
                
            else:
                print "goodbye!"
                sys.exit(1)

            
    else:
        mainDir = pjoin(paths.scratchPath, "QMC_SCRATCH")
    
    if not forceTerminal:
        try:
            app = QApplication(sys.argv)
        except RuntimeError:
            app = QCoreApplication.instance() 
    
    active = True
    GUIopened = False
    while active:
        
        blockFile = selectFile(mainDir)
        
        if not blockFile:
            print "No file selected. Breaking..."
            break
        
        path, fileName = os.path.split(blockFile)
        
        if openGUI and not GUIopened:
            subprocess.Popen(["python", pjoin(paths.toolsPath, 'qmcGUI.py'),\
                path, ">", pjoin(path, "GUI_out.txt")]) 
            GUIopened = True
        
        localSatisfaction = False
        lastParams = None
    
        while not localSatisfaction:
             
            lastParams = getParams(blockFile, lastParams, n_cores)
                
            if lastParams is None:
                break

            initRun(n_cores, mpiFlag,
                    fileName, path,
                    blockFile,
                    lastParams,
                    makeJobScript,
                    display)
                                        
            
            if makeJobScript:
                localSatisfaction = True
            else:
                localSatisfaction = getYesNo("Satisfied with result?")
            
        
        active = getYesNo("View more files?")
    
    if not makeJobScript:
        if getYesNo("Save figs to file?"):
            
            plotTool = Blocking(toFile=True)        
            
            for root, dirs, files in os.walk(mainDir):
                
                if root == mainDir:
                    continue
                
                for outfile in files:
                    if re.findall(plotTool.nametag, outfile):
                        plotTool.filepath = pjoin(root, outfile)
                        plotTool.mainloop()
    
    if not forceTerminal:
        app.exit()
예제 #6
0
def main():
        
    copy=True
    stdoutToFile, MPI_flag, openGUI, n_cores = parseCML(sys.argv)
    print "MPI Nodes: ", n_cores

    if "-noCopy" in sys.argv:
        copy=False
        sys.argv.remove("-noCopy")

    if len(sys.argv) < 3:
        sys.exit("Sufficinet cml args not supplied. (VMC rawdata, DMC dist file)")
    if not "vmc" in sys.argv[1] or not "dmc" in sys.argv[2]:
        sys.exit("Incorrect input type. (VMC rawdata, DMC dist file)")
    
    
    DMC_dist = sys.argv[2]
    VMC_raw_path, VMC_raw_name = os.path.split(sys.argv[1])
    DMC_dist_path, DMC_dist_name = os.path.split(DMC_dist)
    ending = re.findall("\.(arma)$|\.(arma3D)$", DMC_dist_name)[0]    
    
    for entry in ending:
        if entry:
            ending = entry
            break
    print ending
    if len(sys.argv) > 3:
        N = sys.argv[3]
    else:
        N = "200"
    
    VMC_name = re.findall("dist_rawdata_(.+?)vmc\.arma", VMC_raw_name)[0]
    DMC_name = re.findall("dist_out_(.+?)dmc_", DMC_dist_name)[0]
    
    if VMC_name != DMC_name:
        raise Exception("Distributions does not match. (%s != %s)" % (VMC_name, DMC_name))
    
    n_p = re.findall("(\d+)c\d+", VMC_name)[0]
    bin_edge = re.findall("dist_out.+?dmc_edge(\d+\.?\d*)\.arma", DMC_dist_name)[0]
    
#    print n_p
#    print bin_edge
#    print N    
#    print VMC_raw_path
#    print VMC_raw_name
#    print "-----"
   
    
    recalcVMCdist(VMC_raw_path, VMC_raw_name, n_p, bin_edge, N, n_cores, MPI_flag)
    
    new_dir = pjoin("OneBodyDensities", DMC_name)
    new_path = pjoin(paths.scratchPath, new_dir)

    new_VMC_dist = "dist_out_%svmc_edge%s.%s" % (VMC_name, bin_edge, ending)
    new_VMC_dist_rad = "radial_out_%svmc_edge%s.arma" % (VMC_name, bin_edge)
    
    DMC_dist_rad = "radial_out_%sdmc_edge%s.arma" % (DMC_name, bin_edge)
    
#    print new_path
#    print new_VMC_dist
#    print new_VMC_dist_rad
#    print DMC_dist    
#    print DMC_dist_rad
    
    if not copy:
        return 0
        
    
    if not os.path.exists(new_path):
        os.mkdir(new_path)
        
    shutil.copy(pjoin(VMC_raw_path, new_VMC_dist), new_path)
    shutil.copy(pjoin(VMC_raw_path, new_VMC_dist_rad), new_path)
    

    shutil.copy(pjoin(DMC_dist_path, DMC_dist_rad), new_path)
    shutil.copy(DMC_dist, new_path)    
예제 #7
0
def main():

    copy = True
    stdoutToFile, MPI_flag, openGUI, n_cores = parseCML(sys.argv)
    print "MPI Nodes: ", n_cores

    if "-noCopy" in sys.argv:
        copy = False
        sys.argv.remove("-noCopy")

    if len(sys.argv) < 3:
        sys.exit(
            "Sufficinet cml args not supplied. (VMC rawdata, DMC dist file)")
    if not "vmc" in sys.argv[1] or not "dmc" in sys.argv[2]:
        sys.exit("Incorrect input type. (VMC rawdata, DMC dist file)")

    DMC_dist = sys.argv[2]
    VMC_raw_path, VMC_raw_name = os.path.split(sys.argv[1])
    DMC_dist_path, DMC_dist_name = os.path.split(DMC_dist)
    ending = re.findall("\.(arma)$|\.(arma3D)$", DMC_dist_name)[0]

    for entry in ending:
        if entry:
            ending = entry
            break
    print ending
    if len(sys.argv) > 3:
        N = sys.argv[3]
    else:
        N = "200"

    VMC_name = re.findall("dist_rawdata_(.+?)\.arma", VMC_raw_name)[0]
    DMC_name = re.findall("dist_out_(.+?)_edge", DMC_dist_name)[0]

    if VMC_name.replace("vmc", "dmc") != DMC_name:
        raise Exception("Distributions does not match. (%s != %s)" %
                        (VMC_name, DMC_name))

    n_p = re.findall("N(\d+)\w", VMC_name)[0]
    bin_edge = re.findall("dist_out.+?_edge(\d+\.?\d*)\.arma",
                          DMC_dist_name)[0]

    #    print n_p
    #    print bin_edge
    #    print N
    #    print VMC_raw_path
    #    print VMC_raw_name
    #    print "-----"

    recalcVMCdist(VMC_raw_path, VMC_raw_name, n_p, bin_edge, N, n_cores,
                  MPI_flag)

    new_dir = pjoin("OneBodyDensities", DMC_name.replace("dmc", ""))
    new_path = pjoin(paths.scratchPath, new_dir)

    new_VMC_dist = "dist_out_%s_edge%s.%s" % (VMC_name, bin_edge, ending)
    new_VMC_dist_rad = "radial_out_%s_edge%s.arma" % (VMC_name, bin_edge)

    DMC_dist_rad = "radial_out_%s_edge%s.arma" % (DMC_name, bin_edge)

    #    print new_path
    #    print new_VMC_dist
    #    print new_VMC_dist_rad
    #    print DMC_dist
    #    print DMC_dist_rad

    if not copy:
        return 0

    if not os.path.exists(new_path):
        mkdir_p(new_path)

    shutil.copy(pjoin(VMC_raw_path, new_VMC_dist), new_path)
    shutil.copy(pjoin(VMC_raw_path, new_VMC_dist_rad), new_path)

    shutil.copy(pjoin(DMC_dist_path, DMC_dist_rad), new_path)
    shutil.copy(DMC_dist, new_path)
예제 #8
0
def main():

    stdoutToFile, mpiFlag, openGUI, n_cores = parseCML(sys.argv)

    global forceTerminal

    if not openGUI:
        forceTerminal = True

    makeJobScript = getJobFlag(sys.argv)

    if forceTerminal:
        display = displayTerminal
        selectFile = selectFileTerminal
        getYesNo = getYesNoTerminal
        getParams = getParamsTerminal

    else:
        display = lambda a: None
        selectFile = selectFileGUI
        getYesNo = getYesNoGUI
        getParams = getParamsGUI

    print "MPI nodes: ", n_cores

    if len(sys.argv) > 1:
        mainDir = sys.argv[1]
        if not os.path.exists(mainDir):
            print "First CML arg must be an existing path."
            sys.exit(1)

        fixedParams = {"dmc": [0, 0, 0], "vmc": [0, 0, 0]}

        #If we supply the correct CML args, we can
        #draw all runs under one comb, saving time.
        if len(sys.argv) > 2:
            for arg in sys.argv[2:]:
                key, val = arg.split("=")
                try:
                    fixedParams[key] = eval(val)
                except:
                    print "Invalid CML arg: ", arg
                    sys.exit(1)

            print "successfully initialized blocking runs in path:"
            print mainDir
            print
            print "with parameters:"
            print fixedParams
            print
            proceed = raw_input("Continue? [y]")

            if proceed in ["", "y", "Y", "yes"]:
                initializeCoumbRuns(mainDir, fixedParams, n_cores, mpiFlag,
                                    makeJobScript)
                sys.exit(0)

            else:
                print "goodbye!"
                sys.exit(1)

    else:
        mainDir = pjoin(paths.scratchPath, "QMC_SCRATCH")

    if not forceTerminal:
        try:
            app = QApplication(sys.argv)
        except RuntimeError:
            app = QCoreApplication.instance()

    active = True
    GUIopened = False
    while active:

        blockFile = selectFile(mainDir)

        if not blockFile:
            print "No file selected. Breaking..."
            break

        path, fileName = os.path.split(blockFile)

        if openGUI and not GUIopened:
            subprocess.Popen(["python", pjoin(paths.toolsPath, 'qmcGUI.py'),\
                path, ">", pjoin(path, "GUI_out.txt")])
            GUIopened = True

        localSatisfaction = False
        lastParams = None

        while not localSatisfaction:

            lastParams = getParams(blockFile, lastParams, n_cores)

            if lastParams is None:
                break

            initRun(n_cores, mpiFlag, fileName, path, blockFile, lastParams,
                    makeJobScript, display)

            if makeJobScript:
                localSatisfaction = True
            else:
                localSatisfaction = getYesNo("Satisfied with result?")

        active = getYesNo("View more files?")

    if not makeJobScript:
        if getYesNo("Save figs to file?"):

            plotTool = Blocking(toFile=True)

            for root, dirs, files in os.walk(mainDir):

                for outfile in files:
                    if re.findall(plotTool.nametag, outfile):
                        plotTool.filepath = pjoin(root, outfile)
                        print "Figurizing", plotTool.filepath
                        plotTool.mainloop()

    if not forceTerminal:
        app.exit()