def TKEdiss_rxx0(DI,instructions,dist):

    matplotlib.rcParams.update({'font.size':20, 'figure.autolayout': True}) #, 'font.weight':'bold'})
    fig, axL = plt.subplots()

    mfile = DI['pdir']+"means_TKEdiss.dat"
    data = np.loadtxt(mfile, comments=commentHdr)
    times = get_inputFileParameter(DI, ("dumpTimes",))
    D = get_inputFileParameter(DI, ("initParams","djeti"))
    ufile = DI['pdir']+"uvel_cl.dat"
    ucl = np.loadtxt(ufile, comments=commentHdr)
    u = ucl[:,1]

    npts = len(data[:,0])
    ntimes = len(times)
    rnorm = np.empty((npts,ntimes))
    TKE = data[:,1:]
    
    rnorm[:,dist] = data[:,0]/(times[dist] - 4.0*D)

    axL.plot(rnorm[:,dist],TKE[:,dist]/((u[dist]**3)/times[dist]))
    axL.set_ylabel(r"$TKEdiss \bullet \frac{ x}{(u_{cL})^3}$", fontsize=22)
    axL.set_xlabel(r"$r/(x-x_0)$", fontsize=22)
    axL.set_xlim([-0.5,0.5])
    axL.set_title(instructions)

    data = np.vstack([rnorm[:,dist],(sig_uvel[:,dist]/Ucl[dist])]).T
    head = "  rnorm                TKEdiss x/ucL3"
    np.savetxt(DI['pdir']+"TKE_rxx0.dat", data, header=head, comments=commentHdr)

    cid = fig.canvas.mpl_connect('button_press_event', onclick)
    plt.show()
    return pt
Esempio n. 2
0
def uvel(DI, profName="uvel"):

    mfile = DI['pdir'] + "means_" + profName + ".dat"
    sfile = DI['pdir'] + "sig_" + profName + ".dat"

    data = np.loadtxt(mfile, comments=commentHdr)
    y = data[:, 1:]
    data = np.loadtxt(sfile, comments=commentHdr)
    ys = data[:, 1:]

    npts, ntimes = np.shape(data)
    ntimes = ntimes - 1

    cLine = np.zeros(ntimes)
    scLine = np.zeros(ntimes)
    imid = int(npts / 2) + 1

    for it in range(ntimes):
        print("uvel: time %i of %i" % (it + 1, ntimes))
        cLine[it] = y[imid, it]
        scLine[it] = ys[imid, it]

    times = get_inputFileParameter(DI, ("dumpTimes", ))
    D = get_inputFileParameter(DI, ("initParams", "djeti"))
    times = np.array(times)

    if len(times) != ntimes:
        raise ValueError(
            "uvel.py: wrong number of times in data file and in input file.")

    data = np.vstack([times / D, cLine, scLine]).T

    head = "  x/D,               centerline,       rms_cL"
    fname = DI['pdir'] + profName + "_cl.dat"
    np.savetxt(fname, data, header=head, fmt="%15.8e ", comments=commentHdr)
def ZLES_decay(DI): #uses list of cases

    cases=[]
    plotname="ZLES_decay"
    
    matplotlib.rcParams.update({'font.size':20, 'figure.autolayout': True}) #, 'font.weight':'bold'})

    fig, axL = plt.subplots()

    decay = np.zeros((len(DI), 1))
    ZLES_params = np.zeros((len(DI),1))

    for i in range(0, len(DI)):
        
        cases.append(DI[i]['cn'][8:])
        plotname+='__'+DI[i]['cn'][8:]
        fname = DI[i]['pdir']+"uvel_cl.dat"
        odt = np.loadtxt(fname, comments=commentHdr)
        U0 = get_inputFileParameter(DI[i], ("initParams", "vel_max"))
        ua = get_inputFileParameter(DI[i], ("initParams", "vel_min"))
        m,b = np.polyfit(odt[4:,0],(U0-ua)/(odt[4:,1]-ua),1) #line of fit starting at x/d=20
        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        x0 = (-b/m)*D
        Z_LES = get_inputFileParameter(DI[i], ("params","Z_LES"))
        
        decay[i,0] = m
        ZLES_params[i,0] = Z_LES

    plt.scatter(ZLES_params[:,0], decay[:,0])
    plt.ylabel("velocity decay")
    plt.xlabel("$Z_{LES}$")
    plt.title("coldJet")
    
    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/'+'ZLES_decay__ALL'.replace(".","o"))
def TKEdiss_rxx0_half(DI, profName="TKEdiss"): #uses list of cases
    
    cases=[]
    plotname="TKEdiss_rxx0_half"
    #plotname="TKEdiss_rxx0_half_xD"

    matplotlib.rcParams.update({'font.size':20, 'figure.autolayout': True}) #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {'coldJet_base':'k','coldJet_base_gDens60':'m', 'coldJet_base_gDens120':'b', 'coldJet_C_10_gDens120':'g', 'coldJet_C_10_ZLES_7_gDens120':'r', 'coldJet_LplanarTau_gDens60':'b--', 'coldJet_ZLES_7_gDens120':'c', 'coldJet__LPlanarTau_C_10_ZLES_7_gDens60':'r--'}
    #color['coldJet_LplanarTau_gDens60']='k' #use if plotting LPlanarTau cases at multiple distances
    #color['coldJet__LPlanarTau_C_10_ZLES_7_gDens60']='k' #use if plotting LPlanarTau cases at multiple distances

    for i in range(0,len(DI)):

        D = get_inputFileParameter(DI[i],("initParams","djeti"))
        mfile = DI[i]['pdir']+"/means_"+profName+".dat"
        data = np.loadtxt(mfile, comments=commentHdr)
        times = get_inputFileParameter(DI[i],("dumpTimes",))
        ucl = DI[i]['pdir']+"/uvel_cl.dat"
        ucl = np.loadtxt(ucl, comments=commentHdr)
        u = ucl[:,1]
        
        npts = len(data[:,0])
        ntimes = len(times)
        rnorm = np.empty((npts,ntimes))
        TKE = data[:,1:]
        for j in range(ntimes):
            rnorm[:,j] = data[:,0]/(times[j]-4.0*D)

        #if plotting several cases at once, best not to plot multiple downstream distances
        #j = 2; axL.plot(rnorm[:,j], TKE[:,j]/((u[j]**3)/times[j]), color[DI[i]['cn']]+':') #x/D=10
        #j = 4; axL.plot(rnorm[:,j], TKE[:,j]/((u[j]**3)/times[j]), color[DI[i]['cn']]+'--') #x/D=20
        j = 10; axL.plot(rnorm[:,j], TKE[:,j]/((u[j]**3)/times[j]), color[DI[i]['cn']]) #x/D=50
        
        #cases.append(DI[i]['cn'][8:]+', x=10D')
        #cases.append(DI[i]['cn'][8:]+', x=20D')
        cases.append(DI[i]['cn'][8:]+', x=50D')
        plotname+="__"+DI[i]['cn'][8:]

    axL.set_ylim([0,0.18])
    axL.set_xlim([-0.3,0.3])
    axL.set_xlabel(r"$r/(x-x_0)$", fontsize=22)
    axL.set_ylabel(r"$TKEdiss \bullet \frac{ x}{(u_{cL})^3}$", fontsize=22)
    axL.set_title("coldJet",fontsize=22)
    axL.legend(cases,loc="best", frameon=False, fontsize=8)

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/'+'TKEdiss_rxx0_half__ALL'.replace(".","o"))
Esempio n. 5
0
def u0ucl_xD(DI):  #use list of cases

    cases = []
    plotname = "u0ucl_xD"
    x0values = []

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }

    for i in range(0, len(DI)):

        cases.append(DI[i]['cn'][8:])
        plotname += "__" + DI[i]['cn'][8:]
        fname = DI[i]['pdir'] + "uvel_cl.dat"
        odt = np.loadtxt(fname, comments=commentHdr)
        U0 = get_inputFileParameter(DI[i], ("initParams", "vel_max"))
        ua = get_inputFileParameter(DI[i], ("initParams", "vel_min"))
        axL.plot(odt[:, 0], (U0 - ua) / (odt[:, 1] - ua), color[DI[i]['cn']])
        m, b = np.polyfit(odt[4:, 0], (U0 - ua) / (odt[4:, 1] - ua),
                          1)  #fit line starts at x/d=20
        fit = m * odt[:, 0] + b
        axL.plot(odt[:, 0], fit, color[DI[i]['cn']][0] + ':')
        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        x0 = (-b / m) * D
        cases.append('fit, $x_0$ = ' + str(x0)[:7] + ' m')

    axL.set_ylabel(r"$v_0/v_{cL}$", fontsize=22)
    axL.set_xlabel("$x/D$", fontsize=22)
    axL.legend(cases, loc='best', frameon=False, fontsize=8)
    axL.set_title("coldJet", fontsize=22)
    axL.set_ylim([0, 25])

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'u0ucl_xD__ALL'.replace(".", "o"))
Esempio n. 6
0
def fwhm(DI, profName="mixf"):

    mfile = DI['pdir'] + "means_" + profName + ".dat"
    sfile = DI['pdir'] + "sig_" + profName + ".dat"

    data = np.loadtxt(mfile)
    x = data[:, 0]
    y = data[:, 1:]
    data = np.loadtxt(sfile)

    npts, ntimes = np.shape(data)
    ntimes = ntimes - 1

    width = np.zeros(ntimes)

    for it in range(ntimes):
        print("fwhm: time %i of %i" % (it, ntimes))
        width[it] = local_fwhm(x, y[:, it])

    times = get_axialLocations(DI, forceGetDumpTimes=False)
    D = get_inputFileParameter(DI, ("initParams", "d_f"))

    if len(times) != ntimes:
        raise ValueError(
            "fwhm.py: wrong number of times in data file and in input file.")

    data = np.vstack([times / D, width / D]).T

    head = "  y/D,               fwhm/D"
    fname = DI['pdir'] + "fwhm_" + profName + ".dat"
    np.savetxt(fname, data, header=head, fmt="%15.8e ")
