def compare_flow(var_key, *cases):
    """
    Compare distinct flow cases for a given variable on a
    grid of plots.
    :param var_key: Key of variable.
    :param cases: flowCase instances.
    :return: 1:success.
    """

    # Check valid key
    assert var_key in cases[
        0].flow_dict, "Invalid variable key given: %r" % var_key

    # Check required amount of subplots
    num_of_plots = len(cases)
    grid_length = int(num_of_plots**0.5) + 1

    # Create figure
    fig = plot.empty_plot(no_axis=True)

    # Add Title
    ax = fig.add_subplot(111)
    ax.set_title('Data basis with %r cases' % num_of_plots)
    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)

    # Plot individual cases
    for i, case in enumerate(cases):
        ax = fig.add_subplot(grid_length, grid_length,
                             i + 1)  # Add plot to grid
        ax.get_xaxis().set_visible(False)  # No axes
        ax.get_yaxis().set_visible(False)

        x = case.flow_dict['x']
        y = case.flow_dict['y']
        nx = case.flow_dict['nx']
        ny = case.flow_dict['ny']
        var = case.flow_dict[var_key]

        plot.contouring(x.reshape(nx, ny),
                        y.reshape(nx, ny),
                        var.reshape(nx, ny),
                        xlabel='',
                        ylabel='',
                        colorbar=False,
                        append_to_fig_ax=(fig, ax))
    plot.show()

    return 1
Esempio n. 2
0
# compare_profiles('pm', 'x', 0, *hifi_data)
#
# # Fig 27 (a), (c)
# compare_profiles('um', 'y', 4, *hifi_data, xlim=[-0.2, 1.2], ylim=[-0.1, 3.1])
# compare_profiles('uu', 'y', 4, *hifi_data, xlim=[0, 0.1], ylim=[-0.1, 3.1])
#
# # Fig 23, tiny separation bubble
# hifi_data[3].show_flow('um', contour_level=[-0.1, 0, 0.1, 0.2, 0.3], xlim=[0.55, 0.93], ylim=[0.58, 0.82])
#
# # Fig 24, tiny recirculation bubble
# hifi_data[2].show_flow('um', contour_level=[-0.1, 0, 0.1, 0.2, 0.3], xlim=[6.9, 7.5], ylim=[-0.01, 0.31])
#
# # Fig 29, tke comparison
# hifi_data[0].show_flow('k', contour=False)
# hifi_data[-1].show_flow('k', contour=False)

# Fig 30, lumley triangles with invariants
loc = 4
p_IIb = get_profile_data(hifi_data[0], 'IIb', 'y', loc)
p_IIIb = get_profile_data(hifi_data[0], 'IIIb', 'y', loc)

p2_IIb = get_profile_data(hifi_data[-1], 'IIb', 'y', loc)
p2_IIIb = get_profile_data(hifi_data[-1], 'IIIb', 'y', loc)

fig, ax = empty_plot()
lining(p_IIIb[0][221:-1], p_IIb[0][221:-1], xlim=[-0.03, 0.09], ylim=[0, 0.41], append_to_fig_ax=(fig, ax), linestyle='-s')
lining(p2_IIIb[0][221:-1], p2_IIb[0][221:-1], xlim=[-0.03, 0.09], ylim=[0, 0.41], append_to_fig_ax=(fig, ax))


show()
# fig, ax = compare_profiles('uu', 'y+', 0.7, hifi_data[2], xlim=[1, 1e3], ylim=[-0.005, 0.017], xlog=True)
# compare_profiles('vv', 'y+', 0.7, hifi_data[2], xlim=[1, 1e3], ylim=None, xlog=True, append_to_fig_ax=(fig, ax))
# compare_profiles('ww', 'y+', 0.7, hifi_data[2], xlim=[1, 1e3], ylim=None, xlog=True, append_to_fig_ax=(fig, ax))
# compare_profiles('uv', 'y+', 0.7, hifi_data[2], xlim=[1, 1e3], ylim=None, xlog=True, append_to_fig_ax=(fig, ax))

# Fig 2, Evolution of Clauser beta
compare_integral_quantity('beta', 'x', *hifi_data, xlim=[0, 1], ylim=[0, 20])
# compare_integral_quantity('beta', 'Ret', *hifi_data, xlim=[0, 400], ylim=[0, 20])

# Fig 4, Evolution of Reynolds number wrt momentum thickness and friction (tau)
compare_integral_quantity('Reth', 'x', *hifi_data, xlim=[0, 1], ylim=[0, 3500])
# compare_integral_quantity('Ret', 'x', *hifi_data, xlim=[0, 1], ylim=[0, 500])

# Fig 6, Inner-scaled mean velocity profiles
compare_profiles('u+',
                 'y+',
                 0.4,
                 *hifi_data,
                 xlim=[1, 1e3],
                 ylim=[0, 30],
                 xlog=True)
compare_profiles('u+',
                 'y+',
                 0.75,
                 *hifi_data,
                 xlim=[1, 1e3],
                 ylim=[0, 30],
                 xlog=True)

plot.show()