def separation_point(method, field_u, field_w, save=False):
    radius = 75
    theta = np.linspace(0, 120, 120)
    theta = theta * 2 * np.pi / 360
    x = 200 - radius * np.cos(theta)
    y = 150 + radius * np.sin(theta)

    j = np.floor(x / 10).astype(int)
    i = np.floor(y / 10).astype(int)

    dif_utab = []
    u_tab = []
    w_tab = []

    print(i[0])
    aux_u = field_u[i[0]][j[0]]

    for k in range(0, 120):
        ii = i[k]
        jj = j[k]
        val_u = field_u[ii][jj]
        val_w = field_w[ii][jj]

        dif_u = val_u - aux_u
        dif_utab.append(dif_u)

        u_tab.append(val_u)
        w_tab.append(val_w)

    max_idx_dif = max(range(len(dif_utab)), key=dif_utab.__getitem__)

    theta_sep = theta[max_idx_dif]

    # Plot
    legendloc = (0.75, 0.55)
    line_thickness = 1
    real_theta_sep = theta_sep + 0.255
    titlesize = 20
    axis_lbsize = 25
    tick_lbsize = 15
    tickn = 8

    fig = mplPlotter(light=True).setup2d(figsize=(8, 8))

    ax1 = mplPlotter(light=True, fig=fig, shape_and_position=111,
                     usetex=False).plot2d(x=theta,
                                          y=np.array(u_tab),
                                          resize_axes=False,
                                          color='red',
                                          label=r'$\mathit{u}$',
                                          more_subplots_left=True,
                                          linewidth=line_thickness)
    mplPlotter(
        light=True, fig=fig, ax=ax1, shape_and_position=111, usetex=False
    ).plot2d(
        x=theta,
        y=np.array(w_tab),
        plot_title=r'Velocity along sphere surface as a function of $\theta$,'
        + '\n plane y=0',
        title_size=titlesize,
        title_y=1.1,
        aspect=0.1,
        resize_axes=True,
        grid=True,
        gridlines='dotted',
        x_bounds=[0, 140 / 180 * np.pi],
        y_bounds=[-4, 13],
        custom_x_ticklabels=[0, 140],
        y_tick_number=tickn,
        x_tick_number=tickn,
        x_ticklabel_size=tick_lbsize,
        y_ticklabel_size=tick_lbsize,
        color='blue',
        label=r'$\mathit{w}$',
        more_subplots_left=True,
        linewidth=line_thickness,
        y_label=r'$\mathit{V}$' + ' $[m/s]$',
        ylabel_rotation=90,
        x_label=r'$\mathit{\theta}$' + ' $[deg]$',
        yaxis_label_size=axis_lbsize,
        xaxis_label_size=axis_lbsize)
    ax1.axvline(
        x=real_theta_sep,
        ymin=-5,
        ymax=15,
        c='green',
        linewidth=line_thickness,
        label=r'$\mathit{\theta_{sep}}$' +
        r'$ = {}^\circ$'.format(np.round(real_theta_sep / np.pi * 180, 2)))
    ax1.legend(loc=legendloc, fontsize=21)
    plt.tight_layout()
    if save is True:
        plt.savefig(os.path.join(img_path, 'sep_point_velocity.png'), dpi=150)
    plt.show()

    return theta_sep, u_tab, w_tab, theta
        r'C:\Users\xXY4n\AE BSc\AE Year 2\Aerodynamics project\Data Analysis\data\velocity_ensemble_averaged\{}\{}_{}.txt'
        .format(plane, 'w', version))
except:
    interpolate_all(fill=fill,
                    plane=plane,
                    version=version,
                    quirk=quirk,
                    filenamestart=filenamestart,
                    var=re.findall(r'-?\d+', plane)[0],
                    f=f)
"""
Plot
"""

# Subplot setup
fig = mplPlotter(light=True).setup2d(figsize=(20, 5))