Esempio n. 7
0
def cl(DI, profName="mixf"):

    mfile = DI['pdir'] + "means_" + profName + ".dat"
    sfile = DI['pdir'] + "sig_" + profName + ".dat"

    data = np.loadtxt(mfile)
    y = data[:, 1:]
    data = np.loadtxt(sfile)
    ys = data[:, 1:]

    npts, ntimes = np.shape(data)
    ntimes = ntimes - 1

    cLine = np.zeros(ntimes)
    scLine = np.zeros(ntimes)
    imid = int(npts / 2) + 1

    for it in range(ntimes):
        print("cl: time %i of %i" % (it, ntimes))
        cLine[it] = y[imid, it]
        scLine[it] = ys[imid, it]

    times = get_axialLocations(DI, forceGetDumpTimes=False)
    D = get_inputFileParameter(DI, ("initParams", "d_f"))

    if len(times) != ntimes:
        raise ValueError(
            "cl.py: wrong number of times in data file and in input file.")

    data = np.vstack([times / D, cLine, scLine]).T

    head = "  y/D,               cl,       rms_cL"
    fname = DI['pdir'] + "cl_" + profName + ".dat"
    np.savetxt(fname, data, header=head, fmt="%15.8e ")
Esempio n. 8
0
def uclu0_xD(DI):  #use list of cases

    cases = []
    plotname = "uclu0_xD"
    for case in DI:
        cases.append(case['cn'][8:])
        plotname += "__" + case['cn'][8:]

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }

    for i in range(0, len(DI)):

        fname = DI[i]['pdir'] + "uvel_cl.dat"
        odt = np.loadtxt(fname, comments=commentHdr)
        U0 = get_inputFileParameter(DI[i], ("initParams", "vel_max"))
        ua = get_inputFileParameter(DI[i], ("initParams", "vel_min"))
        axL.plot(odt[:, 0], (odt[:, 1] - ua) / (U0 - ua), color[DI[i]['cn']])

    axL.set_ylabel(r"$v_{cL}/v_0$", fontsize=22)
    axL.set_xlabel("$x/D$", fontsize=22)
    axL.legend(cases, loc='best', frameon=False, fontsize=8)
    axL.set_title("coldJet", fontsize=22)
    axL.set_ylim([0, 1.5])

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'uclu0_xD__ALL'.replace(".", "o"))
def urmsucl_rxx0(DI, instructions, dist):

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})
    fig, axL = plt.subplots()

    mfile = DI['pdir'] + "means_uvel.dat"
    data = np.loadtxt(mfile, comments=commentHdr)
    times = get_inputFileParameter(DI, ("dumpTimes", ))
    ua = get_inputFileParameter(DI, ("initParams", "vel_min"))
    D = get_inputFileParameter(DI, ("initParams", "djeti"))
    sfile = DI['pdir'] + "sig_uvel.dat"
    sig_uvel = np.loadtxt(sfile, comments=commentHdr)

    npts = len(data[:, 0])
    ntimes = len(times)
    rnorm = np.empty((npts, ntimes))
    U = data[:, 1:]
    icl = int(npts / 2) + 1
    Ucl = U[icl, :]
    rnorm[:, dist] = data[:, 0] / (times[dist] - 4.0 * D)

    axL.plot(rnorm[:, dist], (sig_uvel[:, dist] / Ucl[dist]))
    axL.set_ylabel(r"$v_{rms}/v_{cL}$", fontsize=22)
    axL.set_xlabel(r"$r/(x-x_0)$", fontsize=22)
    axL.set_xlim([-0.5, 0.5])
    axL.set_title(instructions)

    data = np.vstack([rnorm[:, dist], (sig_uvel[:, dist] / Ucl[dist])]).T
    head = "  rnorm                urms/ucL"
    np.savetxt(DI['pdir'] + "urmsucl_rxx0.dat",
               data,
               header=head,
               comments=commentHdr)

    cid = fig.canvas.mpl_connect('button_press_event', onclick)
    plt.show()
    return pt
def C_growth_x0(DI):  #uses list of cases

    cases = []
    plotname = "C_growth_x0"

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()

    growth_x0 = np.zeros((len(DI), 1))
    C_params = np.zeros((len(DI), 1))

    for i in range(0, len(DI)):

        cases.append(DI[i]['cn'][8:])
        plotname += '__' + DI[i]['cn'][8:]
        fname = DI[i]['pdir'] + "fwhm_cl_uvel.dat"
        odt = np.loadtxt(fname, comments=commentHdr)
        m, b = np.polyfit(odt[4:, 0], odt[4:, 1],
                          1)  #line of fit starting at x/d=20
        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        x0 = (-b / m) * D
        C = get_inputFileParameter(DI[i], ("params", "C_param"))
        #Z_LES = get_inputFileParameter(DI[i], ("params","Z_LES"))

        growth_x0[i, 0] = m
        C_params[i, 0] = C

    plt.scatter(C_params[:, 0], growth_x0[:, 0])
    plt.ylabel("$x_{0,growth}$")
    plt.xlabel("$C$")
    plt.title("coldJet")

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'C_growth_x0__ALL'.replace(".", "o"))
Esempio n. 11
0
def fwhm(DI, profName="mixf"):

    mfile = DI['pdir'] + "means_" + profName + ".dat"
    sfile = DI['pdir'] + "sig_" + profName + ".dat"

    data = np.loadtxt(mfile, comments=commentHdr)
    x = data[:, 0]
    y = data[:, 1:]
    data = np.loadtxt(sfile, comments=commentHdr)
    ys = data[:, 1:]

    npts, ntimes = np.shape(data)
    ntimes = ntimes - 1

    width = np.zeros(ntimes)
    cLine = np.zeros(ntimes)
    scLine = np.zeros(ntimes)
    imid = int(npts / 2) + 1

    for it in range(ntimes):
        print("fwhm: time %i of %i" % (it, ntimes))
        width[it] = local_fwhm(x, y[:, it])
        cLine[it] = y[imid, it]
        scLine[it] = ys[imid, it]

    times = get_inputFileParameter(DI, ("dumpTimes", ))
    #D     = get_inputFileParameter(DI, ("initParams","d_f"))
    D = get_inputFileParameter(DI, ("initParams", "djeti"))
    times = np.array(times)[0:ntimes]

    if len(times) != ntimes:
        raise ValueError(
            "fwhm.py: wrong number of times in data file and in input file.")

    data = np.vstack([times / D, width / D, cLine, scLine]).T

    head = "  x/D,               fwhm/D,         centerline,       rms_cL"
    fname = DI['pdir'] + "fwhm_cl_" + profName + ".dat"
    np.savetxt(fname, data, header=head, fmt="%15.8e ", comments=commentHdr)
def peaks(DI,pts,dist):
    
    file = DI['pdir']+"TKE_rxx0.dat"
    data = np.loadtxt(file)
    times = get_inputFileParameter(DI, ("dumpTimes",))
    rnorm = data[:,0]
    TKEdiss = data[:,1]
    idx1 = (np.abs(rnorm-pts[0]).argmin())
    idx2 = (np.abs(rnorm-pts[1]).argmin())
    print idx1,idx2
    leftPeak = max(TKEdiss[:idx1])
    rightPeak = max(TKEdiss[idx2:])
    print times[dist], leftPeak, rightPeak
    return ([times[dist], leftPeak, rightPeak])
Esempio n. 13
0
def checkForIncompleteRlzs(DI, caseN):

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

    nrlz = len(glob.glob(DI['ddir'] + "data_*"))
    times = get_inputFileParameter(
        DI, ("dumpTimes", ))  # times or ypositions if spatial

    # Incomplete runs ---------------------------------------------------------------------------

    print("Checking for incomplete realizations.")

    incompleteRlzs = []

    for irlz in range(nrlz):

        irlz_str = format(irlz, '05')

        files = glob.glob(DI['ddir'] + "data_" + irlz_str + "/dmp_*.dat")
        if (len(files) < len(times)):
            print("INCOMPLETE: rlz " + str(irlz))
            incompleteRlzs += [irlz]

    if len(incompleteRlzs) != 0:

        copyOverOldFlag = input(
            str(len(incompleteRlzs)) +
            " realization(s) have incomplete data. Copy over them from adjacent realizations? (y/n) "
        )

        if copyOverOldFlag == "y":

            copying_args = [''] * 3
            copying_args[0] = "./copyOverIncompleteRlz.sh"
            copying_args[1] = caseN

            for i in incompleteRlzs:
                copying_args[2] = str(i)
                subprocess.call(copying_args)

    else:

        print("No incomplete realizations.")
