def massflux_ss(init, end):
    """draw th in average"""
    ##### retrieve variables #####
    xx, zz = np.meshgrid(x, z)
    dt = netCDF4.Dataset(dy_files[0])
    t = int(np.array(dt['Time']))
    density = np.loadtxt('../density.txt')[:len(z)]
    dwdzss = np.zeros((end - init, len(z)))
    for tidx in range(init, end):
        td = netCDF4.Dataset(td_files[tidx])
        progressbar(now=tidx - init,
                    length=end - init,
                    text='theta in snap shot')

        dy = netCDF4.Dataset(dy_files[tidx])
        w = np.mean(dy['w'][0, :len(z)] * area, axis=(1, 2))
        dwdzss[tidx - init, :] = w * density

    figure()
    for tidx in range(init, end):
        plot(dwdzss[tidx - init, :],
             z,
             c=cm.jet_r((tidx - init) / (end - init)),
             label='%s' % tidx,
             alpha=0.5)
    plot(np.mean(dwdzss, axis=0), z, color='black', label='average')
    legend(fontsize=5)
    title(r'Convective Mass Flux $\rho w$')
    savefig('dwdzss_ct.jpg', dpi=300)
    clf()
Exemple #2
0
def buoyancy_draw(init, end):
    for t_idx in range(init, end):
        progressbar(now=t_idx - init, length=end - init, text='draw_buoyancy')
        td = netCDF4.Dataset(td_files[t_idx])

        time = int(np.array(td['Time']))

        ##### draw Buoyancy
        buo = buoyancy(data=td)
        contourf(y,
                 z,
                 buo[:len(z), :, x_prof],
                 vmin=0,
                 vmax=0.5,
                 cmap='jet',
                 levels=20)
        colorbar(extend='both')

        ##### draw cloud
        qc = np.array(td['qc'][0, :len(z), yslice, xslice])
        contour(y,
                z,
                qc[:len(z), :, x_prof] > 0,
                colors='grey',
                alpha=1,
                linewidths=1,
                levels=[1])
        #la = contour(x, z, buo[:len(z), y_prof, :], vmin=-0.01, vmax=0.01, levels=20)
        #clabel(la, inline=True)
        title('Time: %06d' % time)
        savefig('buoyancy%06d.jpg' % time, dpi=300)
        clf()
def average(init, end):
    total = end - init
    thmean = np.zeros((len(z), ))
    umean = np.zeros((len(z), ))
    wmean = np.zeros((len(z), ))
    buomean = np.zeros((len(z), ))
    for n in range(init, end):
        ##### retrieve variables #####
        td = netCDF4.Dataset(td_files[n])
        progressbar(now=n - init, length=total, text='Averaging theta')
        th = td['th'][0, :len(z)] * area
        th = np.where(th == 0., np.nan, th)
        th = np.nanmean(th, axis=(1, 2))
        thbar = np.mean(td['th'][0, :len(z), :, :], axis=(1, 2))
        thmean += (th - thbar) / total
        buomean += (th - thbar) / thbar / total
        #th = td['th'][0, :len(z)]
        #qv = td['qv'][0, :len(z)]
        #B = buoyancy(th=th, qv=qv) * area
        #B = np.where(B == 0., np.nan, B)
        #B = np.nanmean(B, axis=(1, 2))
        #buomean += B / total

        dy = netCDF4.Dataset(dy_files[n])
        w = np.mean(dy['w'][0, :len(z)] * area, axis=(1, 2))
        wmean += w / total
    return thmean, buomean, wmean
Exemple #4
0
def cloud_filter(t_idx, save=True):
	"""
	input: t_idx(int)
	return cloud(z, y, x)

	with the help of cloud_mask(),
	return buoyancy filtered by core
	"""

	td, dy = netCDF4.Dataset(td_files[t_idx]), netCDF4.Dataset(dy_files[t_idx])
	progressbar(now=t_idx-init, length=end-init, 
                    text='draw_core')
	t = int(np.array(td['Time']))
	# thermal dynamic variables
	th = td['th'][0, :, :, :]
	qv = td['qv'][0, :, :, :]
	qc = td['qc'][0, :, :, :]
	B = buoyancy(th=th, qv=qv)
	# dynamic variables
	w = dy['w'][0, :, :, :]
	# masked variable
	cloud = cloud_mask(var=B, qc=qc)
	if save:
		cloud.dump('./cloud/cloud%06d.npy'%t_idx)
	return cloud
