示例#1
0
        elif option == "fit":
            fit.main(idata, status, case, dargs["fit"])
        elif option == "plot":
            plot.main(case, dargs["plot"])
        print("")
        print(" ===========================================================")
        break

    # User asked for nothing. Print help!
    if not IN_OPTS:
        print_string(HELP_main, 2)
        return

    # Print elapsed time
    t2 = time.time()
    timeline = "| Total Elapsed Time: %5.1f %5s |" % time2human(
        t2 - t1, "secs")
    print(" " * 25 + "-" * len(timeline))
    print(" " * 25 + timeline)
    print(" " * 25 + "-" * len(timeline))
    print("")


#==========================================================#

#==========================================================#
if __name__ == '__main__':
    try:
        main()
    except Exception as exception:
        deal_with_exception(exception)
#==========================================================#
示例#2
0
def print_elapsed(delta_time, nibs):
    t, units = time2human(delta_time)
    sprint("--------------------------------", NIBS)
    sprint("Elapsed time: %.2f %s" % (t, units), nibs)
    sprint("--------------------------------", NIBS)
    sprint()
示例#3
0
            for species in yvalues.keys():
                fratios["%7.2f"%temp][species] = yvalues[species][-1] / POP0
            # print data from simulation
            print_string(PS.skmc_results(xvalues,yvalues,timeunits),9)
            # save data needed for txt and pdf files
            data += [ ("%.2f"%temp,xvalues,yvalues) ]
            ftimes.append(xvalues[-1])

        # print final ratios
        species = sorted(yvalues.keys())
        print_string(PS.skmc_finaltimes(ltemp,ftimes,timeunits),5)
        print_string(PS.skmc_finalratio(ltemp,species,fratios),5)

        # save data for plotting
        if plotfile is not None:
           plotdata = {}
           plotdata.update(manage_data_for_plot_kmc(target,data,fratios,volume,timeunits))
           write_plotfile(plotfile,plotdata)
        #kmc_savedata(kmcof,data)

        # print end of file
        t2    = time.time()
        etime = time2human(t2-t1,"secs")
        sys.stdout.writeinfile(PS.end_txt(*etime))
        # End logger
        sys.stdout = Logger(None)

#---------------------------------------------------------------#