Esempio n. 14
0
def checkForBlowout(DI):

    dataFiles = glob.glob(DI['cdir'] + "data_py/data_*.npy")
    ntimes = len(dataFiles)
    nrlz = get_nRlz(DI)
    varNames = get_dataHeaderVars(DI)
    times = get_inputFileParameter(
        DI, ("dumpTimes", ))  # times or ypositions if spatial

    # Blowout -----------------------------------------------------------------------------------

    extinction_temp = 1800.0

    itemp = varNames.index("temp")
    blowout_num = 0

    print("Checking for extinguished/blowout cases.")

    for irlz in range(nrlz):
        data = get_data_realization(DI, ntimes - 1, irlz)
        T = data[:, itemp]

        Tmax = np.amax(T)
        if Tmax < extinction_temp:
            print("BLOWOUT: rlz " + str(irlz))
            blowout_num += 1

    if blowout_num >= 1:
        warning_flag = input(
            "WARNING: Blowout in %i realizations. Process at your own risk. Quit? (y/n) "
            % (blowout_num))

        if warning_flag == "y":
            sys.exit()

    else:
        print("No blowout cases.")
def intTKEdiss_xD(DI, profName="TKEdiss"):  #uses list of cases

    cases = []
    plotname = "intTKEdiss_xD"

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }

    for i in range(0, len(DI)):

        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        L = get_inputFileParameter(DI[i], ("params", "domainLength"))
        mfile = DI[i]['pdir'] + "/means_" + profName + ".dat"
        data = np.loadtxt(mfile, comments=commentHdr)
        times = get_inputFileParameter(DI[i], ("dumpTimes", ))

        npts = len(data[:, 0])
        ntimes = len(times)
        icl = int(npts / 2) + 1
        r = data[:, 0]
        times = np.array(times)
        xD = times / D

        TKErdr = np.empty((npts - 1, ntimes))

        TKEr = np.empty((npts, ntimes))
        TKE = data[:, 1:]

        for ipt in range(npts):
            for itime in range(ntimes):
                TKEr[ipt, itime] = TKE[ipt, itime] * r[ipt]

        #integrated from centerline out to maximum positive radial distance
        for itime in range(ntimes):
            TKErdr[icl:, itime] = integrate.cumtrapz(TKEr[icl:, itime],
                                                     r[icl:])

        axL.plot(xD, TKErdr[-1, :], color[DI[i]['cn']])

        cases.append(DI[i]['cn'][8:])
        plotname += "__" + DI[i]['cn'][8:]

    axL.set_xlabel(r"$x/D$", fontsize=22)
    axL.set_ylabel(r"$\int \epsilon rdr$", fontsize=22)
    axL.set_title("coldJet", fontsize=22)
    axL.legend(cases, loc='best', frameon=False, fontsize=8)
    #axL.set_xlim([-.3,.3])
    #axL.set_ylim([-0.05,0.4])

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'intTKEdiss_xD__ALL'.replace(".", "o"))
Esempio n. 16
0
def plot_RorZprof(DI, RorZ, fileType, varName, yD, expFlist, expCol, xlim,
                  ylim, xtics, ytics, xlabel, ylabel):

    D = get_inputFileParameter(DI, ("initParams", "d_f"))
    y = yD * D

    if RorZ == 'R':
        odt = np.loadtxt(DI['pdir'] + fileType + "_" + varName + ".dat")
        scaleX = D
        figName = DI['pdir'] + "radial_" + varName + "_" + fileType + "_" + DI[
            'cn'].replace(".", "o")
    else:
        odt = np.loadtxt(DI['pdir'] + fileType + "_" + varName + ".dat")
        scaleX = 1
        figName = DI[
            'pdir'] + "conditional_" + varName + "_" + fileType + "_" + DI[
                'cn'].replace(".", "o")
    yodt = get_axialLocations(DI, forceGetDumpTimes=False)
    npts = len(odt[:, 0])
    var = np.zeros((npts, len(yD)))

    for i in range(len(yD)):
        for k in range(npts):
            fextrap = extrap1d(yodt, odt[k, 1:])
            var[k, i] = fextrap(y[i])

    plt.figure()
    plt.rc("font", size=14)

    #for i,ifile in enumerate(expFlist):
    for i in range(len(yD)):
        plt.subplot(3, 2, i + 1)
        plt.plot(odt[:, 0] / scaleX, var[:, i], 'k-')
        if expFlist != []:
            exp = np.loadtxt(expFlist[i])
            plt.plot(exp[:, 0], exp[:, expCol], 'r-')
        plt.xlim(xlim)
        plt.ylim(ylim)
        plt.xticks([])
        plt.yticks([])
        plt.title("y/D = %i" % yD[i])

    plt.subplot(3, 2, 1)
    if expFlist == []:
        plt.legend(("ODT"), frameon=False)
    else:
        plt.legend(("ODT", "EXP"), frameon=False)
    plt.yticks(ytics)
    plt.ylabel(ylabel)

    plt.subplot(3, 2, 3)
    plt.yticks(ytics)
    plt.ylabel(ylabel)

    plt.subplot(3, 2, 5)
    plt.yticks(ytics)
    plt.ylabel(ylabel)
    plt.xticks(xtics)
    plt.xlabel(xlabel)

    plt.subplot(3, 2, 6)
    plt.xticks(xtics)
    plt.xlabel(xlabel)

    #plt.show()

    plt.savefig(figName)
Esempio n. 17
0
def plot_uvel(DI, profName='uvel'):

    fname = DI['pdir'] + "uvel_cl.dat"
    odt = np.loadtxt(fname, comments=commentHdr)
    U0 = get_inputFileParameter(DI, ("initParams", "vel_max"))
    fit = 1.0 / 5.8 * (odt[:, 0] - 4.0)
    Exp = np.loadtxt("exp_u_cl.dat")
    ua = get_inputFileParameter(DI, ("initParams", "vel_min"))

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()

    #axL.plot(odt[:,0],(U0-ua)/(odt[:,1]-ua),'ko-')
    axL.plot(odt[:, 0], (U0 - ua) / (odt[:, 1] - ua), 'k-')
    axL.plot(Exp[:, 0], Exp[:, 1], '^')
    axL.plot(odt[:, 0], fit, 'k--')
    axL.set_ylabel(r'$v_0/v_{cL}$', fontsize=22)
    axL.set_xlabel("y/D", fontsize=22)
    axL.legend(("ODT", "EXP", "Fit"),
               loc='upper right',
               frameon=False,
               fontsize=16)
    axL.set_ylim([0, 25])

    plt.savefig(DI['pdir'] + "uvel_cl_" + DI['cn'].replace(".", "o"))

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

    D = get_inputFileParameter(DI, ("initParams", "djeti"))
    Exp = np.loadtxt("exp_u_rad.dat")
    mfile = DI['pdir'] + "/means_" + profName + ".dat"
    data = np.loadtxt(mfile, comments=commentHdr)
    times = get_inputFileParameter(DI, ("dumpTimes", ))
    ua = 0.0
    #ua = get_inputFileParameter(DI, ("initParams","vel_min"))

    npts = len(data[:, 0])
    ntimes = len(times)
    rnorm = np.empty((npts, ntimes))
    U = data[:, 1:]
    icl = int(npts / 2) + 1
    Ucl = U[icl, :]
    for i in range(ntimes):
        rnorm[:, i] = data[:, 0] / (times[i] - 4.0 * D)

    plt.cla()
    #i = 8;  axL.plot(rnorm[:,i], (U[:,i]-ua)/(Ucl[i]-ua), 'k:')
    #i = 12; axL.plot(rnorm[:,i], (U[:,i]-ua)/(Ucl[i]-ua), 'b-.')
    #i = 16; axL.plot(rnorm[:,i], (U[:,i]-ua)/(Ucl[i]-ua), 'g--')
    #i = 20; axL.plot(rnorm[:,i], (U[:,i]-ua)/(Ucl[i]-ua), 'r-')
    i = 12
    axL.plot(rnorm[:, i], (U[:, i] - ua) / (Ucl[i] - ua), 'k:')
    i = 16
    axL.plot(rnorm[:, i], (U[:, i] - ua) / (Ucl[i] - ua), 'b--')
    i = 20
    axL.plot(rnorm[:, i], (U[:, i] - ua) / (Ucl[i] - ua), 'r-')
    axL.plot(Exp[:, 0], Exp[:, 1], 'o')
    axL.set_ylim([0, 1.2])
    axL.set_xlim([0, 0.25])
    axL.set_xlabel(r"$r/(y-y_0)$", fontsize=22)
    axL.set_ylabel(r"$v/v_{cL}$", fontsize=22)
    #axL.legend(("y=30D", "y=50D", "y=70D", "y=90D", 'EXP'), frameon=False, fontsize=16)
    axL.legend(("y=50D", "y=70D", "y=90D", 'EXP'), frameon=False, fontsize=16)

    plt.savefig(DI['pdir'] + "uvel_r_" + DI['cn'].replace(".", "o"))

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

    mfile = DI['pdir'] + "sig_uvel.dat"
    sig_uvel = np.loadtxt(mfile, comments=commentHdr)
    Exp = np.loadtxt("exp_uu_rad.dat")

    plt.cla()
    #i = 8;  axL.plot(rnorm[:,i], sig_uvel[:,i]/Ucl[i], 'k:')
    #i = 12; axL.plot(rnorm[:,i], sig_uvel[:,i]/Ucl[i], 'b-.')
    #i = 16; axL.plot(rnorm[:,i], sig_uvel[:,i]/Ucl[i], 'g--')
    #i = 20; axL.plot(rnorm[:,i], sig_uvel[:,i]/Ucl[i], 'r-')
    i = 12
    axL.plot(rnorm[:, i], sig_uvel[:, i] / Ucl[i], 'k:')
    i = 16
    axL.plot(rnorm[:, i], sig_uvel[:, i] / Ucl[i], 'b--')
    i = 20
    axL.plot(rnorm[:, i], sig_uvel[:, i] / Ucl[i], 'r-')
    axL.plot(Exp[:, 0], Exp[:, 1]**0.5, 'o', ms=4)
    axL.set_ylim([0, 0.6])
    axL.set_xlim([0, 0.25])
    axL.set_xlabel(r"$r/(y-y_0)$", fontsize=22)
    axL.set_ylabel(r"$v_{rms}/v_{cL}$", fontsize=22)
    #axL.legend(("y=30D", "y=50D", "y=70D", "y=90D", 'EXP'), frameon=False, fontsize=16)
    axL.legend(("y=50D", "y=70D", "y=90D", 'EXP'), frameon=False, fontsize=16)

    plt.savefig(DI['pdir'] + "uu_r_" + DI['cn'].replace(".", "o"))