Exemple #5
0
def buoyancy_draw(init, end):
    for t_idx in range(init, end):
        progressbar(now=t_idx, length=len(td_files), text='draw_buoyancy')
        td = netCDF4.Dataset(td_files[t_idx])
        th = td['th'][0, :, :, :]
        qv = td['qv'][0, :, :, :]
        buo = buoyancy(th=th, qv=qv)
        contourf(x,
                 z,
                 buo[:len(z), y_prof, :],
                 vmin=-0.01,
                 vmax=0.01,
                 cmap='coolwarm',
                 levels=20)
        colorbar()
        la = contour(x,
                     z,
                     buo[:len(z), y_prof, :],
                     vmin=-0.01,
                     vmax=0.01,
                     levels=20)
        clabel(la, inline=True)
        title('Time: %06d' % t_idx)
        savefig('buoyancy%06d.jpg' % t_idx, dpi=300)
        clf()
Exemple #6
0
def draw_snapshot(init, end):
    """draw in snap shot"""
    ##### retrieve variables #####
    xx, zz = np.meshgrid(x, z)
    dt = netCDF4.Dataset(td_files[0])
    t = int(np.array(dt['Time']))

    thss = np.zeros((end-init, len(z)))
    buoss = np.zeros((end-init, len(z)))
    wss = np.zeros((end-init, len(z)))
    dwdtss = np.zeros((end-init, len(z)))
    dwdzss = np.zeros((end-init, len(z)-1))
    for tidx in range(init, end):
        td = netCDF4.Dataset(td_files[tidx])
        progressbar(now=tidx-init, length=end-init, text='theta in snap shot')
        thbar = np.mean(td['th'][0, :len(z), :, :], axis=(1, 2))
        th = td['th'][0, :len(z)] * area
        th = np.where(th == 0., np.nan, th)
        th = np.nanmean(th, axis=(1, 2))
        thss[tidx-init, :] = th - thbar
        buoss[tidx-init, :] = (th - thbar) / thbar

        dy = netCDF4.Dataset(dy_files[tidx])
        w = np.mean(dy['w'][0, :len(z)] * area, axis=(1, 2))
        wss[tidx-init, :] = w
        
        if tidx - (end-1): # if not at last time snap
            nextw = netCDF4.Dataset(dy_files[tidx+1])['w']
            nextw = np.mean(nextw[0, :len(z)] * area, axis=(1, 2))
            dwdtss[tidx-init, :] = (nextw - w) / 60 # dw / dt
            dwdzss[tidx-init, :] = (w[1:] - w[:-1]) / (z[1] - z[0]) # ! note that this only fit in fixed interval of z
        
    # ============= draw th spatial mean ================
    #pcolormesh(np.arange(init, end), z, thss.transpose(), 
    #           shading='near', cmap='coolwarm', vmin=-1., vmax=1.)
    #colorbar()
    #xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    #title(r"$\theta '$ in spatial average")
    #savefig('thss.jpg', dpi=300)
    #clf()
    # ============= draw w spatial mean ================
    #pcolormesh(np.arange(init, end), z, wss.transpose(), 
    #           shading='near', cmap='coolwarm', vmin=-0.08, vmax=0.08)
    #colorbar()
    #xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    #title(r"W in spatial average")
    #savefig('wss.jpg', dpi=300)
    #clf()
    # ============= draw buoyancy spatial mean ================
    pcolormesh(np.arange(init, end), z, buoss.transpose(),
               shading='near', cmap='coolwarm', vmin=-0.004, vmax=0.004)
    colorbar()
    #contour(np.arange(init, end), z, wss.transpose(), colors='black', linewidths=0.5)
    contour(np.arange(init, end), z, dwdtss.transpose(), colors='black', linewidths=0.5)
    xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    title(r"Buoyancy [Shaded] & W [Contour] in spatial average")
    savefig('buoss.jpg', dpi=300)
    clf()
Exemple #7
0
def B_laplace(t_idx, save=True):
    td, dy = netCDF4.Dataset(td_files[t_idx]), netCDF4.Dataset(dy_files[t_idx])
    progressbar(t_idx, len(td_files), 'Buoyancy_laplacian')
    t = int(np.array(td['Time']))
    # thermal dynamic variables
    th = td['th'][0, :, :, :]
    qv = td['qv'][0, :, :, :]
    qc = td['qc'][0, :, :, :]
    B = buoyancy(th=th, qv=qv)
    L_buoyancy = h_laplace(var3d=B, dx=interval, dy=interval)
    if save:
        L_buoyancy.dump('./buoyancy/L_buoyancy%06d.npy' % t_idx)
    return L_buoyancy