y_ticks = 8
x_ticks = 9 if plane == 'y=0' or plane == 'z=0' else 8
degree = 2
tsize = 20
axsize = 20
pad = 15
tit_y = 1.05
cbtit_size = 15
fillsphere = True
aspect = 1
save = False
if plane == 'z=0' or plane == 'y=0':
    x_bounds = [0, 40]
    y_bounds = [0, 30]
                                                   plane=plane,
                                                   version=version,
                                                   quirk=quirk,
                                                   filenamestart=filenamestart,
                                                   var=re.findall(
                                                       r'-?\d+', plane)[0],
                                                   f=f)

if clean is True:
    clean_field()
"""
Plot
"""

# Subplot setup
fig = mplPlotter(light=True).setup2d(figsize=(20, 5))

y_ticks = 4
x_ticks = 5 if plane == 'y=0' or plane == 'z=0' else 4
degree = 2
tsize = 25
axsize = 25
pad = 15
tit_y = 1.05
cbtit_size = 15
fillsphere = True
aspect = 1

if plane == 'z=0' or plane == 'y=0':
    x_bounds = [0, 40]
    y_bounds = [0, 30]
        
diff_field = np.loadtxt(os.path.join(os.path.join(os.path.join(comp_field_path, comp_field), plane), '{}_{}.txt'.format(comp_field, comp)))
diff_field = w_mosaic
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
"""
diff_field = np.loadtxt(
    os.path.join(sub_field_path,
                 '{}_{}_vs_{}.txt'.format(comp, ensemble_method, comp_field)))

# Fields in plot
ens_field_title = 'RBF'
comp_field_title = 'Potential Flow'

# Figure setup
fig = mplPlotter(light=True).setup2d(figsize=(20, 6))

y_ticks = 4
x_ticks = 5 if plane == 'y=0' or plane == 'z=0' else 4
degree = 2
tsize = 25
axsize = 25
pad = 15
tit_y = 1.05
cbtit_size = 15
fillsphere = True
aspect = 1

if plane == 'z=0' or plane == 'y=0':
    x_bounds = [0, 40]
    y_bounds = [0, 30]
Exemplo n.º 5
0
import pandas as pd
import numpy as np

import scipy.interpolate as int
from scipy.signal import lfilter
from scipy.signal import savgol_filter
import scipy.optimize as optimize

from mpl_plotter_mpl_plotting_methods import MatPlotLibPublicationPlotter as mplPlotter

# Plot setup
fig = mplPlotter(light=True).setup2d(figsize=(7, 15))
legendloc = (0.6, -0.65)
pointsize = 3

# File read
df = pd.read_csv(
    r'C:\Users\xXY4n\AE BSc\AE Year 2\Aerodynamics project\Data Analysis\data\stagnation_line\stagnation_line_z=0.csv',
    index_col=0)

df.columns = ['x', 'y', 'z', 'u', 'v', 'w']

xticks = 6
yticks = 6

# Experimental data
x = df['x']
u = df['u']
ax1 = mplPlotter(light=True, fig=fig, shape_and_position=411,
                 usetex=False).plot2d(
                     x=x,
if save is True:
    dpi = 150
    if epsilon2 == 500:
        filename = r'C:\Users\xXY4n\AE BSc\AE Year 2\Aerodynamics project\Data Analysis\images\2DInterpolation_epsilon500_{}.png'.format(comp)
    else:
        filename = r'C:\Users\xXY4n\AE BSc\AE Year 2\Aerodynamics project\Data Analysis\images\2DInterpolation_{}_{}.png'.format(function, comp)
else:
    dpi = None
    filename = None

"""
Scatter
"""
widths = [1, 1, 1, 1]
heights = [1]
fig = mplPlotter(light=True).setup2d(figsize=(22, 7))
legendloc=(0.6, -0.5)
y_ticks = 6
x_ticks = 6
degree = 2
tsize=16
axsize = 15
pad = 15
tity = 1.05
shrink = 0.32

cb_vmin = arrcomp[0].min()
cb_vmax = arrcomp[0].max()
cmap = 'RdBu'

mplPlotter(light=True, fig=fig, shape_and_position=141).plot2d(scatter=True, x=y, y=z, c=arrcomp[0],