Esempio n. 18
0
def basic_stats(DI, nfbins=60, nx=-1, favre=False, do_yt=False, filter=True):

    favre = False
    #--------------------------------------------------------------------------------------------

    dataFiles = glob.glob(DI['cdir'] + "data_py/data_*.npy")
    ntimes = len(dataFiles)
    nrlz = get_nRlz(DI)
    varNames = get_dataHeaderVars(DI)
    times = get_inputFileParameter(
        DI, ("dumpTimes", ))  # times or ypositions if spatial
    times = times[
        0:
        ntimes]  # limit times to number of dataFiles, not all listed dumpTimes
    nvar = len(varNames)
    cCoord = get_inputFileParameter(DI, ("params", "cCoord"))
    df = 1.0 / nfbins
    dxmin = get_inputFileParameter(DI, ("params", "dxmin"))
    nx = int(1.0 / dxmin / 10) if nx < 0 else nx
    x0, xL = get_domainBounds(DI)
    L = get_inputFileParameter(DI, ("params", "domainLength"))
    Dx = L / nx
    coflow = get_inputFileParameter(DI, ("initParams", "vel_min"))

    if nx % 2 == 0:
        nx = nx + 1  # make it odd for centerline

    try:
        imixf = varNames.index("mixf")
    except:
        imixf = -1
    try:
        irho = varNames.index("rho")
    except:
        irho = -1
    try:
        idvisc = varNames.index("dvisc")
    except:
        idvisc = -1
    try:
        iposf = varNames.index("posf")
    except:
        raise ValueError("In basic_stats: no posf variable found")
    try:
        ipos = varNames.index("pos")
    except:
        raise ValueError("In basic_stats: no pos variable found")
    try:
        iuvel = varNames.index("uvel")
    except:
        iuvel = -1

    doConditional = True if imixf > -1 else False

    if irho == -1 and favre:
        raise ValueError(
            "In basic_stats: favre is true, but there is no rho in data file")

    if do_yt and (irho == -1 or iuvel == -1):
        raise ValueError(
            "In basic_stats: do_yt is true but missing rho or uvel in data file"
        )

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

    X = np.linspace(x0, xL, nx)
    fbins = np.linspace(df / 2.0, 1.0 - df / 2.0, nfbins)

    # Add the turbulence dissipation rate statistics and its logarithm, so we have nvar+2
    means = np.zeros((ntimes, nvar + 2, nx))
    mean2 = np.zeros((ntimes, nvar + 2, nx))
    rhoM = np.zeros((ntimes, nvar + 2, nx))  # needed for favre to normalize
    cmeans = np.zeros((ntimes, nvar, nfbins))
    cmean2 = np.zeros((ntimes, nvar, nfbins))
    binNrm = np.zeros((ntimes, nvar, nfbins))  # to normalize conditional means
    rhouu = np.zeros(ntimes)
    rhou = np.zeros(ntimes)

    for itime in range(ntimes):

        # instead of using the get_data_realization() which reads each data_py*.npy again for each realization,
        # we read and hold the data for the dump time.
        fname = DI['cdir'] + "data_py/data_py_" + "{0:0>5}".format(
            itime) + ".npy"
        data_all = np.load(fname)
        posf_all = data_all[:, 1]
        dx_all = posf_all[1:] - posf_all[0:-1]

        istarts = np.where(dx_all < 0.0)[0] + 1
        istarts = np.insert(istarts, 0, 0.0)

        iends = np.where(dx_all < 0.0)[0]
        iends = np.append(iends, len(posf_all) - 1)

        nrlz = len(
            istarts)  # some sims end early so compute nrlz for each time

        for irlz in range(nrlz):

            print(
                "basic_stats: Processing time # %i of %i; for realization %i of %i"
                % (itime + 1, ntimes, irlz + 1, nrlz))

            #data = get_data_realization(DI, itime, irlz)
            i_s = istarts[irlz]
            i_e = iends[irlz]

            data = data_all[i_s:i_e + 1, :]
            x = data[:, ipos]
            xf = data[:, iposf]
            xf = np.append(xf, x[-1] + (xf[-1] - x[-1]))

            if doConditional:
                dx = np.abs(np.abs(xf[1:])**cCoord - np.abs(xf[0:-1])**cCoord)
                i = np.where(xf[1:] * xf[0:-1] < 0)[0]
                dx[i] = np.abs(
                    np.abs(xf[i + 1])**cCoord + np.abs(xf[i])**cCoord)
                ibin = (data[:, imixf] / df).astype(int)
                ibin[np.where(ibin < 0)] = 0
                ibin[np.where(ibin > nfbins - 1)] = nfbins - 1
                wt = dx * data[:, irho] if favre else dx.copy()

            if favre:
                fextrap = extrap1d(x, data[:, irho])
                rho = fextrap(X)
                rhoM[itime, :, :] = rhoM[itime, :, :] + rho

            for ivar in range(nvar):

                y = data[:, ivar]
                fextrap = extrap1d(x, y)
                Y = fextrap(X)
                Y2 = Y**2

                means[itime,
                      ivar, :] = means[itime,
                                       ivar, :] + (Y * rho if favre else Y)
                mean2[itime,
                      ivar, :] = mean2[itime,
                                       ivar, :] + (Y2 * rho if favre else Y2)

                if doConditional:
                    cmeans[itime, ivar,
                           ibin] = cmeans[itime, ivar, ibin] + y * wt
                    cmean2[itime, ivar,
                           ibin] = cmean2[itime, ivar, ibin] + y * y * wt
                    binNrm[itime, ivar, ibin] = binNrm[itime, ivar, ibin] + wt

            # here compute the turbulent dissipation rate and other derived variables
            #  need to recompute dx using the cell centers and not area weighting
            dx = (x[1:] - x[0:-1])
            dU = (data[1:, iuvel] - data[0:-1, iuvel]
                  )  # ( Uvel[1:] - Uvel[0:-1] )
            dVisc = 0.5 * (data[1:, idvisc] + data[0:-1, idvisc])
            #i = np.where(( x[1:] * x[0:-1] < 0 ) and ( x[1:] > x[0:-1] ) )[0]   # center origin point
            i = np.where(dx < 0)[0]  #crossing realizations
            dx[i] = dx[i - 1]
            #dU = np.append(dU,0.0)  # append a null value for crossing to next rlzn
            #dVisc = np.append(dVisc,0.0)
            diss = dVisc * (
                dU / dx)**2.0  # uses dx from cell centers and averaged dvisc
            diss = np.append(diss, 0.0)
            fextrap = extrap1d(x, diss)
            yDiss = fextrap(X)
            yDiss2 = yDiss**2.0

            means[itime,
                  nvar, :] = means[itime,
                                   nvar, :] + (yDiss * rho if favre else yDiss)
            mean2[itime,
                  nvar, :] = mean2[itime, nvar, :] + (yDiss2 *
                                                      rho if favre else yDiss2)
            logDiss = np.log(np.maximum(yDiss, 1e-20))
            logDiss2 = logDiss**2.0
            means[itime, nvar +
                  1, :] = means[itime, nvar +
                                1, :] + (logDiss * rho if favre else logDiss)
            mean2[itime, nvar +
                  1, :] = mean2[itime, nvar +
                                1, :] + (logDiss2 * rho if favre else logDiss2)

            if do_yt:
                fextrap = extrap1d(x, data[:, irho])
                rho = fextrap(X)
                fextrap = extrap1d(x, data[:, iuvel])
                uvel = fextrap(X)
                rhouu[itime] += np.sum(rho * uvel * uvel)
                rhou[itime] += np.sum(rho * uvel)

        if favre:
            means[itime, :, :] /= rhoM
            mean2[itime, :, :] /= rhoM

        else:
            means[itime, :, :] /= nrlz
            mean2[itime, :, :] /= nrlz

    sig2 = mean2 - means * means
    sig = np.sqrt(np.abs(sig2))

    if doConditional:
        cmeans = cmeans / binNrm
        cmean2 = cmean2 / binNrm
        cmeans[np.where(binNrm == 0)] = 0

        csig2 = cmean2 - cmeans * cmeans
        csig = np.sqrt(np.abs(csig2))
        csig[np.where(binNrm == 0)] = 0

    if do_yt:
        uavg = rhouu / rhou
        uavg_mid = 0.5 * (uavg[1:] + uavg[0:-1])
        Lspatial = get_inputFileParameter(DI, ("params", "Lspatial"))
        if Lspatial:
            print("setting ytu.dat for spatial case")
            ypos = np.array(times[0:ntimes])
            dy = ypos[1:] - ypos[0:-1]
            tpos = np.cumsum(dy / uavg_mid)
            tpos = np.insert(tpos, 0, 0.0)
        else:  # temporal
            print("setting ytu.dat for temporal case")
            tpos = np.array(times[0:ntimes])
            dt = tpos[1:] - tpos[0:-1]
            ypos = np.cumsum(dt * uavg_mid)
            ypos = np.insert(ypos, 0, 0.0)
        ytu = np.vstack([ypos, tpos, uavg]).T
        np.savetxt(DI['pdir'] + 'ytu.dat',
                   ytu,
                   header=" y(m) t(s) u(m/s)",
                   fmt="%15.8e ",
                   comments=commentHdr)

    #--------------------------------------------------------------------------------------------
    #get jet width data to use for filter--this uses width from the fit line for the coldJet_base_gDens120 case, but could use a fit line from experimental data as long as the downstream distances match
    if filter:
        wfile = '/home/abaumga/odt2.0/post/coldJet/base_width.dat'
        #wfile = DI['pdir']+"fwhm_cl_uvel.dat"  #format same as fwhm_cl_uvel.dat
        jetWidth = np.loadtxt(wfile, comments=commentHdr)
        D = get_inputFileParameter(DI, ("initParams", "djeti"))
        width = np.zeros(ntimes)
        for itime in range(ntimes):
            width[itime] = (jetWidth[itime, 1]) * D

    #--------------------------------------------------------------------------------------------
    # write the mean and std data

    head = "x_(m)           "
    for i, time in enumerate(times):
        hi = "loc_" + str(i + 2) + "_" + str(time)
        hi = hi + (22 - len(hi)) * " "
        head = head + hi

    if filter:
        wndws = np.zeros(ntimes)
        for itime in range(ntimes):
            wndws[itime] = (
                0.1 * width[itime]
            ) / Dx  #window size is 10% of the unfiltered fwhm value at that dumptime

    mav_means = means
    mav_sig = sig
    if filter:
        for i in range(nvar + 2):  #nvar+2 so TKEdiss/logTKEdiss filtered
            for j in range(ntimes):
                wndw = int(wndws[j])
                for k in range(nx):
                    if k >= int(wndw / 2):
                        mav_means[j, i, k] = np.mean(
                            means[j, i, k - int(wndw / 2):k + int(wndw / 2)])
                        mav_sig[j, i, k] = np.mean(
                            sig[j, i, k - int(wndw / 2):k + int(wndw / 2)])

    for i in range(nvar):
        var = mav_means[:, i, :]
        var = np.reshape(var, (ntimes, nx))
        var = np.vstack([X, var]).T
        fname = DI['pdir'] + "means_" + varNames[i] + ".dat"
        np.savetxt(fname, var, header=head, fmt="%15.8e ", comments=commentHdr)

    for i in range(nvar):
        var = mav_sig[:, i, :]
        var = np.reshape(var, (ntimes, nx))
        var = np.vstack([X, var]).T
        fname = DI['pdir'] + "sig_" + varNames[i] + ".dat"
        np.savetxt(fname, var, header=head, comments=commentHdr)

    var = mav_means[:, nvar, :]
    var = np.reshape(var, (ntimes, nx))
    var = np.vstack([X, var]).T
    fname = DI['pdir'] + "means_TKEdiss.dat"
    np.savetxt(fname, var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = mav_means[:, nvar + 1, :]
    var = np.reshape(var, (ntimes, nx))
    var = np.vstack([X, var]).T
    fname = DI['pdir'] + "means_logTKEdiss.dat"
    np.savetxt(fname, var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = mav_sig[:, nvar, :]
    var = np.reshape(var, (ntimes, nx))
    var = np.vstack([X, var]).T
    fname = DI['pdir'] + "sig_TKEdiss.dat"
    np.savetxt(fname, var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = mav_sig[:, nvar + 1, :]
    var = np.reshape(var, (ntimes, nx))
    var = np.vstack([X, var]).T
    fname = DI['pdir'] + "sig_logTKEdiss.dat"
    np.savetxt(fname, var, header=head, fmt="%15.8e ", comments=commentHdr)

    #--------------------------------------------------------------------------------------------
    # write the conditional mean and std data

    if doConditional:

        head = "x_(m)           "
        for i, time in enumerate(times):
            hi = "loc_" + str(i + 2) + "_" + str(time)
            hi = hi + (22 - len(hi)) * " "
            head = head + hi

        for i in range(nvar):
            var = cmeans[:, i, :]
            var = np.reshape(var, (ntimes, nfbins))
            var = np.vstack([fbins, var]).T
            fname = DI['pdir'] + "cmeans_" + varNames[i] + ".dat"
            np.savetxt(fname,
                       var,
                       header=head,
                       fmt="%15.8e ",
                       comments=commentHdr)

        for i in range(nvar):
            var = csig[:, i, :]
            var = np.reshape(var, (ntimes, nfbins))
            var = np.vstack([fbins, var]).T
            fname = DI['pdir'] + "csig_" + varNames[i] + ".dat"
            np.savetxt(fname, var, header=head, comments=commentHdr)
def uucl_rxx0(DI, profName="uvel"):  #use list of cases

    cases = []
    #plotname="uucl_rxx0"
    plotname = "uucl_rxx0_xD"  #for plotting multiple distances

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }
    #color['coldJet_LplanarTau_gDens60']='k' #use if plotting LPlanarTau cases at multiple distances
    #color['coldJet__LPlanarTau_C_10_ZLES_7_gDens60']='k'     #use if plotting LPlanarTau cases at multiple distances

    for i in range(0, len(DI)):

        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        mfile = DI[i]['pdir'] + "/means_" + profName + ".dat"
        data = np.loadtxt(mfile, comments=commentHdr)
        times = get_inputFileParameter(DI[i], ("dumpTimes", ))
        ua = get_inputFileParameter(DI[i], ("initParams", "vel_min"))

        npts = len(data[:, 0])
        ntimes = len(times)
        rnorm = np.empty((npts, ntimes))
        U = data[:, 1:]
        icl = int(npts / 2) + 1
        Ucl = U[icl, :]

        for j in range(ntimes):
            rnorm[:, j] = data[:, 0] / (times[j] - 4.0 * D)

        #if plotting several cases together, best not to plot multiple downstream distances
        #j = 2; axL.plot(rnorm[:,j], (U[:,j]-ua)/(Ucl[j]-ua), color[DI[i]['cn']]+':') #x/D=10
        #j = 4; axL.plot(rnorm[:,j], (U[:,j]-ua)/(Ucl[j]-ua), color[DI[i]['cn']]+'--') #x/D=20
        j = 10
        axL.plot(rnorm[:, j], (U[:, j] - ua) / (Ucl[j] - ua),
                 color[DI[i]['cn']])  #x/D=50

        #cases.append(DI[i]['cn'][8:]+', x=10D')
        #cases.append(DI[i]['cn'][8:]+', x=20D')
        cases.append(DI[i]['cn'][8:] + ', x=50D')
        plotname += "__" + DI[i]['cn'][8:]

    axL.set_ylim([0, 1.2])
    axL.set_xlim([-0.25, 0.25])
    axL.set_xlabel(r"$r/(x-x_0)$", fontsize=22)
    axL.set_ylabel(r"$v/v_{cL}$", fontsize=22)
    axL.set_title("coldJet", fontsize=22)
    axL.legend(cases, loc="best", frameon=False, fontsize=8)

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'uucl_rxx0__ALL'.replace(".", "o"))
Esempio n. 20
0
def uvelScatter(DI):  #uses one case, NOT a list of cases

    dataFiles = glob.glob(DI['cdir'] + "data_py/data_*.npy")
    ntimes = len(dataFiles)
    nrlz = get_nRlz(DI)
    varNames = get_dataHeaderVars(DI)
    times = get_inputFileParameter(
        DI, ("dumpTimes", ))  # times or ypositions if spatial
    times = times[
        0:
        ntimes]  # limit times to number of dataFiles, not all listed dumpTimes
    nvar = len(varNames)

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    #comment or uncomment the following sections for either 4 plots or 1 plot (do not have both uncommented)

    ####FOR 4 SIDE-BY-SIDE PLOTS FOR 4 DUMPTIMES####

    #    fig,axL=plt.subplots(2,2)
    #    dmps=['00005','00010','00015','00020']
    #    for dmp in range(len(dmps)):

    #        fname = DI['cdir']+'data_py/data_py_'+dmps[dmp]+'.npy'
    #        data_all = np.load(fname)
    #        pos_all = data_all[:,0]
    #        uvel_all = data_all[:,4]
    #        iplt = np.random.choice(pos_all.shape[0],10000,replace=False)

    #        for i in iplt:
    #            if dmp==0:
    #                axL[0,0].scatter(pos_all[i],uvel_all[i],s=0.5,c='b')
    #                axL[0,0].set_title('00005')
    #            if dmp==1:
    #                axL[0,1].scatter(pos_all[i],uvel_all[i],s=0.5,c='b')
    #                axL[0,1].set_title('00010')
    #            if dmp==2:
    #                axL[1,0].scatter(pos_all[i],uvel_all[i],s=0.5,c='b')
    #                axL[1,0].set_title('00015')
    #            if dmp==3:
    #                axL[1,1].scatter(pos_all[i],uvel_all[i],s=0.5,c='b')
    #                axL[1,1].set_title('00020')
    #    for ax in axL.flat:
    #        ax.set(xlabel='pos', ylabel='uvel')
    #    for ax in axL.flat:
    #        ax.label_outer()
    #    plt.savefig(DI['pdir']+'uvelScatter'.replace(",","o"))

    ####FOR 1 PLOT FOR 1 DUPMTIME####

    fig, axL = plt.subplots()

    fname = DI['cdir'] + 'data_py/data_py_00010.npy'  #change dmp file name here
    data_all = np.load(fname)
    pos_all = data_all[:, 0]
    uvel_all = data_all[:, 4]
    iplt = np.random.choice(pos_all.shape[0], 10000, replace=False)

    for i in iplt:
        axL.scatter(pos_all[i], uvel_all[i], s=0.5, c='b')
    axL.set_ylabel('uvel')
    axL.set_xlabel('pos')
    axL.set_title(DI['cn'][8:])
    plt.savefig('../../data/plots_coldJet/uvelScatter_00010' +
                DI['cn'][8:].replace(",", "o"))  #change dmp file name here
def logTKEdiss_rxx0(DI, profName="logTKEdiss"):  #uses list of cases

    cases = []
    #plotname="logTKEdiss_rxx0"
    plotname = "logTKEdiss_rxx0_xD"

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }
    #color['coldJet_LplanarTau_gDens60']='k' #use if plotting LPlanarTau cases at multiple distances
    #color['coldJet__LPlanarTau_C_10_ZLES_7_gDens60']='k' #use if plotting LPlanarTau cases at multiple distances

    for i in range(0, len(DI)):

        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        L = get_inputFileParameter(DI[i], ("params", "domainLength"))
        mfile = DI[i]['pdir'] + "/means_" + profName + ".dat"
        data = np.loadtxt(mfile, comments=commentHdr)
        times = get_inputFileParameter(DI[i], ("dumpTimes", ))

        npts = len(data[:, 0])
        ntimes = len(times)
        rnorm = np.empty((npts, ntimes))
        logTKE = data[:, 1:]

        for j in range(ntimes):
            rnorm[:, j] = data[:, 0] / (times[j] - 4.0 * D)

        #when plotting several different cases together, best to plot only one downstream distance
        #j = 2; axL.plot(rnorm[:,j], logTKE[:,j], color[DI[i]['cn']]+':') #x/D=10
        #j = 4; axL.plot(rnorm[:,j], logTKE[:,j], color[DI[i]['cn']]+'--') #x/D=20
        j = 10
        axL.plot(rnorm[:, j], logTKE[:, j], color[DI[i]['cn']])  #x/D=50

        #cases.append(DI[i]['cn'][8:]+', x=10D')
        #cases.append(DI[i]['cn'][8:]+', x=20D')
        cases.append(DI[i]['cn'][8:] + ', x=50D')
        plotname += "__" + DI[i]['cn'][8:]

    axL.set_ylim([0, 2.5])
    axL.set_xlim([-0.2, 0.2])
    #axL.set_ylim([-2,8])
    axL.set_xlabel(r"$r/(x-x_0)$", fontsize=22)
    axL.set_ylabel(r"$logTKEdiss$", fontsize=22)
    axL.set_title("coldJet", fontsize=22)
    axL.legend(cases, loc="best", frameon=False, fontsize=8)

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'logTKEdiss_rxx0__ALL'.replace(".", "o"))
def contourPlot(DI,
                varName,
                levels,
                ticks,
                figName,
                ZvarName='mixf',
                addZstContour=False,
                means_rms='means'):

    print("\nMaking contour plot for figure: ", figName, "\n")

    fname = DI['pdir'] + means_rms + "_" + varName + ".dat"

    data = np.loadtxt(fname)
    x = data[:, 0]
    #x     = x-np.average(x)
    var = data[:, 1:]

    y = get_axialLocations(DI, forceGetDumpTimes=False)
    D = get_inputFileParameter(DI, ("initParams", "d_f"))
    x = x / D
    y = y / D

    X, Y = np.meshgrid(x, y)

    #------------------ plot

    aspectRatio = (np.max(y) - np.min(y)) / (np.max(x) - np.min(x))
    plt.figure(figsize=(4, 2.2 * aspectRatio))
    plt.rc("font", size=16)

    if levels != []:
        C = plt.contourf(X,
                         Y,
                         var.T,
                         levels=levels,
                         extend='max',
                         cmap=cm.viridis)
    else:
        C = plt.contourf(X, Y, var.T, 50, cmap=cm.viridis)

    #C.cmap.set_over('k')     # color for high out of range values
    #C.cmap.set_under('k')    # color for low out of range values
    ax = plt.gca()
    ax.axis((np.min(x), np.max(x), np.min(y), np.max(y)))
    ax.set_xbound(lower=np.min(x), upper=np.max(x))
    ax.set_ybound(lower=np.min(y), upper=np.max(y))
    ax.set_aspect('equal')
    plt.xlabel('position (m)', fontsize=16)
    plt.ylabel('axial position (m)', fontsize=16)
    plt.colorbar(ticks=ticks)
    #plt.xticks((-0.2,0,0.2))
    #plt.yticks(())
    #ax.grid(True, color='w', linewidth=1, linestyle = ':')

    if addZstContour:
        zstoic = get_fstoic(DI)
        Z = np.loadtxt(DI['pdir'] + "means_" + ZvarName + '.dat')
        Z = Z[:, 1:]
        plt.contour(X,
                    Y,
                    Z.T,
                    levels=np.array([zstoic]),
                    colors='white',
                    linewidth=0.1)

    #plt.show()
    plt.savefig(figName)
