3 Make some validation plots 6 import matplotlib.pyplot
as plt
7 from matplotlib.colors
import LinearSegmentedColormap
39 cm = LinearSegmentedColormap.from_list(
'wct_soft0', soft0, N=100)
40 cm.set_bad(color=
'white')
41 plt.register_cmap(cmap=cm)
43 cm = LinearSegmentedColormap(
'wct_hard0', hard0, N=100)
44 cm.set_bad(color=
'white')
45 plt.register_cmap(cmap=cm)
51 Plot three arrays horizontally. 57 if name
in "orig".
split():
60 zlabel = dict(orig=
"ADC", raw=
"nfADC", gauss=
"electrons", wiener=
"electrons")[name]
64 hpix = sum([a.shape[1]
for a
in arrs])
76 width_pix = hpix + len(arrs)*bpix*2 + cpix
77 width_inch = width_pix/dpi
78 height_pix = vpix + 2*bpix + blpix + tpix
79 height_inch = height_pix/dpi
81 bot_pix = blpix + bpix
83 figsize=(width_inch, height_inch)
85 fig = plt.figure(dpi=dpi, figsize = figsize)
91 vmin =
min([numpy.min(arr)
for arr
in arrs])
92 vmax =
max([numpy.max(arr)
for arr
in arrs])
100 for letter, arr, ext
in zip(
"UVW", arrs, extents):
101 tit =
"%d ticks x %d ch grps" % (arr.shape[0], arr.shape[1])
103 xa = (left_pix+bpix)/
float(width_pix)
104 ya = bot_pix/
float(height_pix)
105 dxa = arr.shape[1]/
float(width_pix)
106 dya = arr.shape[0]/
float(height_pix)
107 relaxis = (xa,ya,dxa,dya)
108 x_axes.append((xa,dxa))
110 left_pix += 2*bpix + arr.shape[1]
113 ax = fig.add_axes(relaxis)
116 ax.set_xlabel(
"%s channels" % letter)
117 ax.set_ylabel(
"ticks")
119 im = ax.imshow(arr, cmap=cmap, interpolation=
'none', extent=ext, aspect=
'auto', vmin=vmin, vmax=vmax)
123 relaxis = [(left_pix)/
float(width_pix),
124 bot_pix/
float(height_pix),
125 (cpix-cibpix)/
float(width_pix),
126 (arrs[0].shape[0])/
float(height_pix)]
127 cbar_ax = fig.add_axes(relaxis)
128 fig.colorbar(ims[0], ax=axes[0], cmap=cmap, cax=cbar_ax, label=zlabel)
136 for letter, blarr, ext, (xa,dxa)
in zip(
"UVW", baselines, extents, x_axes):
139 bpix/
float(height_pix),
141 blpix/
float(height_pix))
143 left_pix += 2*bpix + blarr.size/
float(width_pix)
145 ax = fig.add_axes(relaxis)
148 ax.set_xlabel(
"%s channels" % letter)
149 ax.set_ylabel(
"baseline")
152 ax.plot(numpy.linspace(ext[0], ext[1], num=blarr.size), blarr)
153 ax.set_xlim([ext[0],ext[1]])
160 cmap =
'nipy_spectral' 163 size = (arr.shape[0]/dpi, arr.shape[1]/dpi)
165 fig = plt.figure(dpi=dpi, figsize=size)
166 ax = fig.add_subplot(1,1,1)
168 im = ax.imshow(arr, cmap=cmap, interpolation=
'none', extent=extent, aspect=
'auto')
169 fig.colorbar(im, cmap=cmap)
176 matplotlib.rcParams.update({
'font.size': 8})
181 fig, axes = plt.subplots(len(mnames), len(arrs[mnames[0]]), figsize=(8.5,11), dpi=100)
183 for icol, (arr,letter)
in enumerate(
zip(arrs[mname],
"UVW")):
185 ls = numpy.linspace(ext[0], ext[1], num=arr.size)
188 ax.set_xlim([ext[0],ext[1]])
189 ax.set_title(
"%s-plane %s '%s'" % (letter, mname, name));
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
static int max(int a, int b)
def channel_summaries(name, arrs, extents)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
def three_horiz(arrs, extents, name, baselines)
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void split(std::string const &s, char c, OutIter dest)
def one_plane(arr, extent, name)