Exemple #8
0
def draw_L_W(init, end):
    for t_idx in range(init, end):
        progressbar(t_idx, len(td_files), 'saving W laplacian')
        L_W = W_laplace(t_idx=t_idx, save=True)
        contourf(x, z, L_W[:len(z), y_prof, :] * 10**8, vmin=-100, vmax=100)
        cbar = colorbar()
        cbar.ax.set_ylabel(
            r'$\nabla ^2 \ \frac{dw}{dt}$ ($\times 10^{-8}$/$s^2 m$)',
            rotation=270)
        cbar.ax.yaxis.set_label_coords(5, 0.5)
        title('Time: %06d' % t_idx)
        xlabel('X Domain (m)')
        ylabel('Height (m)')
        savefig('LW%06d.jpg' % t_idx, dpi=300)
        clf()
Exemple #9
0
def draw_L_bW_Core(init, end):
    for t_idx in range(init, end):
        progressbar(t_idx, len(td_files),
                    'drawing buoyancy laplacian with core mask')
        td = netCDF4.Dataset(td_files[t_idx])
        dy = netCDF4.Dataset(dy_files[t_idx])
        w = dy['w'][0, :, :, :]
        qc = td['qc'][0, :, :, :]
        qv = td['qv'][0, :, :, :]
        th = td['th'][0, :, :, :]
        B = buoyancy(th=th, qv=qv)

        # Draw laplacian of buoyancy in core mask
        L_buoyancy = np.load('./buoyancy/L_buoyancy%06d.npy' % t_idx,
                             allow_pickle=True)
        core_L_b = core_mask(var=L_buoyancy, buoyancy=B, w=w, qc=qc)

        contourf(x, z, core_L_b[:len(z), y_prof, :] * 10**8, vmin=-10, vmax=10)
        cbar = colorbar()
        cbar.ax.set_ylabel(r'$\nabla ^2$ Buoyancy ($\times 10^{-8}$/$s^2 m$)',
                           rotation=270)
        cbar.ax.yaxis.set_label_coords(5, 0.5)
        title('Time: %06d' % t_idx)
        xlabel('X Domain (m)')
        ylabel('Height (m)')
        savefig('Core_LB%06d.jpg' % t_idx, dpi=300)
        clf()

        # Draw laplacian of W in core mask
        L_W = np.load('./W/L_W%06d.npy' % t_idx, allow_pickle=True)
        core_L_W = core_mask(var=L_W, buoyancy=B, w=w, qc=qc)

        contourf(x,
                 z,
                 core_L_W[:len(z), y_prof, :] * 10**8,
                 vmin=-100,
                 vmax=100)
        cbar = colorbar()
        cbar.ax.set_ylabel(
            r'$\nabla ^2 \ \frac{dw}{dt}$ ($\times 10^{-8}$/$s^2 m$)',
            rotation=270)
        cbar.ax.yaxis.set_label_coords(5, 0.5)
        title('Time: %06d' % t_idx)
        xlabel('X Domain (m)')
        ylabel('Height (m)')
        savefig('Core_LW%06d.jpg' % t_idx, dpi=300)
        clf()
Exemple #10
0
def W_laplace(t_idx, save=True):
    dt = 60  # Assert 1 min since we know
    if t_idx == 0 or t_idx + 1 == len(td_files):  # boundary
        sign = int(np.sign(len(td_files) / 2 - t_idx))
        idx1 = t_idx + sign
        idx2 = len(td_files) - t_idx - 1
        w1 = netCDF4.Dataset(dy_files[idx1])['w'][0, :, :, :]
        w2 = netCDF4.Dataset(dy_files[idx2])['w'][0, :, :, :]
        dwdt = sign * (w1 - w2) / (2 * dt)
    else:  # middle grid point
        w = netCDF4.Dataset(dy_files[t_idx - 1])['w'][0, :, :, :]
        w_after = netCDF4.Dataset(dy_files[t_idx + 1])['w'][0, :, :, :]
        dwdt = (w_after - w) / (2 * dt)
    dwdt = np.array(dwdt)
    progressbar(t_idx, len(td_files), 'W_laplacian')
    L_W = h_laplace(var3d=dwdt, dx=interval, dy=interval)
    if save:
        L_W.dump('./W/L_W%06d.npy' % t_idx)
    return L_W