Esempio n. 23
0
def basic_stats(DI, nfbins=60, nx=-1, favre=False, do_yt=False):

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

    dataFiles = glob.glob(DI['cdir'] + "data_py/data_*.npy")
    ntimes = len(dataFiles)
    nrlz = get_nRlz(DI)
    varNames = get_dataHeaderVars(DI)
    times = get_inputFileParameter(
        DI, ("dumpTimes", ))  # times or ypositions if spatial
    nvar = len(varNames)
    cCoord = get_inputFileParameter(DI, ("params", "cCoord"))
    df = 1.0 / nfbins
    dxmin = get_inputFileParameter(DI, ("params", "dxmin"))
    nx = int(1.0 / dxmin / 10) if nx < 0 else nx
    x0, xL = get_domainBounds(DI)
    if nx % 2 == 0:
        nx = nx + 1  # make it odd for centerline

    try:
        imixf = varNames.index("mixf")
    except:
        imixf = -1
    try:
        irho = varNames.index("rho")
    except:
        irho = -1
    try:
        iposf = varNames.index("posf")
    except:
        raise ValueError("In basic_stats: no posf variable found")
    try:
        ipos = varNames.index("pos")
    except:
        raise ValueError("In basic_stats: no pos variable found")
    try:
        iuvel = varNames.index("uvel")
    except:
        iuvel = -1

    doConditional = True if imixf > -1 else False

    if irho == -1 and favre:
        raise ValueError(
            "In basic_stats: favre is true, but there is no rho in data file")

    if do_yt and (irho == -1 or iuvel == -1):
        raise ValueError(
            "In basic_stats: do_yt is true but missing rho or uvel in data file"
        )

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

    X = np.linspace(x0, xL, nx)
    fbins = np.linspace(df / 2.0, 1.0 - df / 2.0, nfbins)

    means = np.zeros((ntimes, nvar, nx))
    mean2 = np.zeros((ntimes, nvar, nx))
    rhoM = np.zeros((ntimes, nx))  # needed for favre, to normalize
    cmeans = np.zeros((ntimes, nvar, nfbins))
    cmean2 = np.zeros((ntimes, nvar, nfbins))
    binNrm = np.zeros((ntimes, nvar, nfbins))  # to normalize conditional means
    rhouu = np.zeros(ntimes)
    rhou = np.zeros(ntimes)

    for itime in range(ntimes):
        for irlz in range(nrlz):

            print("Processing time # %i of %i; for realization %i of %i" %
                  (itime + 1, ntimes, irlz + 1, nrlz))

            data = get_data_realization(DI, itime, irlz)
            x = data[:, ipos]
            xf = data[:, iposf]
            xf = np.append(xf, x[-1] + (xf[-1] - x[-1]))

            if doConditional:
                dx = np.abs(np.abs(xf[1:])**cCoord - np.abs(xf[0:-1])**cCoord)
                i = np.where(xf[1:] * xf[0:-1] < 0)[0]
                dx[i] = np.abs(
                    np.abs(xf[i + 1])**cCoord + np.abs(xf[i])**cCoord)
                ibin = (data[:, imixf] / df).astype(int)
                ibin[np.where(ibin < 0)] = 0
                ibin[np.where(ibin > nfbins - 1)] = nfbins - 1
                wt = dx * data[:, irho] if favre else dx.copy()

            if favre:
                fextrap = extrap1d(x, data[:, irho])
                rho = fextrap(X)
                rhoM[itime, :] = rhoM[itime, :] + rho

            for ivar in range(nvar):

                y = data[:, ivar]
                fextrap = extrap1d(x, y)
                Y = fextrap(X)
                Y2 = Y**2.0

                means[itime,
                      ivar, :] = means[itime,
                                       ivar, :] + (Y * rho if favre else Y)
                mean2[itime,
                      ivar, :] = mean2[itime,
                                       ivar, :] + (Y2 * rho if favre else Y2)

                if doConditional:
                    cmeans[itime, ivar,
                           ibin] = cmeans[itime, ivar, ibin] + y * wt
                    cmean2[itime, ivar,
                           ibin] = cmean2[itime, ivar, ibin] + y * y * wt
                    binNrm[itime, ivar, ibin] = binNrm[itime, ivar, ibin] + wt

            if do_yt:
                fextrap = extrap1d(x, data[:, irho])
                rho = fextrap(X)
                fextrap = extrap1d(x, data[:, iuvel])
                uvel = fextrap(X)
                rhouu[itime] += np.sum(rho * uvel * uvel)
                rhou[itime] += np.sum(rho * uvel)

    if favre:
        means /= rhoM
        mean2 /= rhoM
    else:
        means /= nrlz
        mean2 /= nrlz

    sig2 = mean2 - means * means
    sig = np.sqrt(np.abs(sig2))

    if doConditional:
        cmeans = cmeans / binNrm
        cmean2 = cmean2 / binNrm
        cmeans[np.where(binNrm == 0)] = 0

        csig2 = cmean2 - cmeans * cmeans
        csig = np.sqrt(np.abs(csig2))
        csig[np.where(binNrm == 0)] = 0

    if do_yt:
        uavg = rhouu / rhou
        uavg_mid = 0.5 * (uavg[1:] + uavg[0:-1])
        Lspatial = get_inputFileParameter(DI, ("params", "Lspatial"))
        if Lspatial:
            print("setting ytu.dat for spatial case")
            ypos = np.array(times)
            dy = ypos[1:] - ypos[0:-1]
            tpos = np.cumsum(dy / uavg_mid)
            tpos = np.insert(tpos, 0, 0.0)
        else:  # temporal
            print("setting ytu.dat for temporal case")
            tpos = np.array(times)
            dt = tpos[1:] - tpos[0:-1]
            ypos = np.cumsum(dt * uavg_mid)
            ypos = np.insert(ypos, 0, 0.0)
        ytu = np.vstack([ypos, tpos, uavg]).T
        np.savetxt(DI['pdir'] + 'ytu.dat',
                   ytu,
                   header=" y(m) t(s) u(m/s)",
                   fmt="%15.8e ")

    #--------------------------------------------------------------------------------------------
    # write the mean and std data

    head = "x_(m)           "
    for i, time in enumerate(times):
        hi = str(i + 2) + "_" + str(time)
        hi = hi + (17 - len(hi)) * " "
        head = head + hi

    for i in range(nvar):
        var = means[:, i, :]
        var = np.reshape(var, (ntimes, nx))
        var = np.vstack([X, var]).T
        fname = DI['pdir'] + "means_" + varNames[i] + ".dat"
        np.savetxt(fname, var, header=head, fmt="%15.8e ")

    for i in range(nvar):
        var = sig[:, i, :]
        var = np.reshape(var, (ntimes, nx))
        var = np.vstack([X, var]).T
        fname = DI['pdir'] + "sig_" + varNames[i] + ".dat"
        np.savetxt(fname, var, header=head)

    #--------------------------------------------------------------------------------------------
    # write the conditional mean and std data

    if doConditional:

        head = "x_(m)           "
        for i, time in enumerate(times):
            hi = str(i + 2) + "_" + str(time)
            hi = hi + (17 - len(hi)) * " "
            head = head + hi

        for i in range(nvar):
            var = cmeans[:, i, :]
            var = np.reshape(var, (ntimes, nfbins))
            var = np.vstack([fbins, var]).T
            fname = DI['pdir'] + "cmeans_" + varNames[i] + ".dat"
            np.savetxt(fname, var, header=head, fmt="%15.8e ")

        for i in range(nvar):
            var = csig[:, i, :]
            var = np.reshape(var, (ntimes, nfbins))
            var = np.vstack([fbins, var]).T
            fname = DI['pdir'] + "csig_" + varNames[i] + ".dat"
            np.savetxt(fname, var, header=head)
