def decomposeDataAndPlot(step, subscript, startCol, fileName):
    # For xx component
    propertyDecomp = {}
    listY = []
    for i in range(nProbe):
        propertyDecomp['probe' +
                       str(i)] = probe.propertyData[fileName][:, startCol +
                                                              step * i]
        listY.append(propertyDecomp['probe' + str(i)])

    # listY = np.array(listY)
    if caseName == 'ALM_N_H_OneTurb':
        listY2 = [listY[3], listY[5], listY[7]]
        del listY[7]
        del listY[5]
        del listY[3]
        listY += listY2

    nPlot = 2 if caseName == 'ALM_N_H_OneTurb' else 1
    nProbePlot = (0, 5, nProbe) if caseName == 'ALM_N_H_OneTurb' else (0,
                                                                       nProbe)
    for i in prange(nPlot):
        yLim = (np.min(listY) - np.abs(np.min(listY) * 0.05),
                np.max(listY) + np.abs(np.max(listY) * 0.05))
        plot = Plot2D(listX[nProbePlot[i]:nProbePlot[i + 1]],
                      listY[nProbePlot[i]:nProbePlot[i + 1]],
                      save=saveFig,
                      name=fileName + '_' + subscript + '_Convergence_' +
                      str(i),
                      xLabel=xLabel,
                      yLabel=yLabel,
                      figDir=figDir,
                      xLim=xLim,
                      yLim=yLim,
                      figWidth=figWidth,
                      show=show,
                      gradientBg=gradientBg)

        plot.initializeFigure()
        plot.plotFigure(plotsLabel=lineLabels[nProbePlot[i]:nProbePlot[i + 1]])
        plot.finalizeFigure()
feat_importance_actual = feat_importance_all.copy()
actual_std = np.zeros_like(all_std)
feat_importance_actual[feat_importance_actual < threshold] = 0.
i0 = 0
for i in range(len(feat_importance_all)):
    if feat_importance_actual[i] != 0.:
        feat_importance_actual[i] = feat_importance[i0]
        actual_std[i] = std[i0]
        i0 += 1

myplot = Plot2D(
    (np.arange(1, 51), ) * 3,
    (feat_importance_all, feat_importance0, feat_importance_actual),
    save=True,
    show=False,
    xlabel='Feature',
    ylabel='Importance',
    figwitdh='1/3',
    figdir=figdir,
    name=estimator_name + '_importance_' + rf_selector_threshold,
    ylim=(0., 0.5))
myplot.initializeFigure()
myplot.plotFigure(linelabel=('TBRF feature selector', estimator_name,
                             'TBRF feature selector + ' + estimator_name),
                  showmarker=True)
myplot.axes.fill_between(np.arange(1, 51),
                         np.maximum(feat_importance_all - all_std, 0.),
                         feat_importance_all + all_std,
                         alpha=0.25,
                         color=myplot.colors[0],
                         lw=0.)
Example #3
0
        # Use magnitude
        if name == 'U':
            data_sorted = np.sqrt(data_sorted[:, 0]**2 + data_sorted[:, 1]**2 +
                                  data_sorted[:, 2]**2)
            data_sorted2 = np.sqrt(data_sorted2[:, 0]**2 +
                                   data_sorted2[:, 1]**2 +
                                   data_sorted2[:, 2]**2)

        listx = (data_sorted, data_sorted2)
        listy = (points_sorted, points_sorted2)

        myplot = Plot2D(listx,
                        listy,
                        plot_type='infer',
                        show=False,
                        save=True,
                        name=name,
                        xlabel=xlabel,
                        ylabel=r'$\frac{z}{z_i}$ [-]',
                        figdir=case.avg_folder_path,
                        figwidth='1/3',
                        xlim=xlim)
        myplot.initializeFigure()
        myplot.plotFigure(linelabel=('South', 'West'))
        myplot.axes.fill_between(xlim, 27 / 750., 153 / 750., alpha=0.25)
        myplot.finalizeFigure()

    kappa = .4
    uref = 8.
    zref = 90.
    z0 = .2
        if case.slices_orient[slicename] == 'vertical' else \
        (r'$x$ [m]', r'$y$ [m]')
    # Figure name
    if 'kResolved' in properties and 'kSGSmean' in properties:
        figname = 'kMean_' + slicenames[i] + slicenames_sub
    elif 'epsilonSGSmean' in properties and 'nuSGSmean' in properties:
        figname = 'epsilonMean_' + slicenames[i] + slicenames_sub
    else:
        figname = slicename

    if plot_type in ('2D', 'all'):
        slicePlot = Plot2D(x2d,
                           y2d,
                           vals3d,
                           name=figname,
                           xlabel=xlabel,
                           ylabel=ylabel,
                           val_label=val_label,
                           save=save,
                           show=show,
                           figdir=case.result_path)
        slicePlot.initializeFigure()
        slicePlot.plotFigure(contour_lvl=contour_lvl)
        slicePlot.finalizeFigure()

