Exemplo n.º 1
0
def plotIntegralLength(Lux, dz):
    # Setting up the y-Axis
    sp  = Lux.shape
    nz  = sp[0]
    z   = np.linspace(0, (nz-1)*dz, nz)

    # Setting up data to be plotted
    x = [Lux]
    y = [z]

    # Setting up the plot
    xlabel  = "Lux(z)"
    ylabel  = "z"
    title   = "Integral length scale"
    legend  = ["Lux(z)"]

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))
    dir_fileName = "Integral_Length_Luu"

    style_dict = {"savefig.format": "svg"}

    # Plotting
    plt.plot2D(x, y, xlabel=xlabel, ylabel=ylabel, title=title, legend=legend,
               dir_fileName=dir_fileName, style_dict=style_dict, 
               colorScheme='UniS', variation='color',
               savePlt=True, showPlt=True)
Exemplo n.º 2
0
def plotCorrelationCoeff(Ruu, dx, nz):
    # Setting up the x-Axis
    sp = Ruu.shape
    nx = sp[0]
    x = np.linspace(0, (nx-1)*dx, nx)

    # Setting up data to be plotted
    x = [x]
    y = [Ruu[:, nz]]

    # Setting up the plot
    xlabel = "Delta x"
    ylabel = "Ruu (Delta x)"
    title = "Correlation Coefficient"
    legend = ["Ruu at nz = " + str(nz)]

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))
    dir_fileName = "Correlation_Coefficient_Ruu"

    style_dict = {"savefig.format": "svg"}

    # Plotting
    plt.plot2D(x, y, xlabel=xlabel, ylabel=ylabel, title=title, legend=legend,
               dir_fileName=dir_fileName, style_dict=style_dict, 
               colorScheme='UniS', variation='color',
               savePlt=True, showPlt=True)
def plotTurbulenceIntensity(Iuu, dz):
    # Setting up the y-Axis
    sp = Iuu.shape
    nz = sp[0]
    z = np.linspace(0, (nz-1)*dz, nz)

    # Setting up data to be plotted
    x = [Iuu*100]
    y = [z]

    # Setting up the plot
    xlabel = "Iuu(z)"
    ylabel = "z"
    title = "Turbulence intensity"
    legend = ["Iuu(z)"]

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))
    dir_fileName = "Turbulence_Intensity_Iuu"

    style_dict = {"savefig.format": "svg"}

    # Plotting
    plt.plot2D(x, y, xlabel=xlabel, ylabel=ylabel, title=title, legend=legend,
               dir_fileName=dir_fileName, style_dict=style_dict,
               colorScheme='UniS', variation='color',
               savePlt=True, showPlt=True)
Exemplo n.º 4
0
def main():

    # Specify the file name
    # fname = str(input("Specify File Name: "))
    fname1 = "Timeseries_Baseshear_Fx_1_conv_ref0"
    fname2 = "Timeseries_Baseshear_Fx_1_conv_ref1"
    fname3 = "Timeseries_Baseshear_Fx_1_conv_ref2"

    # Change to current
    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))

    # Load the ax-object
    ax1 = pkl.load(open(fname1 + '.pickle', 'rb'))
    ax2 = pkl.load(open(fname2 + '.pickle', 'rb'))
    ax3 = pkl.load(open(fname3 + '.pickle', 'rb'))

    # Get data from the ax-object
    x1, y1 = getData(ax1)
    x2, y2 = getData(ax2)
    x3, y3 = getData(ax3)

    # Clean up
    plt.close('all')

    # Plotting
    x = [x1 + 2, x2 + 1, x3]
    y = [y1, y2, y3]

    plot2D.plot2D(x, y, showPlt=True)