Esempio n. 24
0
def urmsucl_xD(DI):  #use list of cases

    cases = []
    plotname = "urmsucl_xD"

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }

    for i in range(0, len(DI)):

        cases.append(DI[i]['cn'][8:])
        plotname += "__" + DI[i]['cn'][8:]

        mfile = DI[i]['pdir'] + "means_uvel.dat"
        sfile = DI[i]['pdir'] + "sig_uvel.dat"

        data = np.loadtxt(mfile, comments=commentHdr)
        y = data[:, 1:]
        data = np.loadtxt(sfile, comments=commentHdr)
        ys = data[:, 1:]

        npts, ntimes = np.shape(data)
        ntimes = ntimes - 1

        cLine = np.zeros(ntimes)
        scLine = np.zeros(ntimes)
        imid = int(npts / 2) + 1

        for it in range(ntimes):
            cLine[it] = y[imid, it]
            scLine[it] = ys[imid, it]

        times = get_inputFileParameter(DI[i], ("dumpTimes", ))
        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        times = np.array(times)

        data = np.vstack([times / D, cLine, scLine]).T

        axL.plot(data[:, 0], data[:, 2] / data[:, 1], color[DI[i]['cn']])

    axL.set_ylabel(r"$v_{rms,cL}/v_{cL}$", fontsize=22)
    axL.set_xlabel("$x/D$", fontsize=22)
    axL.legend(cases, loc='best', frameon=False, fontsize=8)
    axL.set_title("coldJet", fontsize=22)
    #axL.set_ylim([-3,3])
    #axL.set_xlim([-0.1,0.1])

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig("../../data/plots_coldJet/" +
                "urmsucl_xD__ALL".replace(".", "o"))
