Exemplo n.º 1
0
UK2_vmp = sp.io.loadmat('/noc/users/jc3e13/storage/DIMES/combined_jc054.mat',
                        variable_names=['vmp'])['vmp']
vmp_lon = UK2_vmp['startlon'][0][0][0]
vmp_lat = UK2_vmp['startlat'][0][0][0]
m.plot(*m(vmp_lon[24:29], vmp_lat[24:29]),
       marker='*',
       color='yellow',
       linestyle='none',
       label='VMP',
       markersize=10)

plt.legend(loc=4)

pf.my_savefig(fig,
              'both',
              'traj',
              sdir,
              ftype=('pdf', 'png'),
              fsize='double_col')

# %% Float quivers RIDGE ONLY
# ------------------

# Number of half profiles.
N = 30
N0_76 = 15
N0_77 = 10
hpids = np.empty((N, 2))
hpids[:, 0] = np.arange(N0_76, N0_76 + N)
hpids[:, 1] = np.arange(N0_77, N0_77 + N)

lons = np.empty_like(hpids)
# %% Post-load.

X = np.hstack((M1.trace('X')[:], M2.trace('X')[:], M3.trace('X')[:], M4.trace('X')))
Y = np.hstack((M1.trace('Y')[:], M2.trace('Y')[:], M3.trace('Y')[:], M4.trace('Y')))
Z = np.hstack((M1.trace('Z')[:], M2.trace('Z')[:], M3.trace('Z')[:], M4.trace('Z')))
phi_0 = np.hstack((M1.trace('phi_0')[:], M2.trace('phi_0')[:],
                   M3.trace('phi_0')[:], M4.trace('phi_0')))

corner.corner(np.transpose(np.asarray([X, Y, Z, phi_0])),
                labels=['$\lambda_x$ (m)', '$\lambda_y$ (m)',
                        '$\lambda_z$ (m)', '$\phi_0$ (m$^2$ s$^{-2}$)'])

fig = plt.gcf()
fig.set_size_inches(6.5, 6.5)
pf.my_savefig(fig, 'both', 'fit_histograms', sdir, ftype='pdf',
              fsize='double_col')

# %%

Ms = [M2, M3]

fig = plt.figure(figsize=(6.5, 3))

gs = gridspec.GridSpec(1, 5, width_ratios=[3, 1, 1, 1, 1])
gs.update(wspace=0.9)
axs = [plt.subplot(gs[0]), plt.subplot(gs[1]), plt.subplot(gs[2]),
       plt.subplot(gs[3]), plt.subplot(gs[4])]
#for ax in axs[1:]:
#    ax.yaxis.tick_right()
#    ax.yaxis.set_ticks_position('both')
#    ax.yaxis.set_label_position('right')
                     color='grey',
                     linestyle='-',
                     label='Near')
gaus = n.max() * np.exp(-bins**2 / (2 * np.var(w_combined)))
ax.plot(bins, gaus, color='grey', label='Gaus')

ax.set_xlabel('$w$ (cm s$^{-1}$)')
ax.set_xlim(np.min(bins), np.max(bins))
#ax.annotate(r"Mean = {:1.2f} $\pm$ {:1.1f} cm s$^{{-1}}$".format(meanw, stdw),
#            (-7., 0.5))

ax.set_ylabel('Probability density')
ax.legend(loc=2)
pf.my_savefig(fig,
              'both',
              'w_hist',
              sdir,
              ftype=('png', 'pdf'),
              fsize='single_col')

# %% Ws Wf W time series ######################################################
hpids = np.arange(51, 59)
pfls = E76.get_profiles(hpids)

fig, ax = plt.subplots(1, 1, figsize=(6, 3))

for i, pfl in enumerate(pfls):

    t = utils.datenum_to_datetime(pfl.UTC)
    wf = pfl.Wz
    ws = pfl.Ws
    ww = pfl.Ww
Exemplo n.º 4
0
C = fig.colorbar(sc, cax=cbar_ax, extend='both')
C.set_label(r'$\log_{10}(\epsilon)$ (W kg$^{-1}$)')

#    plt.clim(-11., -7.)
ax0.set_xlim(np.min(X), np.max(X))

ax0.set_xlabel('Distance from ridge top (km)')
ax0.set_ylabel('$z$ (km)')

ax1.set_xlim(*ax0.get_xlim())

fontdict={'size': 10}
plt.figtext(-0.05, 0.85, 'a)', fontdict=fontdict)
plt.figtext(-0.05, 0.65, 'b)', fontdict=fontdict)

pf.my_savefig(fig, 'both', 'epsilon_lem', sdir, ftype=('png', 'pdf'),
              fsize='single_col')


# %% Using Thorpe scales

def bin_weighted_average(x, y, bins):
    Nbins = len(bins)
    out = np.zeros(Nbins-1)
    bidxs = np.digitize(x, bins)
    for i in xrange(Nbins-1):
        inbin = bidxs == i
        out[i] = trapz(y[inbin], x[inbin])/(bins[i+1] - bins[i])
    return out