示例#4
0
def main():
    date = time.strftime("%Y/%m/%d %H:%M")
    t1 = time.time()

    # Read user arguments
    user_args = sys.argv[1:]
    if len(user_args) == 0:
       print PROGNAME
       print AUTHORINFO
       print_string(HELP_main,2)
       return
    dargs = classify_args(user_args)

    # User asked for version
    if   "version"    in dargs.keys():
       print "Current version: %s"%VERSION
       return

    # User asked for help
    elif "help"    in dargs.keys():
       print PROGNAME
       print AUTHORINFO
       if len(dargs["help"]) == 0   : print_string(HELP_main  ,2)
       if "gather"  in dargs["help"]: print_string(HELP_gather,1)
       if "input"   in dargs["help"]: print_string(HELP_input ,1)
       if "ics"     in dargs["help"]: print_string(HELP_ics   ,1)
       if "pfn"     in dargs["help"]: print_string(HELP_pfn   ,1)
       if "path"    in dargs["help"]: print_string(HELP_path  ,1)
       if "hlcalc"  in dargs["help"]: print_string(HELP_hlcalc,1)
       if "rcons"   in dargs["help"]: print_string(HELP_rcons ,1)
       if "fit"     in dargs["help"]: print_string(HELP_fit   ,1)
       if "kmc"     in dargs["help"]: print_string(HELP_kmc   ,1)
       if "plot"    in dargs["help"]: print_string(HELP_plot  ,1)
       return

    # Print logo and current date
    print PROGNAME
    print AUTHORINFO
    print
    print " -----------------------------------------------------------"
    print "  Current date: %s"%date
    print " -----------------------------------------------------------"
    print 

    # check some arguments
    dargs    = check_ics(dargs)
    software = check_sft(dargs)
    dlevel   = check_dlevel(dargs)

    # --software used properly
    if software is None:
       print "  Software option has to be followed by an argument!"
       print
       exit()

    # Act according user argument
    IN_OPTS = False
    for option in "ls,gather,input,ics,pfn,path,hlcalc,rcons,kmc,fit,plot".split(","):
        if option not in dargs.keys(): continue
        IN_OPTS = True
        # read input files and print table
        idata, status, string = get_input_data()
        print_string(string,nbs=3)
        # data files according to case
        datafiles,string = dlevel_to_files(dlevel)
        if option in "pfn,path,hlcalc,rcons,kmc,fit,plot".split(","):
           print_string(string,nbs=3)
        case = (datafiles,dlevel,software)
        # execute pilgrim with option
        print  " ==========================================================="
        print  " ||  EXECUTING PILGRIM WITH --%-6s                      ||"%option
        print  " ==========================================================="
        print
        if   option == "ls"    :  gather.ls_struc(idata[0][0])
        elif option == "gather":  gather.main(idata,status                      )
        elif option == "input" : inpmenu.main(idata,status                      )
        elif option == "ics"   :     ics.main(idata,status,*dargs["ics"   ]     )
        elif option == "pfn"   :     pfn.main(idata,status,case, dargs["pfn"   ])
        elif option == "path"  :    path.main(idata,status,case, dargs["path"  ])
        elif option == "hlcalc":  hlcalc.main(idata,status,case, dargs["hlcalc"])
        elif option == "rcons" :   rcons.main(idata,status,case, dargs["rcons" ])
        elif option == "kmc"   :     kmc.main(idata,status,case                 )
        elif option == "fit"   :     fit.main(idata,status,case, dargs["fit"   ])
        elif option == "plot"  :    plot.main(             case, dargs["plot"  ])
        print
        print " ===========================================================\n"
        break

    # User asked for nothing. Print help!
    if not IN_OPTS: print_string(HELP_main,2); return


    # Print elapsed time
    t2 = time.time()
    timeline = "Total Elapsed Time: %5.1f %5s |"%time2human(t2-t1,"secs")
    print "                            "+timeline
    print "                            "+"-"*len(timeline)
示例#5
0
        pathvars = copy.deepcopy(dpath[ctc])
        # isotopic modification?
        masses = get_masses(target, dctc, dimasses)
        pathvars.set_masses(masses)
        # calculate path + coefficients
        idata = (target, dlevel, software, ltemp, dctc, pathvars, dtesLL,
                 dchem, dhighlvl, dimasses)
        try:
            dcoefs, pathvars = deal_with_path(*idata)
        except Exception as exception:
            deal_with_exception(exception)
            sys.stdout = Logger(None)
            continue
        # print end of file
        t2 = time.time()
        etime = fncs.time2human(t2 - t1, "secs")
        sys.stdout.writeinfile(PS.end_txt(*etime))
        # update file (read, check ltemp, update, write)
        sys.stdout = Logger(None)
        fncs.print_string("Updating data file: %s" % dof, 3)
        dall = RW.read_alldata(dof, ltemp)[0]
        for coef in dcoefs.keys():
            dall[coef][target] = dcoefs[coef]
        RW.write_alldata(dof, ltemp, dall)
        print("")
        # collect garbage
        gc.collect()

    # print WARNINGS
    if len(WARNINGS) != 0:
        fncs.print_string("WARNINGS:", 3)