Exemple #11
0
def draw_cloud(init, end):
	"""
	input: init(int), end(init)
	return: figure(.png)

	return time series figure containing 
	buoyancy average filtered by cloud 
	"""
	cloud_collect = np.zeros((len(z), end-init))
	for tidx in range(init, end):
		progressbar(now=tidx, length=end, text='cloud progress')
		cloud = np.load('./cloud/cloud%06d.npy'%tidx, allow_pickle=True) # (z, y, x)
		cloud_collect[:, tidx-init] = np.mean(cloud, axis=(1, 2))[:len(z)]
	contourf(np.arange(init, end), z, cloud_collect, vmin=-0.01, vmax=0.01, levels=50, cmap='coolwarm')
	colorbar()
	title('Cloud Buoyancy')
	xlabel('Time (min)')
	ylabel('Height (m)')
	savefig('Tcloud.png', dpi=300)
	clf()
def draw_thp(init, end):
    for n in range(init, end):
        ##### retrieve variables #####
        xx, zz = np.meshgrid(x, z)
        td = netCDF4.Dataset(td_files[n])
        #print(td_files[n])
        progressbar(now=n - init, length=end - init, text='draw theta')
        t = int(np.array(td['Time']))
        th = td['th'][0, :len(z), y_prof, xslice]
        thbar = np.mean(td['th'][0, :len(z), :, :], axis=(1, 2))
        thbar = np.tile(thbar, (len(x), 1)).transpose()

        qc = td['qc'][0, :len(z), y_prof, xslice]
        qr = td['qr'][0, :len(z), y_prof, xslice]
        dy = netCDF4.Dataset(dy_files[n])
        u, w = dy['u'][0, :len(z), y_prof, xslice], dy['w'][0, :len(z), y_prof,
                                                            xslice]
        ws = np.sqrt(u**2 + w**2)
        ##### draw th-thbar #####
        contourf(x, z, th - thbar, levels=50, vmin=-5, vmax=5, cmap='coolwarm')
        #print(np.max(th-thbar))
        colorbar(extend='both')
        ##### draw cloud and rain #####
        #contour(x, z, qc-1e-6, colors='grey')
        #contour(x, z, qr-1e-6, colors='blue')

        ##### wind blob #####
        interval = 3
        quiver(xx[::interval, ::interval],
               zz[::interval, ::interval], (u / ws)[::interval, ::interval],
               (w / ws)[::interval, ::interval],
               ws[::interval, ::interval],
               cmap='rainbow')
        ##### figure setting #####
        title('Thermal Bubble @ t = ' + str(t) + ' min')
        xlabel('X (m)')
        ylabel('Z (m)')
        savefig('th' + td_files[n][-9:-3] + '.jpg', dpi=300)
        clf()
def draw_vapor(init, end):
    n = 0
    for f in td_files[init:end]:
        #print(f)
        progressbar(now=n - init, length=end - init, text='draw vapor')
        n += 1
        ##### retrieve variables #####
        dt = netCDF4.Dataset(f)
        t = int(np.array(dt['Time']))
        qc = dt['qc'][0, :len(z), y_prof, xslice]
        #qv = dt['qv'][0, :len(z), y_prof, :]
        qr = dt['qr'][0, :len(z), y_prof, xslice]
        ##### draw qv #####
        #qv = np.ma.masked_array(qv, qv<1e-10)
        #contourf(x, z, qv, levels=50, vmin=0., vmax=0.02, cmap='Blues')
        #colorbar(extend='max')
        ##### draw qc #####
        colors = cm.Greys(
            np.hstack([np.array([0.] * 5),
                       np.linspace(0.5, 0.75, 95)]))
        cmap = LinearSegmentedColormap.from_list('name', colors)
        #cmap.set_bad('white')
        qc = np.ma.masked_array(qc, qc < 0.0)
        contourf(x, z, qc, cmap=cmap, vmin=0, vmax=0.001, levels=100)
        colorbar()
        ##### draw qr #####
        cmap = nclcmap('BrownBlue12')
        colors = cm.Blues(np.linspace(0.5, 1))
        cmap = LinearSegmentedColormap.from_list('name', colors)
        qr = np.ma.masked_array(qr, qr <= 1e-6)  #5e-6)
        contourf(x, z, qr, cmap=cmap, vmin=0., vmax=0.01, alpha=.5, levels=20)
        ##### figure setting #####
        title('Vapor Distribution @ t = ' + str(t) + ' min')
        xlabel('X (m)')
        ylabel('Z (m)')
        savefig('vapor' + f[-9:-3] + '.jpg', dpi=300)
        clf()
