Beispiel #1
0
def filt(X, Y, Z, sigma=2., display=False, **kwargs):
    nx, ny = Z.shape
    Zfilt = filters.gaussian_filter(Z, sigma=sigma)  # [...,0]

    #    print(Zfilt.shape)
    if display:
        graphes.color_plot(X, Y, Zfilt, **kwargs)

    imax, jmax = np.unravel_index(np.argmax(Zfilt), Zfilt.shape)
    imin, jmin = np.unravel_index(np.argmin(Zfilt), Zfilt.shape)

    deltax_max, deltay_max = SubPix2DGauss(Zfilt / np.max(Zfilt),
                                           imax,
                                           jmax,
                                           SubPixOffset=0)
    deltax_min, deltay_min = SubPix2DGauss(Zfilt / np.min(Zfilt),
                                           imin,
                                           jmin,
                                           SubPixOffset=0)

    xmin = X[imin, jmin] + deltax_min
    xmax = X[imax, jmax] + deltax_max
    ymin = Y[imin, jmin] - deltay_min
    ymax = Y[imax, jmax] - deltay_max

    return Zfilt, xmin, xmax, ymin, ymax
Beispiel #2
0
def spectrum_2d(M, indices=None):
    Fourier.compute_spectrum_2d(M, Dt=3)  # smooth on 3 time step.
    S_E = np.nanmean(M.S_E[..., indices], axis=2)
    graphes.color_plot(M.kx, M.ky, S_E, log=True, fignum=1)
    graphes.colorbar(label='$E_k$')
    figs = graphes.legende('$k_x$ (mm)', '$k_y$ (mm)', 'Energy Spectrum (log)')
    return figs
Beispiel #3
0
def time_average(M, indices=None):
    figs = {}
    fields, names, vmin, vmax, labels, units = std_fields()

    for j, field in enumerate(fields):
        Y = np.nanmean(getattr(M, field)[..., indices], axis=2)
        graphes.color_plot(M.x, M.y, Y, fignum=j + 1, vmin=vmin[j] / 5, vmax=vmax[j] / 5)
        graphes.colorbar(label=names[j] + ' ' + units[j])
        figs.update(graphes.legende('X (mm)', 'Y (mm)', 'Time averaged ' + field, cplot=True))
    return figs
Beispiel #4
0
def positions(M, i, field='omega', display=False, sigma=1., **kwargs):
    """
    find the maximum position of the vortex core at a given instant, using the field specified in argument
    """

    imin, imax, jmin, jmax, Zfilt, X, Y = position_index(M,
                                                         i,
                                                         field=field,
                                                         display=display,
                                                         sigma=sigma,
                                                         **kwargs)

    deltax_max, deltay_max = SubPix2DGauss(Zfilt / np.max(Zfilt),
                                           imax,
                                           jmax,
                                           SubPixOffset=0)
    deltax_min, deltay_min = SubPix2DGauss(Zfilt / np.min(Zfilt),
                                           imin,
                                           jmin,
                                           SubPixOffset=0)

    #   print(deltax_max)
    #   print(deltax_min)
    #   print(deltay_min)

    #    print(deltax_max)
    # if deltax_max == np.nan or deltax_min==np.nan:
    #    return np.nan,np.nan,np.nan,np.nan
    # else:
    xmin = X[imin, jmin] + deltax_min
    xmax = X[imax, jmax] + deltax_max
    ymin = Y[imin, jmin] - deltay_min
    ymax = Y[imax, jmax] - deltay_max

    #  print(Zfilt.shape)
    #  print(Y.shape)
    #  print(X.shape)

    if display:
        graphes.color_plot(X[:, 5:], Y[:, 5:], Zfilt / np.min(Zfilt), **kwargs)
        graphes.graph([xmin + 10], [ymin], label='bo', **kwargs)
        graphes.graph([xmax + 10], [ymax], label='ro', **kwargs)

        #  graphes.color_plot(X[:,5:],Y[:,5:],Zfilt/np.max(Zfilt),fignum=2)

        # input()
    #    t.append(M.t[i])
    #    Xmin.append(M.x[imin,jmin])
    #    Xmax.append(M.x[imax,jmax])
    #    Ymin.append(M.y[imin,jmin])
    #    Ymax.append(M.y[imax,jmax])

    return xmin, xmax, ymin, ymax