Exemplo n.º 5
0
def plotTimeseries(Ti, Fi):
    # --- Calculation --#
    meanFi, stdFi, _rmsFi, _maxFi, _minFi, _nAvMax, _maxAvFi, _minAvFi = calcStatistics(
        Fi)

    hLines = [meanFi, meanFi + stdFi, meanFi - stdFi]
    hTexts = ["\$F_{x,mean}\$", "\$F_{x,mean+std}\$", "\$F_{x,mean-std}\$"]

    # ---- Plotting ----#
    xlabel = "$Time$ $[s]$"
    ylabel = "\$F_{x} [MN]\$"
    title = "Time Series of Base Shear F_{x}"

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))
    dir_fileName = "Timeseries_Baseshear_Fx"

    xlim = []
    ylim = []

    style_dict = {"lines.linewidth": "0.75", "savefig.format": "svg"}

    plt.plot2D(Ti, Fi, xlabel=xlabel, ylabel=ylabel, title=title,
               dir_fileName=dir_fileName, hLines=hLines, hTexts=hTexts, xlim=xlim, ylim=ylim,
               style_dict=style_dict, colorScheme='UniS', variation='color',
                 showPlt=True, savePkl=True, savePlt=True)
Exemplo n.º 6
0
def plotSpectra(f, Sa):  #comp
    # Function fit
    # # Set up logspace
    # fx_fit = np.logspace(np.log10(fx[1]), np.log10(fx[-1]), num=1000)

    # # Interpolate to grid
    # Sa_fit = griddata(fx, Sa, fx_fit, method='cubic')

    # Fit a function to the values
    # Sa_fit = savgol_filter(Sa, 51, 3)      # window size 51, polynomial order 3

    # Setting up the plot
    x = [f]
    y = [Sa]

    #maximum peak frequency

    max_fq = f[np.argmax(Sa)]

    # ---- Plotting ----#
    xlabel = "f"
    ylabel = "PSD "  #(" + comp + ")
    title = "Power Spectral Density"
    vLines = [max_fq]
    vTexts = [r"\$f_{peak}" + '{:03.4f}'.format(max_fq) + r"\$"]
    legend = ["measured"]

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))
    dir_fileName = "PowerSpectralDensity__Baseshear_Fx"

    xlim = []
    ylim = [10**-3, 10**1.5]

    style_dict = {"savefig.format": "svg"}

    plt.plot2D(
        x,
        y,
        xlabel=xlabel,
        ylabel=ylabel,
        title=title,
        legend=legend,
        vLines=vLines,
        vTexts=vTexts,
        dir_fileName=dir_fileName,
        xlim=xlim,
        ylim=ylim,
        xscale='log',
        yscale='log',
        style_dict=style_dict,
        colorScheme='UniS',
        variation='color',
        savePlt=True,
        showPlt=True,
        savePkl=True,
    )
Exemplo n.º 7
0
def replotMerged(x, y, legend, hLines, hTexts, xlabel, ylabel):
    plot2D.plot2D(x,
                  y,
                  title="Comparison Fx_Mean",
                  legend=legend,
                  ylim=[4.5, 6.5],
                  hLines=hLines,
                  hTexts=hTexts,
                  showPlt=True,
                  xlabel=xlabel,
                  ylabel=ylabel)