hpids = np.arange(10, 52, 2)
dbin = 200.
    for i in xrange(4):
        axs[i].set_xlabel('$x$ (m)')
        axs[i].set_ylim(X.z_0, 0)
        axs[i].set_xlim(np.min(xg), np.max(xg))

        axs[i].plot(r[:idx, 0], r[:idx, 2], 'k--', linewidth=3)
        axs[i].plot(r[idx, 0], r[idx, 2], 'yo', linewidth=3)
        plt.setp(axs[i].xaxis.get_majorticklabels(), rotation=60)


    C[0].set_clim(-1e2*(X.u_0+U), 1e2*(X.u_0+U))
    C[1].set_clim(-1e2*X.v_0, 1e2*X.v_0)
    C[2].set_clim(-1e2*X.w_0, 1e2*X.w_0)
    C[3].set_clim(-1e4*X.b_0, 1e4*X.b_0)

    pf.my_savefig(fig, 'model_contour', 't{:1.0f}'.format(j), sdir,
                  fsize='double_col')
    plt.close()


# %%
# Model fitting using EM-APEX positions

def u_model(params, pfl, zlim, deg):

    phi_0, X, Z, phase_0 = params
    zmin, zmax = zlim
    nope = np.isnan(pfl.zef) | (pfl.zef < zmin) | (pfl.zef > zmax)

    t = 60*60*24*(pfl.UTCef - np.nanmin(pfl.UTCef))
    x = 1000.*(pfl.dist_ef - np.nanmin(pfl.dist_ef))
    k = 2*np.pi/X
Exemplo n.º 6
0
            alpha=0.8,
            label='4977')
axs[2].hist(np.log10(epsilon_77[~(flag_77 | ~use_77)]),
            bins=bins,
            color='green',
            alpha=0.8,
            label='4977 above noise')
axs[2].set_xlabel('$\log_{10}(\epsilon)$ W kg$^{-1}$')

axs[1].text(-7, 0.6, r'c = {:1.3f}'.format(c_76))
axs[2].text(-7, 0.6, r'c = {:1.3f}'.format(c_77))

for ax in axs:
    ax.legend()

pf.my_savefig(fig3, 'eheight', 'lem_hist', sdir, ftype='png')

# %% Time

xvar = 'time'
dx = 5.
hpids = np.arange(50, 150)
width = 120.
lc = np.array([300, 120])
c = 1.
btype = 'bandpass'
we = 0.001

t = np.arange(0., 11000., dx)
__, __, z_76 = E76.get_interp_grid(hpids, t, 'dUTC', 'z')
__, __, z_77 = E77.get_interp_grid(hpids, t, 'dUTC', 'z')
Exemplo n.º 7
0
                     np.mean(M.trace('X')[:]), np.std(M.trace('X')[:]),
                     np.mean(M.trace('Y')[:]), np.std(M.trace('Y')[:]),
                     np.mean(M.trace('Z')[:]), np.std(M.trace('Z')[:]),
                     np.mean(M.trace('phi_0')[:]), np.std(M.trace('phi_0')[:]),
                     np.mean(Efluxz), np.std(Efluxz),
                     np.mean(Mfluxz), np.std(Mfluxz)
                 ))

triangle.corner(np.transpose(np.asarray([M.trace('X')[:],
                                         M.trace('Y')[:],
                                         M.trace('Z')[:],
                                         M.trace('phi_0')[:]])),
                labels=['$\lambda_x$ (m)', '$\lambda_y$ (m)',
                        '$\lambda_z$ (m)', '$\phi_0$ (m$^2$ s$^{-2}$)'])
fig = plt.gcf()
pf.my_savefig(fig, save_string, 'MCMC_triangle', sdir, ftype='png',
              fsize='double_col')
plt.close()

# Plot fit comparison.
fig, axs = plt.subplots(1, 5, sharey=True, figsize=(6.5, 3))
axs[0].plot(100.*U, z, color='black')
axs[0].set_xlabel('$u$ (cm s$^{-1}$)')
axs[0].set_ylabel('$z$ (m)')
axs[1].plot(100.*V, z, color='black')
axs[1].set_xlabel('$v$ (cm s$^{-1}$)')
axs[2].plot(100.*W, z, color='black')
axs[2].set_xlabel('$w$ (cm s$^{-1}$)')
axs[3].plot(10000.*B, z, color='black')
axs[3].set_xlabel('$b$ ($10^{-4}$ m s$^{-2}$)')
axs[4].plot(100.*PP, z, color='black')
axs[4].set_xlabel('$\phi$ ($10^{-2}$ m$^2$ s$^{-2}$)')
axs[2].hist(X_dist[:,2], bins=np.arange(-300, 300, 10),
            normed=True, log=False, alpha=0.4, label='4977');

axs[2].legend()

for ax in axs:
    plt.setp(ax.xaxis.get_majorticklabels(), rotation=60)
    ax.set_yticks([])
    ax.grid()

axs[0].set_ylabel('Occurances (-)')
axs[0].set_xlabel('$\lambda_x$ (m)')
axs[1].set_xlabel('$\lambda_z$ (m)')
axs[2].set_xlabel('$T$ (min)')

pf.my_savefig(fig, 'both_matrix_inversion', 'hist', sdir, fsize='double_col')

print(X)
print("Horizontal wavelength: {:1.0f} m\nVertical wavelength: {:1.0f} m\n"
      "Period: {:1.0f} min".format(np.pi*2/X[0], np.pi*2/X[1],
                                   np.pi*2/X[2]/60.))
print(X_mean)
print(X_std)
print(np.percentile(X_dist, [5, 25, 50, 75, 95], axis=0))
# %%

# These are the measured amplitudes after detrending a 2nd order polynomial.
# Always bottom up.

#                    u,    v,    w, b
amps_31 = np.array([[0.17, 0.11, 0.17, 4e-4],