Beispiel #5
0
def spatial_decay(M, field='E', indices=None):
    from mpl_toolkits.axes_grid.inset_locator import inset_axes
    import stephane.vortex.track as track

    fields, names, vmin, vmax, labels, units = std_fields()
    j = fields.index(field)

    Z = np.nanmean(getattr(M, field)[..., indices], axis=2)

    X, Y = [], []
    for i in indices:
        tup = track.positions(M, i, field=field, indices=indices, step=1, sigma=10.)
        X.append(tup[1])
        Y.append(tup[3])
    X0, Y0 = np.nanmean(X), np.nanmean(Y)

    R, Theta = Smath.cart2pol(M.x - X0, M.y - Y0)
    R0 = M.param.Diameter

    Z_flat = np.ndarray.flatten(Z)
    R_flat = np.ndarray.flatten(R)
    Theta_flat = np.ndarray.flatten(Theta)

    phi = np.pi / 2
    C = np.mod((Theta_flat + phi + np.pi) / 2 / np.pi, 1)
    cmap = matplotlib.cm.hot
    color = [matplotlib.colors.rgb2hex(cmap(c)[:3]) for c in C]

    fig, ax2 = graphes.set_fig(1, subplot=122)
    fig.set_size_inches(20, 6)
    ax2.scatter(R_flat, Z_flat, marker='o', facecolor=color, alpha=0.3, lw=0, cmap=cmap)

    Rth = np.arange(10 ** 1, 10 ** 2, 1.)
    # graphes.graphloglog(Rth, 10 ** 5 * (Rth / R0) ** -3.2, label='k--')
    # graphes.graphloglog(Rth, 5 * 10 ** 4 * (Rth / R0) ** -4.5, label='k--')
    graphes.set_axis(10 ** 0, 10 ** 2, 10 ** 2, 8 * 10 ** 4)
    figs = graphes.legende('$R$ (mm)', 'Energy (mm$^2$/s$^{2}$)', 'Spatial decay')

    fig, ax1 = graphes.set_fig(1, subplot=121)
    graphes.color_plot(M.x, M.y, Z, fignum=1, vmin=0, vmax=40000, subplot=121)
    graphes.colorbar(label=names[j] + ' (' + units[j] + ')')
    figs.update(graphes.legende('X (mm)', 'Y (mm)', 'Time averaged ' + field, cplot=True))

    inset_ax = inset_axes(ax2, height="50%", width="50%", loc=3)
    inset_ax.pcolormesh(M.x / 10 - 10, M.y / 10 - 10, Theta, cmap=cmap)
    inset_ax.axis('off')

    return figs
Beispiel #6
0
def display_fft_2d(kx, ky, sk, fignum=1, vmin=1, vmax=7, log10=True):
    """Preview the 2d spectrum (typically energy spectrum) in log scale

    Parameters
    ----------
    kx : n x m float array
        wavenumbers in x dimension
    ky : n x m float array
        wavenumbers in y dimension
    S : n x m complex? array
        the fourier transform to display, supplied in raw linear scale
    fignum : int
        The index of the figure on which to plot the fft
    vmin : float
        minimum for the colorscale
    vmax : float
        maximum for the colorscale

    Returns
    -------
    cc :
    """
    # display in logscale
    fig, ax, cc = graphes.color_plot(kx, ky, sk, log10=log10, vmin=vmin, vmax=vmax, fignum=fignum)

    graphes.clegende(cc, '$\ln (E_k) [a.u.]$')
    return cc