def plot(PSD_u_prime_measured, fx_red):
    # --- To compare with exact spectra --- #
    # Exact Kaimal Spectra, see "Kaimal, Wyngaard, Izumi, Cote - Spectral
    # characteristics of surface layer turbulence", Quarterly Journal of the Royal
    # Meteorological Society 98 (1972) or "Cheynet, Jakobsen, Obhrai - Spectral characteristics
    # of surface-layer turbulence in the North Sea" (2017)

    def PSD_u_prime_exact(n): return (a * n ** gamma) / \
        (c + b * n ** alpha) ** beta

    # Kaimal Spectra:
    a = 1 * 52.5                      # Factor 1 or 2 for one- or two-sided specta
    b = 33
    alpha = 1
    beta = 5/3
    gamma = 1
    c = 1

    # --- Fit function to measured spectra --- #
    # Fit a function to the values
    popt, pcov = curve_fit(fit_func, fx_red, PSD_u_prime_measured)
    PSD_u_prime_fit = fit_func(fx_red, *popt)

    # Setting up data to be plotted
    x = [fx_red]
    y = [PSD_u_prime_exact(fx_red), PSD_u_prime_measured, PSD_u_prime_fit]

    # Setting up the plot
    xlabel = "fx,red"
    ylabel = "f x PSD / (u_tau ** 2)"
    title = "Turbulent kinetic energy spectrum"
    legend = ["exact", "measured", "fit"]

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))
    dir_fileName = "Turbulenc_kinetic_energy_spectrum_Su"

    style_dict = {"savefig.format": "svg"}

    # Plotting
    plt.plot2D(x, y, xlabel=xlabel, ylabel=ylabel, title=title, legend=legend,
               xscale='log', yscale='log',
               dir_fileName=dir_fileName, style_dict=style_dict,
               colorScheme='UniS', variation='color',
               savePlt=True, showPlt=True)
Exemplo n.º 9
0
def samplePlots(*, showPlt=False):
    # Dataset x-Axis
    x = np.linspace(0, 2 * np.pi, 50)

    # Change to current file location
    os.chdir(os.path.dirname(sys.argv[0]))

    # FIRST PLOT
    # ----------
    y = np.sin(x)
    title = "First Plot"

    dir_fileName = "plot_as_pickle_01"

    # plot2D w/ only specified options, save as .pickle
    plot2D.plot2D(x,
                  y,
                  title=title,
                  dir_fileName=dir_fileName,
                  savePkl=True,
                  showPlt=showPlt)

    # SECOND PLOT
    # -----------
    y = np.cos(x)
    title = "Second Plot"

    dir_fileName = "plot_as_pickle_02"

    # plot2D w/ only specified options, save as .pickle
    plot2D.plot2D(x,
                  y,
                  title=title,
                  dir_fileName=dir_fileName,
                  savePkl=True,
                  showPlt=showPlt)

    # THIRD PLOT
    # ----------
    y = np.cos(2 * x)
    title = "Third Plot"

    dir_fileName = "plot_as_pickle_03"

    # plot2D w/ only specified options, save as .pickle
    plot2D.plot2D(x,
                  y,
                  title=title,
                  dir_fileName=dir_fileName,
                  savePkl=True,
                  showPlt=showPlt)
