def plot_x_y_yhat(x, y, y_hat, xsz, ysz, binz=False):
"""Plot x, y and y_hat side by side."""
plt.close("all")
f = plt.figure(figsize=(15, 10.8), dpi=300)
gs = gridspec.GridSpec(1, 3)
if binz:
y_hat = (y_hat > 0.5) * 1.
ims = [x, y, y_hat]
tils = [
"x:" + str(xsz) + "x" + str(xsz),
"y:" + str(ysz) + "x" + str(ysz),
"yhat:" + str(ysz) + "x" + str(ysz)]
for n, ti in zip([0, 1, 2], tils):
f.add_subplot(gs[n])
if n == 0:
plt.imshow(ims[n], cmap=cm.Greys_r)
else:
plt.imshow(ims[n], cmap=cm.Greys_r)
plt.title(ti)
return f
python类imshow()的实例源码
def plot_x_x_yhat(x, x_hat):
"""Plot x, y and y_hat side by side."""
plt.close("all")
f = plt.figure() # figsize=(15, 10.8), dpi=300
gs = gridspec.GridSpec(1, 2)
ims = [x, x_hat]
tils = [
"xin:" + str(x.shape[0]) + "x" + str(x.shape[1]),
"xout:" + str(x.shape[1]) + "x" + str(x_hat.shape[1])]
for n, ti in zip([0, 1], tils):
f.add_subplot(gs[n])
plt.imshow(ims[n], cmap=cm.Greys_r)
plt.title(ti)
ax = f.gca()
ax.set_axis_off()
return f
def show_mpl(self, im, enhance=True, clear_fig=True):
if self._pylab is None:
import pylab
self._pylab = pylab
if self._render_figure is None:
self._render_figure = self._pylab.figure(1)
if clear_fig: self._render_figure.clf()
if enhance:
nz = im[im > 0.0]
nim = im / (nz.mean() + 6.0 * np.std(nz))
nim[nim > 1.0] = 1.0
nim[nim < 0.0] = 0.0
del nz
else:
nim = im
ax = self._pylab.imshow(nim[:,:,:3]/nim[:,:,:3].max(), origin='upper')
return ax
def plot_allsky_healpix(image, nside, fn, label = "", rotation = None,
take_log = True, resolution=512, cmin=None, cmax=None):
import matplotlib.figure
import matplotlib.backends.backend_agg
if rotation is None: rotation = np.eye(3).astype("float64")
img, count = pixelize_healpix(nside, image, resolution, resolution, rotation)
fig = matplotlib.figure.Figure((10, 5))
ax = fig.add_subplot(1,1,1,projection='aitoff')
if take_log: func = np.log10
else: func = lambda a: a
implot = ax.imshow(func(img), extent=(-np.pi,np.pi,-np.pi/2,np.pi/2),
clip_on=False, aspect=0.5, vmin=cmin, vmax=cmax)
cb = fig.colorbar(implot, orientation='horizontal')
cb.set_label(label)
ax.xaxis.set_ticks(())
ax.yaxis.set_ticks(())
canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
canvas.print_figure(fn)
return img, count
def plot_2d(dataset, nbins, data, extra=None):
with sns.axes_style('white'):
plt.rc('font', weight='bold')
plt.rc('grid', lw=2)
plt.rc('lines', lw=2)
rows, cols = nbins
im = np.zeros(nbins)
for i in xrange(rows):
for j in xrange(cols):
im[i,j] = ((data[:,0] == i) & (data[:,1] == j)).sum()
plt.imshow(im, cmap='gray_r', interpolation='none')
if extra is not None:
dataset += extra
plt.savefig('plots/marginals-{0}.pdf'.format(dataset.replace('_','-')), bbox_inches='tight')
plt.clf()
plt.close()
def plot_2d(dataset, nbins, data=None, extra=None):
if data is None:
data = np.loadtxt('experiments/uci/data/splits/{0}_all.csv'.format(dataset), skiprows=1, delimiter=',')[:,-2:]
with sns.axes_style('white'):
plt.rc('font', weight='bold')
plt.rc('grid', lw=2)
plt.rc('lines', lw=2)
rows, cols = nbins
im = np.zeros(nbins)
for i in xrange(rows):
for j in xrange(cols):
im[i,j] = ((data[:,0] == i) & (data[:,1] == j)).sum()
plt.imshow(im, cmap='gray_r', interpolation='none')
if extra is not None:
dataset += extra
plt.savefig('plots/marginals-{0}.pdf'.format(dataset.replace('_','-')), bbox_inches='tight')
plt.clf()
plt.close()
def show_samples(y, ndim, nb=10, cmap=''):
if ndim == 4:
for i in range(nb**2):
plt.subplot(nb, nb, i+1)
plt.imshow(y[i], cmap=cmap, interpolation='none')
plt.axis('off')
else:
x = y[0]
y = y[1]
plt.figure(0)
for i in range(10):
plt.subplot(2, 5, i+1)
plt.imshow(x[i], cmap=cmap, interpolation='none')
plt.axis('off')
plt.figure(1)
for i in range(10):
plt.subplot(2, 5, i+1)
plt.imshow(y[i], cmap=cmap, interpolation='none')
plt.axis('off')
plt.show()
def plot_x_y_yhat(x, y, y_hat, xsz, ysz, binz=False):
"""Plot x, y and y_hat side by side."""
plt.close("all")
f = plt.figure(figsize=(15, 10.8), dpi=300)
gs = gridspec.GridSpec(1, 3)
if binz:
y_hat = (y_hat > 0.5) * 1.
ims = [x, y, y_hat]
tils = [
"x:" + str(xsz) + "x" + str(xsz),
"y:" + str(ysz) + "x" + str(ysz),
"yhat:" + str(ysz) + "x" + str(ysz)]
for n, ti in zip([0, 1, 2], tils):
f.add_subplot(gs[n])
if n == 0:
plt.imshow(ims[n], cmap=cm.Greys_r)
else:
plt.imshow(ims[n], cmap=cm.Greys_r)
plt.title(ti)
return f
def visualize_input(model):
sess = tf.Session()
sess.run(tf.global_variables_initializer())
tf.train.start_queue_runners(sess=sess)
batch_img, batch_cap = sess.run([model.images, model.input_seqs])
# show first img
batch_img = batch_img[0,:]
batch_img = (batch_img + 1.) / 2.
# show caption
fid = open('/media/DATA/MS-COCO/word_counts.txt')
raw_words = fid.readlines()
words = []
for raw_word in raw_words:
word, _ = raw_word.split()
words.append(word)
batch_cap = batch_cap[0]
sentence = []
for tmp_id in batch_cap:
sentence.append(words[int(tmp_id)])
print(sentence)
plt.imshow(batch_img)
plt.show()
def gen_aperture(imgsize,ypos,xpos,radius,pixval=1,showaperture=False,verbose=True):
"""
Generating an aperture image
--- INPUT ---
imgsize The dimensions of the array to return. Expects [y-size,x-size].
The aperture will be positioned in the center of a (+/-x-size/2., +/-y-size/2) sized array
ypos Pixel position in the y direction
xpos Pixel position in the x direction
radius Radius of aperture in pixels
showaperture Display image of generated aperture
verbose Toggle verbosity
--- EXAMPLE OF USE ---
import tdose_utilities as tu
apertureimg = tu.gen_aperture([20,40],10,5,10,showaperture=True)
apertureimg = tu.gen_aperture([2000,4000],900,1700,150,showaperture=True)
"""
if verbose: print ' - Generating aperture in image (2D array)'
y , x = np.ogrid[-ypos:imgsize[0]-ypos, -xpos:imgsize[1]-xpos]
mask = x*x + y*y <= radius**2.
aperture = np.zeros(imgsize)
if verbose: print ' - Assigning pixel value '+str(pixval)+' to aperture'
aperture[mask] = pixval
if showaperture:
if verbose: print ' - Displaying resulting image of aperture'
plt.imshow(aperture,interpolation='none')
plt.title('Generated aperture')
plt.show()
return aperture
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
def gen_overview_plot_image(ax,imagefile,imgext=0,cubelayer=1,title='Img Title?',fontsize=6,lthick=2,alpha=0.5,
cmap='coolwarm'):
"""
Plotting commands for image (cube layer) overview plotting
--- INPUT ---
cubelayer If the content of the file is a cube, provide the cube layer to plot. If
cubelayer = 'fmax' the layer with most flux is plotted
"""
ax.set_title(title,fontsize=fontsize)
if os.path.isfile(imagefile):
imgdata = pyfits.open(imagefile)[imgext].data
if len(imgdata.shape) == 3: # it is a cube
imgdata = imgdata[cubelayer,:,:]
ax.imshow(imgdata, interpolation='None',cmap=cmap,aspect='equal', origin='lower')
ax.set_xlabel('x-pixel')
ax.set_ylabel('y-pixel ')
ax.set_xticks([])
ax.set_yticks([])
else:
textstr = 'No image\nfound'
ax.text(1.0,22,textstr,horizontalalignment='center',verticalalignment='center',fontsize=fontsize)
ax.set_ylim([28,16])
ax.plot([0.0,2.0],[28,16],'r--',lw=lthick)
ax.plot([2.0,0.0],[28,16],'r--',lw=lthick)
ax.set_xlabel(' ')
ax.set_ylabel(' ')
ax.set_xticks([])
ax.set_yticks([])
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
def residual_multigauss(param, dataimage, nonfinite = 0.0, ravelresidual=True, showimages=False, verbose=False):
"""
Calculating the residual bestween the multigaussian model with the paramters 'param' and the data.
--- INPUT ---
param Parameters of multi-gaussian model to generate. See modelimage_multigauss() header for details
dataimage Data image to take residual
nonfinite Value to replace non-finite entries in residual with
ravelresidual To np.ravel() the residual image set this to True. Needed by scipy.optimize.leastsq()
optimizer function
showimages To show model and residiual images set to True
verbose Toggle verbosity
--- EXAMPLE OF USE ---
import tdose_model_FoV as tmf
param = [18,31,1*0.3,2.1*0.3,1.2*0.3,30*0.3, 110,90,200*0.5,20.1*0.5,15.2*0.5,0*0.5]
dataimg = pyfits.open('/Users/kschmidt/work/TDOSE/mock_cube_sourcecat161213_tdose_mock_cube.fits')[0].data[0,:,:]
residual = tmf.residual_multigauss(param, dataimg, showimages=True)
"""
if verbose: ' - Estimating residual (= model - data) between model and data image'
imgsize = dataimage.shape
xgrid, ygrid = tu.gen_gridcomponents(imgsize)
modelimg = tmf.modelimage_multigauss((xgrid, ygrid),param,imgsize,showmodelimg=showimages, verbose=verbose)
residualimg = modelimg - dataimage
if showimages:
plt.imshow(residualimg,interpolation='none', vmin=1e-5, vmax=np.max(residualimg), norm=mpl.colors.LogNorm())
plt.title('Resdiaul (= model - data) image')
plt.show()
if nonfinite is not None:
residualimg[~np.isfinite(residualimg)] = 0.0
if ravelresidual:
residualimg = np.ravel(residualimg)
return residualimg
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
def imageSegmentor(imageFilePath, matFilePath):
mat = readMatFile(matFilePath); # read mat file
image = getImage(imageFilePath); # input the image
typeOfFruit = getTypeOfFruit(image); # on basis of counting or temperature value there are 2 types of fruit
plt.imshow(image);
_fft = getFFT(image);
_mag = getMag(_fft);
_ang = getAngleInDegrees(_fft);
edges = edgeDetector(image); # detects the edges of the image
_segmentation = segmentation(image, typeOfFruit); # segments different parts of image
filteredImage = filterImageFromSegmentation(image, _segmentation); # filter the object part of image
outputMatrix = imageMapping(filteredImage, mat['IR']); # map the value part of the image and else 0
prefix = re.split('IR_|.pgm', imageFilePath)[0];
postfix = re.split('IR_|.pgm', imageFilePath)[1];
nameOfFile = prefix + "csv_"
nameOfFile = nameOfFile + postfix;
print(nameOfFile);
writeToCSV(outputMatrix, nameOfFile); # write it to the CSV file
writeFF2CSV(outputMatrix, _mag, _ang, nameOfFile);
fig, ((fig1, fig2), (fig3, fig4)) = plt.subplots(2, 2, figsize = (10, 8)); # subplot the different plots
fig1.imshow(image, cmap = plt.cm.gray); # colormap used here is gray
fig2.imshow(image, cmap = plt.cm.gray);
fig3.imshow(edges, cmap = plt.cm.gray);
fig4.imshow(filteredImage, cmap = plt.cm.gray);
return
# header file
draw.py 文件源码
项目:uai2017_learning_to_acquire_information
作者: evanthebouncy
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def draw(m, name, extra=None):
FIG.clf()
matrix = m
orig_shape = np.shape(matrix)
# lose the channel shape in the end of orig_shape
new_shape = orig_shape[:-1]
matrix = np.reshape(matrix, new_shape)
ax = FIG.add_subplot(1,1,1)
ax.set_aspect('equal')
plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.gray)
# plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.ocean)
plt.colorbar()
if extra != None:
greens, reds = extra
grn_x, grn_y, = greens
red_x, red_y = reds
plt.scatter(x=grn_x, y=grn_y, c='g', s=40)
plt.scatter(x=red_x, y=red_y, c='r', s=40)
# # put a blue dot at (10, 20)
# plt.scatter([10], [20])
# # put a red dot, size 40, at 2 locations:
# plt.scatter(x=[3, 4], y=[5, 6], c='r', s=40)
# # plt.plot()
plt.savefig(name)
draw.py 文件源码
项目:uai2017_learning_to_acquire_information
作者: evanthebouncy
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def draw(m, name, extra=None):
FIG.clf()
matrix = m
orig_shape = np.shape(matrix)
# lose the channel shape in the end of orig_shape
new_shape = orig_shape[:-1]
matrix = np.reshape(matrix, new_shape)
ax = FIG.add_subplot(1,1,1)
ax.set_aspect('equal')
plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.gray)
# plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.ocean)
plt.colorbar()
if extra != None:
greens, reds = extra
grn_x, grn_y, = greens
red_x, red_y = reds
plt.scatter(x=grn_x, y=grn_y, c='g', s=40)
plt.scatter(x=red_x, y=red_y, c='r', s=40)
# # put a blue dot at (10, 20)
# plt.scatter([10], [20])
# # put a red dot, size 40, at 2 locations:
# plt.scatter(x=[3, 4], y=[5, 6], c='r', s=40)
# # plt.plot()
plt.savefig(name)
draw.py 文件源码
项目:uai2017_learning_to_acquire_information
作者: evanthebouncy
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def draw(m, name, extra=None):
FIG.clf()
matrix = m
orig_shape = np.shape(matrix)
# lose the channel shape in the end of orig_shape
new_shape = orig_shape[:-1]
matrix = np.reshape(matrix, new_shape)
ax = FIG.add_subplot(1,1,1)
ax.set_aspect('equal')
plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.gray)
# plt.imshow(matrix, interpolation='nearest', cmap=plt.cm.ocean)
plt.colorbar()
if extra != None:
greens, reds = extra
grn_x, grn_y, = greens
red_x, red_y = reds
plt.scatter(x=grn_x, y=grn_y, c='g', s=40)
plt.scatter(x=red_x, y=red_y, c='r', s=40)
# # put a blue dot at (10, 20)
# plt.scatter([10], [20])
# # put a red dot, size 40, at 2 locations:
# plt.scatter(x=[3, 4], y=[5, 6], c='r', s=40)
# # plt.plot()
plt.savefig(name)
def plot1D_mat(a, b, M, title=''):
""" Plot matrix M with the source and target 1D distribution
Creates a subplot with the source distribution a on the left and
target distribution b on the tot. The matrix M is shown in between.
Parameters
----------
a : np.array, shape (na,)
Source distribution
b : np.array, shape (nb,)
Target distribution
M : np.array, shape (na,nb)
Matrix to plot
"""
na, nb = M.shape
gs = gridspec.GridSpec(3, 3)
xa = np.arange(na)
xb = np.arange(nb)
ax1 = pl.subplot(gs[0, 1:])
pl.plot(xb, b, 'r', label='Target distribution')
pl.yticks(())
pl.title(title)
ax2 = pl.subplot(gs[1:, 0])
pl.plot(a, xa, 'b', label='Source distribution')
pl.gca().invert_xaxis()
pl.gca().invert_yaxis()
pl.xticks(())
pl.subplot(gs[1:, 1:], sharex=ax1, sharey=ax2)
pl.imshow(M, interpolation='nearest')
pl.axis('off')
pl.xlim((0, nb))
pl.tight_layout()
pl.subplots_adjust(wspace=0., hspace=0.2)
def rasta_plp_extractor(x, sr, plp_order=0, do_rasta=True):
spec = log_power_spectrum_extractor(x, int(sr*0.02), int(sr*0.01), 'hamming', False)
bark_filters = int(np.ceil(freq2bark(sr//2)))
wts = get_fft_bark_mat(sr, int(sr*0.02), bark_filters)
'''
plt.figure()
plt.subplot(211)
plt.imshow(wts)
plt.subplot(212)
plt.hold(True)
for i in range(18):
plt.plot(wts[i, :])
plt.show()
'''
bark_spec = np.matmul(wts, spec)
if do_rasta:
bark_spec = np.where(bark_spec == 0.0, np.finfo(float).eps, bark_spec)
log_bark_spec = np.log(bark_spec)
rasta_log_bark_spec = rasta_filt(log_bark_spec)
bark_spec = np.exp(rasta_log_bark_spec)
post_spec = postaud(bark_spec, sr/2.)
if plp_order > 0:
lpcas = do_lpc(post_spec, plp_order)
# lpcas = do_lpc(spec, plp_order) # just for test
else:
lpcas = post_spec
return lpcas
def run_frey():
# import dataset
data = pods.datasets.brendan_faces()
# Y = data['Y'][:50, :]
Y = data['Y']
Yn = Y - np.mean(Y, axis=0)
Yn /= np.std(Y, axis=0)
Y = Yn
# inference
print "inference ..."
M = 30
D = 20
lvm = vfe.SGPLVM(Y, D, M, lik='Gaussian')
lvm.optimise(method='L-BFGS-B', maxiter=10)
plt.figure()
mx, vx = lvm.get_posterior_x()
zu = lvm.sgp_layer.zu
plt.scatter(mx[:, 0], mx[:, 1])
plt.plot(zu[:, 0], zu[:, 1], 'ko')
nx = ny = 30
x_values = np.linspace(-5, 5, nx)
y_values = np.linspace(-5, 5, ny)
sx = 28
sy = 20
canvas = np.empty((sx * ny, sy * nx))
for i, yi in enumerate(x_values):
for j, xi in enumerate(y_values):
z_mu = np.array([[xi, yi]])
x_mean, x_var = lvm.predict_f(z_mu)
canvas[(nx - i - 1) * sx:(nx - i) * sx, j *
sy:(j + 1) * sy] = x_mean.reshape(sx, sy)
plt.figure(figsize=(8, 10))
Xi, Yi = np.meshgrid(x_values, y_values)
plt.imshow(canvas, origin="upper", cmap="gray")
plt.tight_layout()
plt.show()
def run_frey():
# import dataset
data = pods.datasets.brendan_faces()
# Y = data['Y'][:50, :]
Y = data['Y']
Yn = Y - np.mean(Y, axis=0)
Yn /= np.std(Y, axis=0)
Y = Yn
# inference
print "inference ..."
M = 30
D = 20
lvm = aep.SGPLVM(Y, D, M, lik='Gaussian')
# lvm.train(alpha=0.5, no_epochs=10, n_per_mb=100, lrate=0.1, fixed_params=['sn'])
lvm.optimise(method='L-BFGS-B', alpha=0.1, maxiter=10)
plt.figure()
mx, vx = lvm.get_posterior_x()
zu = lvm.sgp_layer.zu
plt.scatter(mx[:, 0], mx[:, 1])
plt.plot(zu[:, 0], zu[:, 1], 'ko')
nx = ny = 30
x_values = np.linspace(-5, 5, nx)
y_values = np.linspace(-5, 5, ny)
sx = 28
sy = 20
canvas = np.empty((sx * ny, sy * nx))
for i, yi in enumerate(x_values):
for j, xi in enumerate(y_values):
z_mu = np.array([[xi, yi]])
x_mean, x_var = lvm.predict_f(z_mu)
canvas[(nx - i - 1) * sx:(nx - i) * sx, j *
sy:(j + 1) * sy] = x_mean.reshape(sx, sy)
plt.figure(figsize=(8, 10))
Xi, Yi = np.meshgrid(x_values, y_values)
plt.imshow(canvas, origin="upper", cmap="gray")
plt.tight_layout()
plt.show()
def snapshot(self, fn = None, clip_ratio = None):
import matplotlib.pylab as pylab
pylab.figure(2)
self.transfer_function.show()
pylab.draw()
im = Camera.snapshot(self, fn, clip_ratio)
pylab.figure(1)
pylab.imshow(im / im.max())
pylab.draw()
self.frames.append(im)
def imageSegy(Data):
"""
imageSegy(Data)
Image segy Data
"""
import matplotlib.pylab as plt
plt.imshow(Data)
plt.title('pymat test')
plt.grid(True)
plt.show()
#%%
def draw_heatmap(xedges, yedges, heatmap):
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
plt.figure(figsize=(8, 8))
plt.imshow(heatmap, extent=extent)
plt.show()
def animate(y, ndim, cmap) :
plt.ion()
if ndim == 5:
plt.figure()
plt.show()
for i in range(y.shape[1]) :
print "Showing batch", i
plt.close('all')
for j in range(y.shape[0]) :
plt.imshow(y[j,i], interpolation='none', cmap=cmap)
plt.pause(0.1)
time.sleep(1)
else:
for i in range(y.shape[1]) :
print "Showing batch", i
plt.close('all')
for j in range(y.shape[0]) :
plt.figure(0)
plt.imshow(y[j,i], interpolation='none', cmap=cmap)
plt.figure(1)
plt.imshow(x[j,i], interpolation='none', cmap=cmap)
plt.pause(0.2)
time.sleep(1)
def fancy_show(y, cmap=''):
x = y[0]
y = y[1]
plt.figure(0)
for i in range(100):
plt.subplot(10, 10, i+1)
plt.imshow(x[i], cmap=cmap, interpolation='none')
plt.axis('off')
plt.figure(1)
for i in range(100):
plt.subplot(10, 10, i+1)
plt.imshow(y[i], cmap=cmap, interpolation='none')
plt.axis('off')
plt.show()
def imshow_(x, **kwargs):
if x.ndim == 2:
plt.imshow(x, interpolation="nearest", **kwargs)
elif x.ndim == 1:
plt.imshow(x[:,None].T, interpolation="nearest", **kwargs)
plt.yticks([])
plt.axis("tight")
# ------------- Data -------------
def show_image(data, shape, order='f', cmap=cm.gray):
"""
display an image from a 1d vector
:param data: 1d vector containing image information
:param shape: actual image dimensions
:param order: 'c' or 'f'
:param cmap: colour map, defaults to grayscale
:return:
"""
img = data.reshape(shape, order=order)
plt.imshow(img, cmap=cmap)
plt.show()
def plotImgPatchPrototypes(doShowNow=True):
from matplotlib import pylab
pylab.figure()
for kk in range(K):
pylab.subplot(2, 4, kk + 1)
Xp = makeImgPatchPrototype(D, kk)
pylab.imshow(Xp, interpolation='nearest')
if doShowNow:
pylab.show()
def plotTrueCovMats(doShowNow=True):
from matplotlib import pylab
pylab.figure()
for kk in range(K):
pylab.subplot(2, 4, kk + 1)
pylab.imshow(Sigma[kk], interpolation='nearest')
if doShowNow:
pylab.show()
def plotBlackWhiteStateSeqForMeeting(meetingNum=1, badUIDs=[-1, -2],
**kwargs):
''' Make plot like in Fig. 3 of AOAS paper
'''
from matplotlib import pylab
Data = get_data(meetingNum=args.meetingNum)
Z = np.asarray(Data.TrueParams['Z'], dtype=np.int32)
uLabels = np.unique(Z)
uLabels = np.asarray([u for u in uLabels if u not in badUIDs])
sizes = np.asarray([np.sum(Z == u) for u in uLabels])
sortIDs = np.argsort(-1 * sizes)
Zim = np.zeros((10, Z.size))
for rankID, uID in enumerate(uLabels[sortIDs]):
Zim[1 + rankID, Z == uID] = 1
size = sizes[sortIDs[rankID]]
frac = size / float(Z.size)
print 'state %3d: %5d tsteps (%.3f)' % (rankID + 1, size, frac)
for uID in badUIDs:
size = np.sum(Z == uID)
frac = size / float(Z.size)
print 'state %3d: %5d tsteps (%.3f)' % (uID, size, frac)
pylab.imshow(1 - Zim,
interpolation='nearest',
aspect=Zim.shape[1] / float(Zim.shape[0]) / 3,
cmap='bone',
vmin=0,
vmax=1,
origin='lower')
pylab.show()