Exemple #14
0
def draw_thprof(init, end):
    for n in range(init, end):
        ##### retrieve variables #####
        xx, zz = np.meshgrid(x, z)
        td = netCDF4.Dataset(td_files[n])
        #print(td_files[n])
        progressbar(now=n, length=end-init, text='draw theta')
        t = int(np.array(td['Time']))
        th = td['th'][0, :len(z), y_prof, xslice]
        thbar = np.mean(td['th'][0, :len(z), :, :], axis=(1, 2))
        thbar = np.tile(thbar, (len(x), 1)).transpose()

        ##### dw / dt #####
        prevw = np.array(netCDF4.Dataset(dy_files[n-1 + (n == init)])['w'])
        nexw  = np.array(netCDF4.Dataset(dy_files[n+1 - (n == end-1)])['w'])
        dwdt = (nexw - prevw) / 60
        dwdt = dwdt[0, :len(z), y_prof, xslice]
        ##### draw th-thbar #####
        contourf(x, z, th-thbar, levels=50, vmin=-5, vmax=5, cmap='coolwarm')
        colorbar(extend='both')
        wt = contour(x, z, dwdt, colors='black', linewidths=.5)
        #clabel(wt, inline=True, fontsize=5)
        ##### draw wind #####
        u = np.array(netCDF4.Dataset(dy_files[n])['u'])[0, :len(z), y_prof, xslice]
        w = np.array(netCDF4.Dataset(dy_files[n])['w'])[0, :len(z), y_prof, xslice]
        ws = np.sqrt(u ** 2 + w ** 2)
        interval = 2
        quiver(xx[::interval, ::interval], zz[::interval, ::interval],
               (u/ws)[::interval, ::interval], (w/ws)[::interval, ::interval],
                ws[::interval, ::interval], cmap='rainbow')
        
        title(' t = '+ str(t) + r" min [Shade: $\theta '$, Contour: $\frac{\partial w}{\partial t}$]")
        xlabel('X (m)')
        ylabel('Z (m)')
        savefig('th_dwdt'+td_files[n][-9:-3]+'.jpg', dpi=300)
        clf()
