Esempio n. 1
0
def rhoplot(rho, axislabels=None, save=False):
    import matplotlib.pyplot as plt
    import matplotlib.colors as colors
    from mpl_toolkits.mplot3d import Axes3D

    # extract real and imaginary components of density matrix
    realrho = np.real(rho)
    imagrho = np.imag(rho)

    # instantiate new figure
    fig = plt.gcf()
    fig.canvas.set_window_title('Density Plot')
    #rax = Axes3D(fig)
    rax = fig.add_subplot(121, projection='3d')
    iax = fig.add_subplot(122, projection='3d')

    # set titles
    rax.title.set_text('Real$(\\rho)$')
    iax.title.set_text('Imag$(\\rho)$')
    # apply custom labelling
    if axislabels is not None:
        rax.set_xticklabels(axislabels)
        rax.set_yticklabels(axislabels)
        iax.set_xticklabels(axislabels)
        iax.set_yticklabels(axislabels)

    # dimension of space
    dim = np.shape(realrho)[0]
    # create indexing vectors
    x, y = np.meshgrid(range(0, dim), range(0, dim), indexing='ij')
    x = x.flatten('F')
    y = y.flatten('F')
    z = np.zeros_like(x)

    # create bar widths
    dx = 0.5*np.ones_like(z)
    dy = dx.copy()
    dzr = realrho.flatten()
    dzi = imagrho.flatten()

    # compute colour matrix for real matrix and set axes bounds
    norm = colors.Normalize(dzr.min(), dzr.max())
    rcolours = cm.BuGn(norm(dzr))
    rax.set_zlim3d([0, np.max(dzr)])
    iax.set_zlim3d([0, np.max(dzr)])

    inorm = colors.Normalize(dzi.min(), dzi.max())
    icolours = cm.jet(inorm(dzi))

    # plot image
    rax.bar3d(x, y, z, dx, dy, dzr, color=rcolours)
    iax.bar3d(x, y, z, dx, dy, dzi, color=icolours)
    #plt.ticklabel_format(style='sci', axis='z', scilimits=(0, 0))
    plt.show()
norm = mcolors.BoundaryNorm(clevs, cmap.N)
# In future MetPy
# norm, cmap = ctables.registry.get_with_boundaries('precipitation', clevs)

low = cm.GnBu_r(np.linspace(0, 0.75, 128))
mid = np.ones((30, 4))
high = cm.YlOrRd(np.linspace(0.0, 0.95, 128))
colors = np.vstack((low, mid, high))
bwr = LinearSegmentedColormap.from_list('my_colormap', colors)  #, N=24)
bwr.set_under = 'darkbrown'
bwr.set_over = 'magenta'
#bwr.set_bad = 'k'

low = cm.YlOrBr_r(np.linspace(0, 0.9, 128))
mid = np.ones((30, 4))
high = cm.BuGn(np.linspace(0, 0.95, 128))
colors = np.vstack((low, mid, high))
drywet = LinearSegmentedColormap.from_list('my_colormap', colors)  #, N=24)

#fwrf1 = "./outputs/wrf3roms1/1-1-2/wrfout_d01_2019-09-06_00:00:00"
#fwrf2 = "./outputs/wrf3roms1_adj_Qs/1-1-2/wrfout_d01_2019-09-06_00:00:00"

minLon, maxLon, minLat, maxLat = [119, 130, 27, 40]
hres = 0.1
lons = np.arange(minLon, maxLon + hres,
                 hres)  # analysis domain c    overing [118.5, 128, 26.5, 42.]
lats = np.arange(minLat, maxLat + hres, hres)

plevs = np.arange(950, 250, -50)  #[925, 900, 850, 700, 500, 300]
print(plevs)
Esempio n. 3
0
  of the mesh grid data, see raven/tests/framework/AnalyticModels/optimizing/plot_functions.py.
"""

import pickle as pk
import matplotlib.pyplot as plt
from matplotlib import colors
from matplotlib import cm
from mpl_toolkits.mplot3d import axes3d, Axes3D

from matplotlib import animation
import numpy as np

# load function data
bX,bY,bZ = pk.load(open('dvalley_plotdata.pk','rb'))
norm = plt.Normalize(bZ.min()-1, bZ.max()+5)
colors = cm.BuGn(norm(bZ))
rcount, ccount, _ = colors.shape
fig = plt.figure(figsize=(10,8))
ax = fig.gca(projection='3d')
ax.view_init(70, 0)


surf = ax.plot_surface(bX, bY, bZ, rcount=rcount, ccount=ccount,
                       facecolors=colors,alpha=0.3)
ax.set_xlabel('x')
ax.set_ylabel('y')

# load walk data
cases = range(5)
data = {}
for c,case in enumerate(cases):
Esempio n. 4
0
#rateVsSE = np.zeros(len(

plt.subplots_adjust(hspace=0.35, wspace=0.3, top=0.95, bottom=0.05)

pl.savefig("rate_effect_5trials_" + ref + ".pdf")
pl.savefig("rate_effect_5trials_" + ref + ".jpg")

#--------------------------------------------------- This plots the Supp Fig 4 -----------------------------------------------------------------

fig1 = pl.figure(2, figsize=(9, 16))
t1 = fig1.add_subplot(211)
for i, x in enumerate(big_gpe_fr_lis_mult):
    t1.plot(x[0],
            big_gpe_spec_lis_mult[i][0],
            '.',
            color=cm.BuGn(float(i + 1) / len(big_gpe_fr_lis_mult)),
            markersize=13,
            label="Trial " + str(i + 1))
    t1.plot(x,
            big_gpe_spec_lis_mult[i],
            '.',
            color=cm.BuGn(float(i + 1) / len(big_gpe_fr_lis_mult)),
            markersize=13)

t1.set_title("GPe", fontsize=25, fontweight='bold')
t1.set_ylabel("SE", fontsize=25, fontweight='bold')
t1.legend(prop={"size": 10, "weight": "bold"})
for x in t1.get_yticklabels():
    x.set_fontsize(15)
    x.set_fontweight('bold')
for x in t1.get_xticklabels():