Exemplo n.º 10
0
def main():
    # Get name of input file
    # fname = sys.argv [1]
    fname = "/media/dani/linuxHDD/visualStudio/cfdPostProcessing/WindTunnelPostprocessing/T115_6/T115_6_000.mat"

    # Clean up results folder
    # delFilesInFolder('T115_6/results')

    # Full scale building properties
    uH_f    = 38             # m/s       // Wind speed at z = H (50yr)
    H_f     = 160               # m         // Building height
    B       = 32                # m         // Building width
    dns     = ['D', 'L']        #           // Directions (Drag/Lifts)
 

    # @DL: Folgende Variablen ignorieren, 
    # Diese wären nur wichtig für Strukturanalyse
    nF      = 32                #           // Number of floors
    nM      = 4                 #           // Number of modules
    b       = 16                # m         // Core wall thickness    
    D       = 0.02              # %         // Damping
    I       = 477.924           # m4        // Starting value
    E       = 28900 * 10 ** 3   # kN/m2     // E-Modulus
    mue     = 30473 / H_f       # t/m       // Mass distribution

    # Iterate over both directions (D/L)
    for dn in dns:    
        # Load wind tunnel model properties, TPU Database files
        wtModelProp = modelProp.wtModelProp(fname)
        wtModelProp.loadTPUModelProp()

        # Initialize building model properties
        buildProp = modelProp.buildProp(H_f, B, nF, nM, dn, E, I, D, uH_f)
        
        # Load aerodynamic forces in model scale
        wtModelAeroForces = aeroForces.wtModelAeroForces()
        wtModelAeroForces.loadTPUModelForces(wtModelProp, buildProp)

        # Calculate scaling factors
        scalingFactors = scaling.scalingFactors(wtModelProp, buildProp)

        # Scale wind tunnel model
        buildProp.scaleBuildProp(wtModelProp, scalingFactors)

        # Scale forces
        buildAeroForces = aeroForces.buildAeroForces(scalingFactors, wtModelAeroForces)

        # All forces are in kN
        print("Direction: " + dn)
        print("Mean Base Force: " + '{:02.3f}'.format(np.mean(buildAeroForces.BF_p)))
        print("Min Base Force: " + '{:02.3f}'.format(np.min(buildAeroForces.BF_p)))
        print("Max Base Force: " + '{:02.3f}'.format(np.max(buildAeroForces.BF_p)))
        print("Std Base Force: " + '{:02.3f}'.format(np.std(buildAeroForces.BF_p)))
        
        meanBF, stdBF, rmsBF, maxBF, minBF = calcStatistics(buildAeroForces.BF_p)
        hLines = [meanBF, meanBF + stdBF, meanBF - stdBF]
        hTexts = ["\$F_{x,mean}\$", "\$F_{x,mean+std}\$", "\$F_{x,mean-std}\$"]




        # Time series of base forces
        t = np.linspace(0, buildProp.nT*buildProp.dT, buildProp.nT)
        F = buildAeroForces.BF_p
        
        style_dict = {"lines.linewidth": "0.5", "savefig.format": "svg"}
        plt.plot2D(t, F, hLines=hLines,   style_dict=style_dict, xlabel="Time [s]", ylabel= "Base Force " + dn + " [kN]", title="Time series of base forces", showPlt=True)            
