示例#1
0
def MakeGif(filename, chemical, skipFig):
    inD = ReadParaFromFile(filename)    # init
    droute = inD['droute']
    prefix = inD['prefix']
    citcomsFile = inD['citcomsFile']
    pp_file = os.path.join(droute, "post_process")
    p_dict = read_input(pp_file)
    e_steps = get_variable(p_dict, 'episode_steps', 'int_list')
    stepTuple = get_steps(droute, prefix, 100000)
    stepTuple = [step for step in stepTuple if step <= e_steps[-1] and step > 0]
    PlotSurf0 = PlotSurf(inD, 'MF0', stepTuple)
    # plot figures
    if skipFig == 0:
        # maxV = PlotSurf0.GetUnvMax()     # get max value
        maxV = PlotSurf0.GetUnvMax1(1, header=1)     # get max value
        num_cores = multiprocessing.cpu_count()
        print("start parallel: cores %d" % num_cores)
        Parallel(n_jobs=num_cores)(delayed(PlotSurf0)(step, chemical=chemical, maxV=maxV, otype='jpg')
                                   for step in stepTuple)
    # make gif
    timeTuple = read_time(droute, prefix)
    citcomsD = read_input(citcomsFile)
    Ro = get_variable(citcomsD, 'radius', 'float')
    Kappa = get_variable(citcomsD, 'thermdiff', 'float')
    timeScale = pow(Ro, 2.0) / Kappa
    MakeAni0 = MakeAni(inD, timeScale, stepTuple, timeTuple)
    MakeAni0('MF_hammer', chemical=chemical, removeJpg=True)
示例#2
0
def main():
    inD = ReadParaFromFile()
    route = inD['route']
    oroute = inD['oroute']
    prefix = inD['prefix']
    routeA = inD['routeA']
    prefixA = inD['prefixA']
    if os.path.isdir(oroute) is False:
        os.mkdir(oroute)
    nprocz = inD['nprocz']
    #   Case steps
    pp_file = os.path.join(route, "post_process")
    p_dict = read_input(pp_file)
    e_steps = get_variable(p_dict, 'episode_steps', 'int_list')
    step_tuple = get_steps(route, prefix, 100000)
    stepInEpisode = [step for step in step_tuple if step <= e_steps[-1] and step > 0]
    #   Combine MF files
    SArea = SurfArea(inD)
    sA = SArea(routeA, prefixA, col=1)     # read surf_area file
    sA *= S
    combineS = CombineSurfFile('MF', inD, surfArea=sA)
    # combineS(route, prefix, 1000, nprocz, "surf",   # test a single step
    #         obl=False, expandLon=True, oroute=oroute, area=1.0,
    #         eaMesh=True)
    num_cores = multiprocessing.cpu_count()
    print("start parallel: cores %d" % num_cores)
    Parallel(n_jobs=num_cores)(delayed(combineS)(route, prefix, step, nprocz, "surf",
                                                 obl=True, expandLon=True, oroute=oroute,
                                                 area=1.0, eaMesh=False)
                               for step in stepInEpisode)
    #   Total amount of melt
    pFile = os.path.join(route, "input_solidus_i", "in_65moon")
    pDict = read_input(pFile)
    Ro = get_variable(pDict, 'radius', 'float')
    Kappa = get_variable(pDict, 'thermdiff', 'float')
    timeScale = pow(Ro, 2.0) / Kappa
    _cls = Cls(oroute, prefix, timeScale)    # input class
    timeArray = read_time(route, prefix)    # time
    combineS.TotalAmount(_cls, stepInEpisode, timeArray, obl=True, area=1.0)
        # im = m.imshow(s, cmap=cm, vmin=0.0, vmax=mm[1])
    # combineS.EaGrid(oroute, prefix, nprocz, total=True)
    #   Time of Steps
    StepTime(oroute, prefix, step_tuple, timeArray, timeScale/Ma)
示例#3
0
def ReadParaFromFile():
    if os.path.isfile('inputFileSurf') is False:
        raise NoFileError('inputFile')
    _inD = read_input('inputFileSurf')
    return _inD
示例#4
0
def ReadParaFromFile(inputFile):
    if os.path.isfile(inputFile) is False:
        raise NoFileError(inputFile)
    _inD = read_input(inputFile)
    return _inD