Exemple #15
0
    dt = netCDF4.Dataset(td_files[0])  # take initial state
    z, y, x = np.array(dt['zc']), np.array(dt['yc']), np.array(dt['xc'])
    xargmin, xargmax = np.argmin(abs(x - x[0])), np.argmin(abs(x - x[-1]))
    yargmin, yargmax = np.argmin(abs(y - y[0])), np.argmin(abs(y - y[-1]))
    xslice, yslice = slice(xargmin, xargmax), slice(yargmin, yargmax)
    x = x[xargmin:xargmax]
    y = y[yargmin:yargmax]

    thbar = np.mean(dt['th'][0], axis=(1, 2))
    thbar = np.tile(thbar[:, np.newaxis, np.newaxis], (1, len(y), len(x)))

    init, end = 303, 350

    for tidx in range(init, end):
        progressbar(now=tidx - init,
                    length=end - init,
                    text='generating nc file')
        ##### buoyancy #####
        td = netCDF4.Dataset(td_files[tidx])
        buo = buoyancy(td)
        buo = buo[:-1]
        ##### dwdt #####
        dwdt = gen_dwdt(tidx)

        buo, dwdt = buo[np.newaxis, :], dwdt[np.newaxis]
        data = xa.Dataset(
            {
                'buoyancy': (('Time', 'zc', 'yc', 'xc'), buo),
                'dwdt': (('Time', 'zc', 'yc', 'xc'), dwdt)
            },
            coords={
Exemple #16
0
    td_loc = '/media/wk2/atmenu10246/VVM/DATA/' + exp_name + '/archive/'
    td_files, dy_files = [], []
    for td, dy in zip(
            glob.glob(td_loc + exp_name + '.L.Thermodynamic-??????.nc'),
            glob.glob(td_loc + exp_name + '.L.Dynamic-??????.nc')):
        td_files.append(td)
        dy_files.append(dy)
    print('Appended nc files: ' + str(len(td_files)))
    # ========================================

    ##### universal variables #####
    dt = netCDF4.Dataset(td_files[0])  # take initial state
    z, y, x = dt['zc'], dt['yc'], dt['xc']

    for tidx in range(len(td_files)):
        progressbar(now=tidx, length=len(td_files), text='generating nc file')
        ##### buoyancy #####
        qv = np.array(netCDF4.Dataset(td_files[tidx])['qv'])[0]
        th = np.array(netCDF4.Dataset(td_files[tidx])['th'])[0]
        buo = buoyancy(th, qv)

        ##### dwdt #####
        dwdt = gen_dwdt(tidx)

        buo, dwdt = buo[np.newaxis, :], dwdt[np.newaxis]
        data = xa.Dataset(
            {
                'buoyancy': (('Time', 'zc', 'yc', 'xc'), buo),
                'dwdt': (('Time', 'zc', 'yc', 'xc'), dwdt)
            },
            coords={
def draw_snapshot(init, end):
    """draw in snap shot"""
    ##### retrieve variables #####
    xx, zz = np.meshgrid(x, z)
    dt = netCDF4.Dataset(td_files[0])
    t = int(np.array(dt['Time']))

    thss = np.zeros((end-init, len(z)))
    buoss = np.zeros((end-init, len(z)))
    wss = np.zeros((end-init, len(z)))
    dwdtss = np.zeros((end-init, len(z)))
    for tidx in range(init, end):
        td = netCDF4.Dataset(td_files[tidx])
        progressbar(now=tidx-init, length=end-init, text='theta in snap shot')
        thbar = np.mean(td['th'][0, :len(z), :, :], axis=(1, 2))
        th = td['th'][0, :len(z)] * area
        th = np.where(th == 0., np.nan, th)
        th = np.nanmean(th, axis=(1, 2))
        thss[tidx-init, :] = th - thbar

        th = td['th'][0, :len(z)]
        qv = td['qv'][0, :len(z)]
        B = buoyancy(th=th, qv=qv) * area
        B = np.where(B == 0., np.nan, B)
        B = np.nanmean(B, axis=(1, 2))
        buoss[tidx-init, :] = B

        dy = netCDF4.Dataset(dy_files[tidx])
        w = np.mean(dy['w'][0, :len(z)] * area, axis=(1, 2))
        wss[tidx-init, :] = w
        
        if tidx - (end-1): # if not at last time snap
            nextw = netCDF4.Dataset(dy_files[tidx+1])['w']
            nextw = np.mean(nextw[0, :len(z)] * area, axis=(1, 2))
            dwdtss[tidx-init, :] = (nextw - w) / 60 # dw / dt
        
    # ============= draw th spatial mean ================
    pcolormesh(np.arange(init, end), z, thss.transpose(), 
               shading='near', cmap='coolwarm', vmin=-1., vmax=1.)
    colorbar()
    xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    title(r"$\theta '$ in spatial average")
    savefig('thss.jpg', dpi=300)
    clf()
    # ============= draw w spatial mean ================
    pcolormesh(np.arange(init, end), z, wss.transpose(), 
               shading='near', cmap='coolwarm', vmin=-0.08, vmax=0.08)
    colorbar()
    xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    title(r"W in spatial average")
    savefig('wss.jpg', dpi=300)
    clf()
    # ============= draw buoyancy spatial mean ================
    pcolormesh(np.arange(init, end), z, buoss.transpose(),
               shading='near', cmap='coolwarm', vmin=-0.004, vmax=0.004)
    colorbar()
    contour(np.arange(init, end), z, wss.transpose(), cmap='viridis', linewidths=0.5)
    xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    title(r"Buoyancy in spatial average")
    savefig('buoss.jpg', dpi=300)
    clf()
    # ============= draw dw/dt spatial mean ============
    pcolormesh(np.arange(init, end), z, dwdtss.transpose(),
               shading='near', cmap='coolwarm', vmin=-0.0004, vmax=0.0004)
    colorbar()
    xlabel('Time (min)', fontsize=12); ylabel('Height (m)', fontsize=12)
    title(r"$\frac{\partial w}{\partial t}$ in spatial average")
    savefig('dwdtss.jpg', dpi=300)
    clf()