def get_dxpdfs(DI, nbins=60):

    #--------------------------------------------------------------------------------------------
    
    dataFiles = glob.glob(DI['cdir']+"data_py/data_*.npy")
    ntimes    = len(dataFiles)
    nrlz      = get_nRlz(DI)
    varNames  = get_dataHeaderVars(DI)
    times     = get_inputFileParameter(DI, ("dumpTimes",))         # times or ypositions if spatial
    times     = times[0:ntimes]    # limit times to number of dataFiles, not all listed dumpTimes
    nvar      = len(varNames)
    dxmin     = get_inputFileParameter(DI, ("params", "dxmin"))
    dxmax     = get_inputFileParameter(DI, ("params", "dxmax"))
    L         = get_inputFileParameter(DI, ("params", "domainLength"))
    x0, xL    = get_domainBounds(DI) 

    dxmin *= L
    dxmax *= L
    
    try :
        iposf = varNames.index("posf")
    except :
        raise ValueError("In basic_stats: no posf variable found")
    try :
        ipos = varNames.index("pos")
    except :
        raise ValueError("In basic_stats: no pos variable found")

    dxpdfs = np.zeros((nbins, ntimes))

    #--------------------------------------------------------------------------------------------
    
    for itime in range(ntimes) :
        
        dx = np.empty(0)

        fname = DI['cdir']+"data_py/data_py_" + "{0:0>5}".format(itime) + ".npy"
        data_all = np.load(fname)
        posf_all   = data_all[:,1]
        dx_all = posf_all[1:]-posf_all[0:-1]

        istarts = np.where(dx_all <0.0)[0] + 1
        istarts = np.insert(istarts, 0, 0.0)

        iends = np.where(dx_all < 0.0)[0]
        iends = np.append(iends, len(posf_all)-1)
        
        nrlz = len(istarts)  # some sims end early so compute nrlz for each time

        for irlz in range(nrlz) : 
    
            print("Processing time # %i of %i; for realization %i of %i" %(itime+1, ntimes, irlz+1, nrlz))
    
            #data = get_data_realization(DI, itime, irlz)
            i_s = istarts[irlz]
            i_e = iends[irlz]

            data = data_all[i_s:i_e+1, :]
            x  = data[:,ipos]
            xf = data[:,iposf]
            xf = np.append(xf,x[-1]+(xf[-1]-x[-1]))       
            dx = np.append(dx, (xf[1:] - xf[0:-1]))

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

        #dxpdfs[:,itime], bins = compute_pdf(dx, dxmin, dxmax, nbins)
        dxpdfs[:,itime], bins = compute_pdf(np.log10(dx), np.log10(dxmin), np.log10(dxmax), nbins)

        bdx = np.vstack([bins,dxpdfs.T]).T

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

    head = " log(dx)[m]     "
    for i,time in enumerate(times) :
        hi = "loc_" + str(i+2) + "_" + str(time) 
        hi = hi + (22-len(hi))*" "
        head = head + hi
    np.savetxt(DI['pdir']+'dxpdfs.dat', bdx, header=head, fmt="%15.8e ", comments=commentHdr)