if plot_type in ('3D', 'all'):
    zlabel = r'$z$ [m]'
    # Figure name for 3D plots
    if 'kResolved' in properties and 'kSGSmean' in properties:
        figname_3d = 'kMean_' + str(slicenames)
    elif 'epsilonSGSmean' in properties and 'nuSGSmean' in properties:
        figname_3d = 'epsilonMean_' + str(slicenames)
# list_y = [list_y[i] - ymean if i < 3 else ymean1 for i in range(len(list_y))]
for i in range(len(list_y)):
    list_y[i] -= ymean if i < 3 else ymean1

# [DEPRECATED]
if figwidth == 'full':
    yoffset = 255.
    for i in range(3, 6):
        list_y[i] += yoffset

for i0 in range(len(fignames)):
    list_x = [np.array(g[set_locs[i]][i0]).T for i in range(len(set_locs))]
    gplot = Plot2D(list_x=list_x,
                   list_y=list_y,
                   name=fignames[i0],
                   xlabel=xlabel,
                   ylabel=ylabel,
                   save=save_fig,
                   show=show,
                   figdir=case.result_path,
                   figwidth=figwidth,
                   xlim=xlim,
                   ylim=ylim)
    gplot.initializeFigure()
    gplot.markercolors = None
    # Go through each line location
    for i in range(len(list_x)):
        # Then for each location, go through each line
        for j in range(3):
            label = labels[i0][j] if i == 0 else None
            # Flip y
            gplot.axes.plot(list_x[i][:, j],
                else:
                    list_y = (distance_test.take(sortidx), ) * 2
                    list_x = (y_test[:, i].take(sortidx),
                              y_pred_test[:, i].take(sortidx))
                    ylim = heightlim
                    xlim = bijlims
                    turblocs = (90. - 63., 90. + 63.)
                    xlabel, ylabel = bijlabels[i], 'Range [m]'

                bij_plot = Plot2D(list_x=list_x,
                                  list_y=list_y,
                                  name=fignames_bij[i],
                                  xlabel=xlabel,
                                  ylabel=ylabel,
                                  save=save_fig,
                                  show=show,
                                  figwidth='1/3',
                                  figheight_multiplier=figheight_multiplier,
                                  figdir=lineresult_folder,
                                  plot_type='infer',
                                  xlim=xlim,
                                  ylim=ylim)
                bij_plot.initializeFigure()
                if orient == 'H':
                    bij_plot.axes.fill_between(turblocs,
                                               bijlims[0],
                                               bijlims[1],
                                               alpha=0.5,
                                               facecolor=bij_plot.colors[2],
                                               zorder=-1)
                else:
for i in range(len(E)):
    # If plotting horizontal Eii
    if i != len(E) - 1:
        xList, yList = (Kr, E12ref[:, 0], Kr), (E[i], E12ref[:, 1], E_Kolmo)
        plotsLabel = (label, 'Churchfield et al.', 'Kolmogorov model')
    # Else if plotting E33
    else:
        xList, yList = (Kr, E33ref[:, 0], Kr), (E[i], E33ref[:, 1], E_Kolmo)
        plotsLabel = (label, 'Churchfield et al.', 'Kolmogorov model')

    # Initialize figure
    plot = Plot2D(xList,
                  yList,
                  xLabel=xLabels,
                  yLabel=yLabels[i],
                  name=figNames[i],
                  save=save,
                  show=show,
                  xLim=xLim,
                  yLim=yLim,
                  figDir=resultPath)
    plot.initializeFigure()
    plot.plotFigure(plotsLabel=plotsLabel)
    plot.axes[0].fill_between((1. / cellSizes2D[0], xLim[1]),
                              yLim[0],
                              yLim[1],
                              alpha=fillAlpha,
                              facecolor=plot.gray,
                              zorder=-1)
    plot.finalizeFigure(xyScale=('log', 'log'))

# [DEPRECATED]
        xy_bary_pred_v = xy_bary_pred_v[y_idx]
        list_ccy_v.append(ccy_v[y_idx])

    # Limit predicted barycentric x, y coor
    xy_bary_pred_v[xy_bary_pred_v < -0.1] = -0.1
    xy_bary_pred_v[xy_bary_pred_v > 1.] = 1.

    # Plot Barycentric triangle
    list_x = (xy_bary_test_v[:, 0], xy_bary_pred_v[:, 0])
    list_y = (xy_bary_test_v[:, 1], xy_bary_pred_v[:, 1])
    figname = 'triangle{}'.format(i)
    barymap = Plot2D(list_x,
                     list_y,
                     name=figname,
                     xlabel=None,
                     ylabel=None,
                     save=save_fig,
                     show=show,
                     figwidth='1/3',
                     figheight_multiplier=1,
                     figdir=case.result_paths[time],
                     equalaxis=True)
    barymap.initializeFigure()
    barymap.axes.add_patch(next(tripatches))
    barymap.plotFigure(linelabel=('Truth', 'Prediction'), showmarker=True)
    plt.axis('off')
    barymap.axes.annotate(r'$\textbf{X}_{2c}$', (0., 0.), (-0.15, 0.))
    barymap.axes.annotate(r'$\textbf{X}_{3c}$', (0.5, np.sqrt(3) / 2.))
    barymap.axes.annotate(r'$\textbf{X}_{1c}$', (1., 0.))
    barymap.finalizeFigure(legloc='upper left')

    # Retrieve TKE Production G in Vertical Lines
Example #9
0
ymean1 = (max(list_y[-1]) + min(list_y[-1])) / 2.
# Center y around 0 y/D
for i in range(len(list_y)):
    list_y[i] -= ymean if i < 3 else ymean1

# if figwidth == 'full':
#     yoffset = 255.
#     for i in range(3, 6):
#         list_y[i] += yoffset

list_x = [g[set_types[i]] for i in range(len(set_types))]
# First plot of G for LES, TBDT, TBRF
gplot = Plot2D(list_x=[None],
               list_y=[None],
               name=figname,
               xlabel=xlabel,
               ylabel=ylabel,
               save=save_fig,
               show=show,
               figdir=case.result_path,
               figwidth=figwidth,
               xlim=xlim,
               figheight_multiplier=figheight_multiplier,
               ylim=ylim)
gplot.initializeFigure()
gplot.markercolors = None
# Go through each line location
for i in range(len(list_x)):
    # Then for each location, go through each line
    # for j in range(3):
    #     label = labels[j] if i == 0 else None
    #     # Plot each prediction and flip y
Example #10
0
 # Reference data, 1st column is x, 2nd column is y
 refData = readData(refDataName, fileDir=refDataDir, skipRow=0)
 # Since refData is sorted from low x to high x, what we want is from low y to high y
 # Thus sort the 2nd column
 refData = refData[refData[:, 1].argsort()]
 # Add both normalized simulation and reference data to lists to plot
 xList, yList = [uvwMean / Uhub,
                 refData[:, 0]], [bl.hLvls / zi, refData[:, 1]]
 # X, Y limit to be inline with Churchfield's data
 xLim, yLim = (0, 2), (0, 1)
 # Initialize figure object
 plot = Plot2D(xList,
               yList,
               xLabel=r'$\langle \overline{U}\rangle /U_{\rm{hub}}$',
               yLabel=r'$z/z_i$',
               figDir=figDir,
               name=profile,
               save=save,
               show=show,
               xLim=xLim,
               yLim=yLim)
 plot.initializeFigure()
 # Fill in the rotor swept area
 plot.axes[0].fill_between(xLim, ((zHub + D / 2) / zi, ) * 2,
                           ((zHub - D / 2) / zi, ) * 2,
                           alpha=0.25,
                           facecolor=plot.colors[2],
                           zorder=-1)
 plot.axes[0].fill_between(xLim, ((zi + 0.5 * invW) / zi, ) * 2,
                           ((zi - 0.5 * invW) / zi, ) * 2,
                           alpha=fillAlpha,
                           facecolor=plot.colors[3],