def vfield(sigma, modes, fignum=1):
    names = {
        'sigma': sigma,
        'n': modes
    }  # name:eval(name) for name in ['sigma','n','N_p']}# this piece of code does not work

    t = distribution(sigma, modes)

    B = 1.
    n = 100
    dx = 2 * B / n
    x = np.arange(-B, B, dx)
    y = 0.
    z = np.arange(-B, B, dx)
    P = np.asarray(np.meshgrid(x, y, z))

    dim = P.shape
    N = np.prod(dim[1:])
    X = np.reshape(P[0, ...], (N, ))
    Y = np.reshape(P[1, ...], (N, ))
    Z = np.reshape(P[2, ...], (N, ))

    Pos = [np.asarray([x0, y0, z0]) for x0, y0, z0 in zip(X, Y, Z)]

    V = biot.velocity_from_line(t.paths, Pos, Gamma=1, d=3)

    V_2d = np.reshape(V, (n, n, 3))
    E = np.sum(np.power(V_2d, 2), axis=2)

    subplot = [111]
    fig, axes = panel.make(subplot, fignum=fignum)
    fig.set_size_inches(10, 10)

    graphes.color_plot(x, z, E, fignum=fignum, vmin=0, vmax=0, log=True)
    c = graphes.colorbar()

    figs = {}
    figs.update(graphes.legende('X', 'Z', 'E'))

    graphes.save_figs(figs,
                      prefix='Random_path/V_Distributions/Fields/',
                      suffix=suf(names),
                      dpi=300,
                      display=True,
                      frmt='png')
Beispiel #8
0
def position_index(M, i, field='omega', display=True, sigma=1., **kwargs):
    dx = M.x[0, 1] - M.x[0, 0]

    #    x0 = M.x[0,5]
    #    y0 = M.y[0,0]
    nx, ny, nt = M.shape()
    crop = True
    if crop:
        lin = slice(0, nx)
        col = slice(0, ny)
        X = M.x[lin, col]
        Y = M.y[lin, col]

    Zfilt = smoothing(M, i, field=field, sigma=sigma)
    if display:
        graphes.color_plot(X, Y, Zfilt, **kwargs)

    imax, jmax = np.unravel_index(np.argmax(Zfilt), Zfilt.shape)
    imin, jmin = np.unravel_index(np.argmin(Zfilt), Zfilt.shape)

    return imin, imax, jmin, jmax, Zfilt, X, Y
Beispiel #9
0
def make_2dmovie(M, Z, start, stop, Dirname='velocity_module', vmin=-3, vmax=3):
    # Movie of the velocity modulus U
    #    U=np.sqrt(S.Ux**2+S.Uy**2)
    fignum = 5
    for i in range(start, stop):
        Z0 = Z[:, :, i] / 1000
        print(i)

        #  print('<dU>_x,y = '+str(np.median(Z0)))
        #  print('<dU^2>_x,y = '+str(np.std(Z0)))
        graphes.color_plot(M.x, M.y, np.log10(Z0), fignum=fignum, vmin=vmin, vmax=vmax)
        if i == start:
            graphes.colorbar(fignum=fignum, label='V (m/s)')
        titre = ''
        graphes.legende('x (mm)', 'y (mm)', titre)

        if i == start:
            input()
        #       graphes.vfield_plot(S)

        Dir = os.path.dirname(M.Sdata.fileCine) + '/' + Dirname + '/'
        print(Dir)
        filename = Dir + 'V' + str(i)
        graphes.save_fig(fignum, filename, fileFormat='png')
Beispiel #10
0
def fit_core_size(x, y, Z, fignum=1, display=False):
    """
    Find the half width of a gaussian bump
    INPUT
    -----
    x : 2d np array 
        spatial coordinates (columns)
    y : 2d np array
        spatial coordinates (lines)
    Z : 2d np array
        data to be fitted (typically vorticity field )
    fignum : int
        figure number for the output. Default 1
    display : bool
    OUTPUT
    -----
    a : float
        parameter of the gaussian bump
    center : 2 elements np array
        center coordinates
    """
    ny, nx = Z.shape
    X, Y, data, center, factor = normalize(x, y, Z)
    R, theta = Smath.cart2pol(X, Y)

    a0 = 1
    fun = gaussian
    res = opt.minimize(distance_fit, a0, args=(fun, R, data))

    cond = ((center[0] > 5) and (center[0] < nx - 5) and (center[1] > 5)
            and (center[1] < ny - 5))
    if cond:
        a = np.sqrt(res.x)
    else:
        a = None

    if display:
        figs = {}
        graphes.graph(R, factor * data, fignum=3, label='ko')
        graphes.graph(R,
                      factor * gaussian(res.x, R),
                      label='r.',
                      fignum=fignum + 2)
        graphes.set_axis(0, 20, 0, factor * 1.1)
        figs.update(graphes.legende('r (mm)', 'Vorticity s^{-1})', ''))

        fig = graphes.set_fig(fignum + 3)
        graphes.plt.clf()
        fig, ax, c = graphes.color_plot(X, Y, factor * data, fignum=fignum + 3)
        fig.colorbar(c)
        #        graphes.colorbar()

        figs.update(
            graphes.legende('X (mm)',
                            'Y (mm)',
                            'Vorticity',
                            display=False,
                            cplot=True))
        return a, center, figs
    else:
        return a, center