Exemplo n.º 11
0
def main(dObject):
    # Get ouput directory
    outDir = '/media/dani/linuxHDD/openfoam/simpleFoam/testing/'
    fname0 = '/media/dani/linuxHDD/openfoam/simpleFoam/testing/1_conv_ref0/postProcessing/forces/0/force.dat'
    interpForces = readForces.importForces(fname0)

    # Get data to plot
    sT = min(interpForces[0])
    eT = max(interpForces[0])
    dT = interpForces[0][1] - interpForces[0][0]
    nT = len(interpForces[0] * dT)

    T = np.linspace(sT, eT, nT)

    BF = interpForces[2] / (10**6)

    # Specify Cut-Off time
    print("Specify time range to plot")
    sT = int(input("Start Time: "))
    eT = int(input("End Time:   "))
    print("Specify time to start evaluation")
    sT_S = int(input("Start Time: "))

    for comp in BF:

        # Cut the array to desired range
        x = T[int(sT_S / dT):int(eT / dT)]
        y = BF[comp][int(sT_S / dT):int(eT / dT)]

        # Filter anomalies if desired
        # flagFilter = input("Shall data for " + comp + " be filtered? (Y/N): ")

        # if flagFilter == "Y":
        #     y = filterDataWithStd(y, comp, dT, sT)

        # Calculate statistic properties
        meanBF, rmsBF, stdBF = statisticsOverTimeSeries(y)

        x = [x]

        # Plot the mean / time
        y = [meanBF]

        xlabel = r"$Time [s]$"
        if "F" in comp:
            ylabel = r"$Mean F_{} [MN]$".format(comp[1])
            legend = [r"$Mean F_{}$".format(comp[1])]
            title = "Mean Base Shear"
            app = comp + "_" + str(int(round(np.min(x)))) + "_" + str(
                int(round(np.max(x))))
            dir_fileName = outDir + "Mean_BaseShear_" + app

        elif "M" in comp:
            ylabel = r"$Mean M_{} [MNm]$".format(comp[1])
            legend = [r"$Mean M_{}$".format(comp[1])]
            title = "Mean Base Moment"
            app = comp + "_" + str(int(round(np.min(x)))) + "_" + str(
                int(round(np.max(x))))
            dir_fileName = outDir + "Mean_BaseMoment_" + app

        xlim = []
        ylim = []

        style_dict = {"lines.linewidth": 1.0, "figure.figsize": "11.0, 4.8"}

        plt.plot2D(x,
                   y,
                   xlabel,
                   ylabel,
                   title,
                   legend,
                   dir_fileName,
                   xlim=xlim,
                   ylim=ylim,
                   xscale='linear',
                   yscale='linear',
                   style_dict=style_dict,
                   colorScheme='TUM',
                   variation='color')

        # Plot the root-mean-square / time
        y = [rmsBF]

        xlabel = r"$Time [s]$"
        if "F" in comp:
            ylabel = r"$RMS F_{} [MN]$".format(comp[1])
            legend = [r"$RMS F_{}$".format(comp[1])]
            title = "Root-Mean-Square Base Shear"
            app = comp + "_" + str(int(round(np.min(x)))) + "_" + str(
                int(round(np.max(x))))
            dir_fileName = outDir + "RMS_BaseShear_" + app

        elif "M" in comp:
            ylabel = r"$RMS M_{} [MNm]$".format(comp[1])
            legend = [r"$RMS M_{}$".format(comp[1])]
            title = "Root-Mean-Square Base Moment"
            app = comp + "_" + str(int(round(np.min(x)))) + "_" + str(
                int(round(np.max(x))))
            dir_fileName = outDir + "RMS_BaseMoment_" + app

        xlim = []
        ylim = []

        style_dict = {"lines.linewidth": 1.0, "figure.figsize": "11.0, 4.8"}

        plt.plot2D(x,
                   y,
                   xlabel,
                   ylabel,
                   title,
                   legend,
                   dir_fileName,
                   xlim=xlim,
                   ylim=ylim,
                   xscale='linear',
                   yscale='linear',
                   style_dict=style_dict,
                   colorScheme='TUM',
                   variation='color')

        # Plot the standart deviation / time
        y = [stdBF]

        xlabel = r"$Time [s]$"
        if "F" in comp:
            ylabel = r"$STD F_{} [MN]$".format(comp[1])
            legend = [r"$STD F_{}$".format(comp[1])]
            title = "Standard Deviation Base Shear"
            app = comp + "_" + str(int(round(np.min(x)))) + "_" + str(
                int(round(np.max(x))))
            dir_fileName = outDir + "STD_BaseShear_" + app

        elif "M" in comp:
            ylabel = r"$STD M_{} [MNm]$".format(comp[1])
            legend = [r"$STD M_{}$".format(comp[1])]
            title = "Standard Deviation Base Moment"
            app = comp + "_" + str(int(round(np.min(x)))) + "_" + str(
                int(round(np.max(x))))
            dir_fileName = outDir + "STD_BaseMoment_" + app

        xlim = []
        ylim = []

        style_dict = {"lines.linewidth": 1.0, "figure.figsize": "11.0, 4.8"}

        plt.plot2D(x,
                   y,
                   xlabel,
                   ylabel,
                   title,
                   legend,
                   dir_fileName,
                   xlim=xlim,
                   ylim=ylim,
                   xscale='linear',
                   yscale='linear',
                   style_dict=style_dict,
                   colorScheme='TUM',
                   variation='color')

    print("\n")
    def plotConvergence(self, outDir, sT, eT, stat):

        dir_fileName = outDir + "Baseshear"
        x = self.delta_x_k_m
        y = self.S_k_m

        if self.convrgFlag == "Convergent":
            hLines = [self.S_C, 1.728]  #1.551058 4.970328
            hTexts = ['estimate', 'Windtunnel']
            print(self.S_C)
        else:
            hLines = None
            hTexts = None

        # # 1) For Mean
        # if "Mean" in designation:
        #     if "F" in comp:
        #         ylabel  = r"\$\overbar{F_{" + r"{}".format(comp[1]) + r"}}~[MN]\$"
        #         title   = r"Convergence Mean F \textsubscript{" + r"{}".format(comp)[1] + r"}"
        #     elif "M" in comp:
        #         ylabel  = r"\$\overbar{M_{" + r"{}".format(comp[1]) + r"}}~[MNm]\$"
        #         title   = r"Convergence Mean M \textsubscript{" + r"{}".format(comp)[1] + r"}"

        # # 2) For RMS
        # elif "RMS" in designation:
        #     if "F" in comp:
        #         ylabel  = r"\$F_{" + r"{}".format(comp[1]) + r",rms}~[MN]\$"
        #         title   = r"Convergence RMS F \textsubscript{" + r"{}".format(comp)[1] + r"}"
        #     elif "M" in comp:
        #         ylabel  = r"\$M_{" + r"{}".format(comp[1]) + r",rms}~[MNm]\$"
        #         title   = r"Convergence RMS M \textsubscript{" + r"{}".format(comp)[1] + r"}"

        # # 3) For Std
        # elif "Std" in designation:
        #     if "F" in comp:
        #         ylabel  = r"\$F_{" + r"{}".format(comp[1]) + r",}~[MN]\$"
        #         title   = r"Convergence Std F \textsubscript{" + r"{}".format(comp)[1] + r"}"
        # elif "M" in comp:
        #     ylabel  = r"\$M_{" + r"{}".format(comp[1]) + r",std}~[MNm]\$"
        #     title   = r"Convergence Std M \textsubscript{" + r"{}".format(comp)[1] + r"}"

        # # 4) For Largest20Values
        # elif "Largest20" in designation:
        #     if "F" in comp:
        #         ylabel  = r"\$F_{" + r"{}".format(comp[1]) + r",max}~[MN]\$"
        #         title   = r"Convergence Max F \textsubscript{" + r"{}".format(comp)[1] + r"}"
        #     elif "M" in comp:
        #         ylabel  = r"\$M_{" + r"{}".format(comp[1]) + r",max}~[MNm]\$"
        #         title   = r"Convergence Max M \textsubscript{" + r"{}".format(comp)[1] + r"}"

        # # 5) For Smallest20Values
        # elif "Smallest20" in designation:
        #     if "F" in comp:
        #         ylabel  = r"\$F_{" + r"{}".format(comp[1]) + r",min}~[MN]\$"
        #         title   = r"Convergence Min F \textsubscript{" + r"{}".format(comp)[1] + r"}"
        #     elif "M" in comp:
        #         ylabel  = r"\$M_{" + r"{}".format(comp[1]) + r",min}~[MNm]\$"
        #         title   = r"Convergence Min M \textsubscript{" + r"{}".format(comp)[1] + r"}"

        xlim = [0, max(x) + max(x) * 0.2]
        ylim = [0, max(y) + max(y) * 0.5]
        # Change to current file location
        os.chdir(os.path.dirname(sys.argv[0]))

        style_dict = {
            "lines.linewidth": 0,
            "lines.markersize": 8,
            "savefig.format": "pdf",
            "lines.marker": "x"
        }
        xlabel = 'Zellanzahl Refinement Zone [10⁶]'
        ylabel = str(stat[3])
        title = str(stat[4])

        # Punkte mit Text
        annotate = [['coarse ' + str('{:03.2f}'.format(y[2])), (x[2], y[2])],
                    ['fine ' + str('{:03.2f}'.format(y[1])), (x[1], y[1])],
                    ['finest ' + str('{:03.2f}'.format(y[0])), (x[0], y[0])]]

        plt.plot2D(x,
                   y,
                   xlabel=xlabel,
                   ylabel=ylabel,
                   title=title,
                   dir_fileName=dir_fileName,
                   xlim=xlim,
                   ylim=ylim,
                   hLines=hLines,
                   hTexts=hTexts,
                   style_dict=style_dict,
                   variation='color',
                   savePlt=True,
                   showPlt=True,
                   annotate=annotate)