示例#6
0
def main():
    cdate = time.strftime("%Y-%m-%d")
    ctime = time.strftime("%H:%M:%S")
    t1 = time.time()

    # Read user arguments
    user_args = sys.argv[1:]
    if len(user_args) == 0:
       print(PROGNAME)
       print(PROGHEAD)
       print(AUTHORINFO)
       print_string(HELP_main,2)
       return
    dargs = classify_args(user_args)

    # User asked for version
    if "version" in dargs.keys() or "-v" in user_args:
       print("Current version: %s"%VERSION)
       return

    # User asked for help
    elif "help"    in dargs.keys():
       print(PROGNAME)
       print(PROGHEAD)
       print(AUTHORINFO)
       if len(dargs["help"]) == 0   : print_string(HELP_main   ,2)
       if "gather"  in dargs["help"]: print_string(HELP_gather ,1)
       if "input"   in dargs["help"]: print_string(HELP_input  ,1)
       if "ics"     in dargs["help"]: print_string(HELP_ics    ,1)
       if "pfn"     in dargs["help"]: print_string(HELP_pfn    ,1)
       if "path"    in dargs["help"]: print_string(HELP_path   ,1)
       if "hlcalc"  in dargs["help"]: print_string(HELP_hlcalc ,1)
       if "rcons"   in dargs["help"]: print_string(HELP_rcons  ,1)
       if "fit"     in dargs["help"]: print_string(HELP_fit    ,1)
       if "kmc"     in dargs["help"]: print_string(HELP_kmc    ,1)
       if "plot"    in dargs["help"]: print_string(HELP_plot   ,1)
       if "kies"    in dargs["help"]: print_string(HELP_kies   ,1)
       if "summary" in dargs["help"]: print_string(HELP_summary,1)
       return

    # Print logo and current date
    string_head  = PROGNAME+"\n"+PROGHEAD+"\n"+AUTHORINFO+"\n"+"\n"
    string_head += " -----------------------------------------------------------\n"
    string_head += exe_info()
    string_head += " -----------------------------------------------------------\n\n"
    print(string_head)

    # check some arguments
    dargs    = check_ics(dargs)
    software = check_sft(dargs)
    dlevel   = check_dlevel(dargs)
    boolms   = check_boolms(dargs)

    # --software used properly
    if software is None:
       print("  Software option has to be followed by an argument!")
       print("")
       exit()

    # Act according user argument
    IN_OPTS = False
    for option in OPTIONS.split(","):
        if option not in dargs.keys(): continue
        IN_OPTS = True
        # read input files and print table
        idata, status, string = get_input_data()
        print_string(string,nbs=3)
        # data files according to case
        datafiles,string = dlevel_to_files(dlevel)
        if option in OPTIONS1.split(","): print_string(string,nbs=3)
        case = (datafiles,dlevel,software)
        # execute pilgrim with option
        print(" ===========================================================")
        print(" ||  EXECUTING PILGRIM WITH --%-6s                      ||"%option)
        print(" ===========================================================")
        print("")
        if   option == "ls"     :  gather.ls_struc(idata[0][0])
        elif option == "gather" :  gather.main(idata,status                      )
        elif option == "input"  : inpmenu.main(idata,status                      )
        elif option == "ics"    :     ics.main(idata,status,*dargs["ics"   ]     )
        elif option == "pfn"    :     pfn.main(idata,status,case,dargs["pfn"   ])
        elif option == "path"   :    path.main(idata,status,case,dargs["path"  ],boolms)
        elif option == "hlcalc" :  hlcalc.main(idata,status,case,dargs["hlcalc"])
        elif option == "rcons"  :   rcons.main(idata,status,case,dargs["rcons" ])
        elif option == "kmc"    :     kmc.main(idata,status,case,dargs["kmc"   ])
        elif option == "kies"   :    kies.main(idata,status,case                )
        elif option == "fit"    :     fit.main(idata,status,case,dargs["fit"   ])
        elif option == "plot"   :    plot.main(             case,dargs["plot"  ])
        elif option == "summary": summary.main(idata,status,case,dargs["summary"])
        print("")
        print(" ===========================================================")
        break

    # User asked for nothing. Print help!
    if not IN_OPTS: print_string(HELP_main,2); return


    # Print elapsed time
    t2 = time.time()
    timeline = "| Total Elapsed Time: %5.1f %5s |"%time2human(t2-t1,"secs")
    print(" "*25+"-"*len(timeline))
    print(" "*25+        timeline)
    print(" "*25+"-"*len(timeline))
    print("")