Beispiel #11
0
def plot_lambda_Re_lambda_coarse(Mfluc,
                                 cutoff=10**(-3),
                                 vminRe=0,
                                 vmaxRe=800,
                                 vminLambda=0,
                                 vmaxLambda=10,
                                 nu=1.004,
                                 x0=None,
                                 y0=None,
                                 x1=None,
                                 y1=None,
                                 redo=False):

    if not hasattr(Mfluc, 'U2ave') or redo:
        print 'Mfluc does not have attribute Mfluc.U2ave. Calculate it.'
        Mfluc = compute_u2_duidxi(Mfluc, x0=x0, y0=y0, x1=x1, y1=y1)

    # Calculate Local Taylor microscale: lambdaT
    Mfluc.lambdaT_Local = np.sqrt(Mfluc.U2ave / Mfluc.dUidxi2ave)
    Mfluc.Re_lambdaT_Local = Mfluc.lambdaT_Local * np.sqrt(Mfluc.U2ave) / nu

    Mfluc.lambdaTx_Local = np.sqrt(Mfluc.Ux2ave / Mfluc.dUxdx2ave)
    Mfluc.Re_lambdaTx_Local = Mfluc.lambdaTx_Local * np.sqrt(Mfluc.Ux2ave) / nu

    Mfluc.lambdaTy_Local = np.sqrt(Mfluc.Uy2ave / Mfluc.dUydy2ave)
    Mfluc.Re_lambdaTy_Local = Mfluc.lambdaTy_Local * np.sqrt(Mfluc.Uy2ave) / nu

    # Mfluc.lambdaT_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    # Mfluc.lambdaTx_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    # Mfluc.lambdaTy_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    # Mfluc.Re_lambdaT_Local = np.zeros((Mfluc.x.shape[0], Mfluc.Ux.shape[1]))
    # Mfluc.Re_lambdaTx_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    # Mfluc.Re_lambdaTy_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    # for x in range(0, Mfluc.Ux.shape[0] - 1):
    #     for y in range(0, Mfluc.Ux.shape[1] - 1):
    #         if Mfluc.dUidxi2ave[x, y] < cutoff:
    #             Mfluc.lambdaT_Local[x, y] = 0
    #         else:
    #             Mfluc.lambdaT_Local[x, y] = np.sqrt(Mfluc.U2ave[x, y] / Mfluc.dUidxi2ave[x, y])
    #             Mfluc.Re_lambdaT_Local[x, y] = Mfluc.lambdaT_Local[x, y] * np.sqrt(Mfluc.U2ave[x, y]) / nu
    #         if Mfluc.dUxdx2ave[x, y] < cutoff:
    #             Mfluc.lambdaTx_Local[x, y] = 0
    #         else:
    #             Mfluc.lambdaTx_Local[x, y] = np.sqrt(Mfluc.Ux2ave[x, y] / Mfluc.dUxdx2ave[x, y])
    #             Mfluc.Re_lambdaTx_Local[x, y] = Mfluc.lambdaTx_Local[x, y] * np.sqrt(Mfluc.Ux2ave[x, y]) / nu
    #         if Mfluc.dUydy2ave[x, y] < cutoff:
    #             Mfluc.lambdaTy_Local[x, y] = 0
    #         else:
    #             Mfluc.lambdaTy_Local[x, y] = np.sqrt(Mfluc.Uy2ave[x, y] / Mfluc.dUydy2ave[x, y])
    #             Mfluc.Re_lambdaTy_Local[x, y] = Mfluc.lambdaTy_Local[x, y] * np.sqrt(Mfluc.Uy2ave[x, y]) / nu

    # Plot Taylor miroscale

    graphes.color_plot(Mfluc.x,
                       Mfluc.y,
                       Mfluc.Re_lambdaT_Local,
                       fignum=1,
                       vmin=vminRe,
                       vmax=vmaxRe)
    graphes.colorbar()
    plt.title('Local $Re_\lambda$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x,
                       Mfluc.y,
                       Mfluc.Re_lambdaTx_Local,
                       fignum=2,
                       vmin=vminRe,
                       vmax=vmaxRe)
    graphes.colorbar()
    plt.title('Local $Re_{\lambda,x}$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x,
                       Mfluc.y,
                       Mfluc.Re_lambdaTy_Local,
                       fignum=3,
                       vmin=vminRe,
                       vmax=vmaxRe)
    graphes.colorbar()
    plt.title('Local $Re_{\lambda,y}$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')

    graphes.color_plot(Mfluc.x,
                       Mfluc.y,
                       Mfluc.lambdaT_Local,
                       fignum=4,
                       vmin=vminLambda,
                       vmax=vmaxLambda)
    graphes.colorbar()
    plt.title('Local $\lambda$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x,
                       Mfluc.y,
                       Mfluc.lambdaTx_Local,
                       fignum=5,
                       vmin=vminLambda,
                       vmax=vmaxLambda)
    graphes.colorbar()
    plt.title('Local $\lambda_x$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x,
                       Mfluc.y,
                       Mfluc.lambdaTy_Local,
                       fignum=6,
                       vmin=vminLambda,
                       vmax=vmaxLambda)
    graphes.colorbar()
    plt.title('Local $\lambda_y$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
Beispiel #12
0
def plot_lambda_Re_lambda_heatmaps(Mfluc,
                                   cutoff=10**(-3),
                                   vminRe=0,
                                   vmaxRe=800,
                                   vminLambda=0,
                                   vmaxLambda=800,
                                   nu=1.004,
                                   x0=None,
                                   y0=None,
                                   x1=None,
                                   y1=None,
                                   redo=False):
    """
    Plots a heatmap of local Re_lambda and lambda
    Parameters
    ----------
    Mfluc
    cutoff
    vminRe
    vmaxRe
    vminLambda
    vmaxLambda
    nu

    Returns
    -------

    """
    if x0 is None:
        x0, y0 = 0, 0
        x1, y1 = Mfluc.Ux.shape[1], Mfluc.Ux.shape[0]
        print 'Will average from (%d, %d) to (%d, %d)  (index)' % (x0, y0, x1,
                                                                   y1)
    nrows, ncolumns = y1 - y0, x1 - x0

    Mfluc.lambdaT_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    Mfluc.lambdaTx_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    Mfluc.lambdaTy_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    Mfluc.Re_lambdaT_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    Mfluc.Re_lambdaTx_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))
    Mfluc.Re_lambdaTy_Local = np.zeros((Mfluc.Ux.shape[0], Mfluc.Ux.shape[1]))

    if not hasattr(Mfluc, 'U2ave') or redo:
        print 'Mfluc does not have attribute Mfluc.U2ave. Calculate it.'
        Mfluc = compute_u2_duidxi(Mfluc, x0=x0, y0=y0, x1=x1, y1=y1)
        print Mfluc.Ux2ave.shape

    # Calculate Local Taylor microscale: lambdaT
    for y in range(0, Mfluc.Ux.shape[0] - 1):
        for x in range(0, Mfluc.Ux.shape[1] - 1):
            if Mfluc.dUidxi2ave[y, x] < cutoff:
                Mfluc.lambdaT_Local[y, x] = 0
            else:
                Mfluc.lambdaT_Local[y, x] = np.sqrt(Mfluc.U2ave[y, x] /
                                                    Mfluc.dUidxi2ave[y, x])
                Mfluc.Re_lambdaT_Local[y, x] = Mfluc.lambdaT_Local[
                    y, x] * np.sqrt(Mfluc.U2ave[y, x]) / nu
            if Mfluc.dUxdx2ave[y, x] < cutoff:
                Mfluc.lambdaTx_Local[y, x] = 0
            else:
                Mfluc.lambdaTx_Local[y, x] = np.sqrt(Mfluc.Ux2ave[y, x] /
                                                     Mfluc.dUxdx2ave[y, x])
                Mfluc.Re_lambdaTx_Local[y, x] = Mfluc.lambdaTx_Local[
                    y, x] * np.sqrt(Mfluc.Ux2ave[y, x]) / nu
            if Mfluc.dUydy2ave[y, x] < cutoff:
                Mfluc.lambdaTy_Local[y, x] = 0
            else:
                Mfluc.lambdaTy_Local[y, x] = np.sqrt(Mfluc.Uy2ave[y, x] /
                                                     Mfluc.dUydy2ave[y, x])
                Mfluc.Re_lambdaTy_Local[y, x] = Mfluc.lambdaTy_Local[
                    y, x] * np.sqrt(Mfluc.Uy2ave[y, x]) / nu

    # Plot Taylor miroscale
    graphes.color_plot(Mfluc.x[y0:y1, x0:x1],
                       Mfluc.y[y0:y1, x0:x1],
                       Mfluc.Re_lambdaT_Local[y0:y1, x0:x1],
                       fignum=1,
                       vmin=vminRe,
                       vmax=vmaxRe)
    graphes.colorbar()
    plt.title('Local $Re_\lambda$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x[y0:y1, x0:x1],
                       Mfluc.y[y0:y1, x0:x1],
                       Mfluc.Re_lambdaTx_Local[y0:y1, x0:x1],
                       fignum=2,
                       vmin=vminRe,
                       vmax=vmaxRe)
    graphes.colorbar()
    plt.title('Local $Re_{\lambda,x}$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x[y0:y1, x0:x1],
                       Mfluc.y[y0:y1, x0:x1],
                       Mfluc.Re_lambdaTy_Local[y0:y1, x0:x1],
                       fignum=3,
                       vmin=vminRe,
                       vmax=vmaxRe)
    graphes.colorbar()
    plt.title('Local $Re_{\lambda,y}$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')

    graphes.color_plot(Mfluc.x[y0:y1, x0:x1],
                       Mfluc.y[y0:y1, x0:x1],
                       Mfluc.lambdaT_Local[y0:y1, x0:x1],
                       fignum=4,
                       vmin=vminLambda,
                       vmax=vmaxLambda)
    graphes.colorbar()
    plt.title('Local $\lambda$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x[y0:y1, x0:x1],
                       Mfluc.y[y0:y1, x0:x1],
                       Mfluc.lambdaTx_Local[y0:y1, x0:x1],
                       fignum=5,
                       vmin=vminLambda,
                       vmax=vmaxLambda)
    graphes.colorbar()
    plt.title('Local $\lambda_x$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
    graphes.color_plot(Mfluc.x[y0:y1, x0:x1],
                       Mfluc.y[y0:y1, x0:x1],
                       Mfluc.lambdaTy_Local[y0:y1, x0:x1],
                       fignum=6,
                       vmin=vminLambda,
                       vmax=vmaxLambda)
    graphes.colorbar()
    plt.title('Local $\lambda_y$')
    plt.xlabel('X (mm)')
    plt.ylabel('Y (mm)')
graphes.colorbar()

# Plot the enstrophy at a particular time (frame#)
graphes.Mplot(M, 'enstrophy', frame, vmin=0, vmax=90000)
graphes.colorbar()

########################################################
figs = {}
fields, names, vmin, vmax, labels, units = comp.std_fields()
# print(M.param.v)
indices = range(50, M.Ux.shape[2])
field = 'E'
j = 3  # index to put right units on the graph (j=3 (energy), j=4 (enstrophy))
print(fields)
E_moy = np.nanmean(getattr(M, field)[..., indices], axis=2)
graphes.color_plot(M.x, M.y, E_moy, fignum=j + 1, vmin=0, vmax=80000)
graphes.colorbar(label=names[j] + ' (' + units[j] + ')')
figs.update(
    graphes.legende('X (mm)', 'Y (mm)', 'Time averaged ' + field, cplot=True))

X, Y = [], []
for i in indices:
    X.append(
        track.positions(M, i, field='E', indices=indices, step=1,
                        sigma=10.)[1])
    Y.append(
        track.positions(M, i, field='E', indices=indices, step=1,
                        sigma=10.)[3])
X0, Y0 = np.nanmean(X), np.nanmean(Y)
# graphes.graph([X0],[Y0],label='ko',fignum=j+1)
graphes.save_figs(figs, savedir=savedir, suffix='smooth')