def intTKEdiss(DI, profName="TKEdiss"):  #uses list of cases

    cases = []
    plotname = "intTKEdiss"

    matplotlib.rcParams.update({
        'font.size': 20,
        'figure.autolayout': True
    })  #, 'font.weight':'bold'})

    fig, axL = plt.subplots()
    color = {
        'coldJet_base': 'k',
        'coldJet_base_gDens60': 'm',
        'coldJet_base_gDens120': 'b',
        'coldJet_C_10_gDens120': 'g',
        'coldJet_C_10_ZLES_7_gDens120': 'r',
        'coldJet_LplanarTau_gDens60': 'b--',
        'coldJet_ZLES_7_gDens120': 'c',
        'coldJet__LPlanarTau_C_10_ZLES_7_gDens60': 'r--'
    }

    for i in range(0, len(DI)):

        D = get_inputFileParameter(DI[i], ("initParams", "djeti"))
        L = get_inputFileParameter(DI[i], ("params", "domainLength"))
        mfile = DI[i]['pdir'] + "/means_" + profName + ".dat"
        data = np.loadtxt(mfile, comments=commentHdr)
        times = get_inputFileParameter(DI[i], ("dumpTimes", ))

        npts = len(data[:, 0])
        ntimes = len(times)
        icl = int(npts / 2) + 1
        r = data[:, 0]
        rnorm = np.empty((npts, ntimes))
        intTKEdiss = np.empty((npts - 1, ntimes))

        TKEr = np.empty((npts, ntimes))
        TKE = data[:, 1:]

        for ipt in range(npts):
            for itime in range(ntimes):
                TKEr[ipt, itime] = TKE[ipt, itime] * r[ipt]

        for itime in range(ntimes):
            intTKEdiss[icl:,
                       itime] = integrate.cumtrapz(TKEr[icl:, itime], r[icl:])
            rnorm[:, itime] = data[:, 0] / (times[itime] - 4.0 * D)

        j = 10
        axL.plot(rnorm[icl + 1:, j], intTKEdiss[icl:, j],
                 color[DI[i]['cn']])  #x=50D
        #plot fit line to check that it starts after asymptote reached to ensure correct y-intercept value
        m, b = np.polyfit(
            rnorm[icl + 8001:, j], intTKEdiss[icl + 8000:, j], 1
        )  #change index from icl+8001/icl+8000 depending on start of asymptote
        #fit = rnorm[icl+1:,j]*m+b
        #axL.plot(rnorm[icl+1:,j],fit,color[DI[i]['cn']][0]+':')

        #cases.append(DI[i]['cn'][8:]+', x=50D') #use if plotting fit
        #cases.append('$y_{int} = $'+str(b)[:7]) #use if plotting fit
        cases.append(DI[i]['cn'][8:] + ', x=50D, $y_{int}$ =' +
                     str(b)[:7])  #use if not plotting fit
        plotname += "__" + DI[i]['cn'][8:]

    axL.set_xlabel(r"$r/(x-x_0)$", fontsize=22)
    axL.set_ylabel(r"$\int \epsilon rdr$", fontsize=22)
    axL.set_title("coldJet", fontsize=22)
    axL.legend(cases, loc='best', frameon=False, fontsize=8)
    #axL.set_xlim([-.3,.3])
    #axL.set_ylim([-0.05,0.4])

    #plt.savefig('../../data/plots_coldJet/'+plotname.replace(".","o"))
    plt.savefig('../../data/plots_coldJet/' +
                'intTKEdiss__ALL'.replace(".", "o"))
Esempio n. 27
0
def get_pdfs(DI, favre=False, nbins=60):

    #--------------------------------------------------------------------------------------------
    
    dataFiles = glob.glob(DI['cdir']+"data_py/data_*.npy")
    ntimes    = len(dataFiles)
    nrlz      = get_nRlz(DI)
    varNames  = get_dataHeaderVars(DI)
    times     = get_inputFileParameter(DI, ("dumpTimes",))         # times or ypositions if spatial
    times     = times[0:ntimes]    # limit times to number of dataFiles, not all listed dumpTimes
    nvar      = len(varNames)
    cCoord    = get_inputFileParameter(DI, ("params", "cCoord"))
    dxmin     = get_inputFileParameter(DI, ("params", "dxmin"))
    dxmax     = get_inputFileParameter(DI, ("params", "dxmax"))
    L         = get_inputFileParameter(DI, ("params", "domainLength"))
    umax      =  get_inputFileParameter(DI, ("initParams", "vel_max"))
    umin      =  get_inputFileParameter(DI, ("initParams", "vel_min"))
    vmin      = -0.05*np.abs(umax-umin)
    vmax      = 0.05*np.abs(umax-umin)
    wmin      = -0.05*np.abs(umax-umin)
    wmax      = 0.05*np.abs(umax-umin)
    x0, xL    = get_domainBounds(DI) 

    dxmin *= L
    dxmax *= L
    
    try :
        iposf = varNames.index("posf")
    except :
        raise ValueError("In basic_stats: no posf variable found")
    try :
        ipos = varNames.index("pos")
    except :
        raise ValueError("In basic_stats: no pos variable found")
    try :
        irho = varNames.index("rho")
    except :
        irho = -1
    try :
        idvisc = varNames.index("dvisc")
    except :
        idvisc = -1
    try :
        imixf = varNames.index("mixf")
    except :
        imixf = -1
    try :
        iuvel = varNames.index("uvel")
    except :
        iuvel = -1
    try :
        ivvel = varNames.index("vvel")
    except :
        ivvel = -1
    try :
        iwvel = varNames.index("wvel")
    except :
        iwvel = -1

    if irho == -1 and favre :
        raise ValueError("In basic_stats: favre is true, but there is no rho in data file")

    dxpdfs = np.zeros((nbins, ntimes))

    P_uvel = np.zeros([nbins,ntimes])
    P_vvel = np.zeros([nbins,ntimes])
    P_wvel   = np.zeros([nbins,ntimes])
    P_diss = np.zeros([nbins,ntimes])
    P_logDiss = np.zeros([nbins,ntimes])
    P_diffU  =  np.zeros([nbins,ntimes])
    #P_logDiffUpos = np.zeros([nbins,ntimes])
    #P_logDiffUneg = np.zeros([nbins,ntimes])

    dumpTimesString = ''

    #--------------------------------------------------------------------------------------------
    
    for itime in range(ntimes) :
        
        dx = np.empty(0)

        dumpTimesString = dumpTimesString + '"P(t='+'{:.2e}'.format(times[itime])+' s)" '
        fname = DI['cdir']+"data_py/data_py_" + "{0:0>5}".format(itime) + ".npy"
        data = np.load(fname)

        print("Processing time # %i of %i" %(itime+1, ntimes))
    
        x  = data[:,ipos]
        xf = data[:,iposf]
        xf = np.append(xf,x[-1]+(xf[-1]-x[-1]))    
        rho = data[:,irho]
        uvel = data[:,iuvel]
        vvel = data[:,ivvel]
        wvel = data[:,iwvel]
        dvisc = data[:,idvisc]

        wt1 = np.abs(np.abs(xf[1:])**cCoord - np.abs(xf[0:-1])**cCoord)
        i = np.where(xf[1:] * xf[0:-1] < 0)[0]
        wt1[i] = np.abs(np.abs(xf[i+1])**cCoord + np.abs(xf[i])**cCoord) 
        # the crossing between realizations is computed correctly, so we don't need to mask end points
        #maskCrossing = (xf[1:] > xf[0:-1])
        wt = ( wt1*rho if favre else wt1 ) #  don't need this: (wt1*rho if favre else wt1)*maskCrossing
        
        #--------------
        j = np.where(  ( uvel - umin ) > 0.0001*(umax-umin) )
        P_uvel[:,itime] , uvel_bins = compute_wpdf(uvel[j], wt[j], umin, umax, nbins)
        P_vvel[:,itime] , vvel_bins = compute_wpdf(vvel[j], wt[j], vmin, vmax, nbins)
        P_wvel[:,itime] , wvel_bins = compute_wpdf(wvel[j], wt[j], wmin, wmax, nbins)

        # dissipation computation
        uvel  = np.append(uvel,uvel[-1])  # get same number of entries as dx
        dvisc = np.append(dvisc,dvisc[-1]) 
        dx = (xf[1:] - xf[0:-1])
        du = ( uvel[1:] - uvel[0:-1] )
        dvisc = 0.5 * ( dvisc[1:] + dvisc[0:-1] )
        diss = dvisc * ( du / dx )**2.0 # uses dx from cell centers and averaged dvisc
        #don't compute dissipation at crossing and don't count points with negligible dissipation
        j = np.where( np.logical_and( dx > 0.0 , diss > 10**(-6) ) )
        P_diss[:,itime] , diss_bins = compute_wpdf(diss[j], wt[j], 0, 1000, nbins)
        P_logDiss[:,itime] , logDiss_bins = compute_wpdf(np.log10(diss[j]), wt[j], -6, 8, nbins)
        #--------------

        #dxpdfs[:,itime], bins = compute_pdf(dx, dxmin, dxmax, nbins)
        dxpdfs[:,itime], bins = compute_pdf(np.log10(dx[j]), np.log10(dxmin), np.log10(dxmax), nbins)

        bdx = np.vstack([bins,dxpdfs.T]).T

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

#    head = " log(dx)[m]     "  + dumpTimesString
#    for i,time in enumerate(times) :
#        hi = "time_" + str(i+2) + "_" + str(time) 
#        hi = hi + (22-len(hi))*" "
#        head = head + hi

    var = np.vstack([uvel_bins,P_uvel.T]).T
    head = " u[m/s]   "  + dumpTimesString
    np.savetxt(DI['pdir']+'pdfs_uvel.dat', var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = np.vstack([vvel_bins,P_vvel.T]).T
    head = " v[m/s]   "  + dumpTimesString
    np.savetxt(DI['pdir']+'pdfs_vvel.dat', var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = np.vstack([wvel_bins,P_wvel.T]).T
    head = " w[m/s]   "  + dumpTimesString
    np.savetxt(DI['pdir']+'pdfs_wvel.dat', var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = np.vstack([diss_bins,P_diss.T]).T
    head = " TKEdiss   "  + dumpTimesString
    np.savetxt(DI['pdir']+'pdfs_TKEdiss.dat', var, header=head, fmt="%15.8e ", comments=commentHdr)

    var = np.vstack([logDiss_bins,P_logDiss.T]).T
    head = " log10(TKEdiss)   "  + dumpTimesString
    np.savetxt(DI['pdir']+'pdfs_logTKEdiss.dat', var, header=head, fmt="%15.8e ", comments=commentHdr)