Python matplotlib.pylab.imshow() Examples
The following are 30
code examples of matplotlib.pylab.imshow().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.pylab
, or try the search function
.
Example #1
Source File: graph-bot.py From discord-bots with MIT License | 6 votes |
def matrix(msg, mobj): """ Interpret a user string, convert it to a list and graph it as a matrix Uses ast.literal_eval to parse input into a list """ fname = bot_data("{}.png".format(mobj.author.id)) try: list_input = literal_eval(msg) if not isinstance(list_input, list): raise ValueError("Not a list") m = np_matrix(list_input) fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.set_aspect('equal') plt.imshow(m, interpolation='nearest', cmap=plt.cm.ocean) plt.colorbar() plt.savefig(fname) await client.send_file(mobj.channel, fname) f_remove(fname) return except Exception as ex: logger("!matrix: {}".format(ex)) return await client.send_message(mobj.channel, "Failed to render graph")
Example #2
Source File: testfuncs.py From ImageFusion with MIT License | 6 votes |
def plotallfuncs(allfuncs=allfuncs): from matplotlib import pylab as pl pl.ioff() nnt = NNTester(npoints=1000) lpt = LinearTester(npoints=1000) for func in allfuncs: print(func.title) nnt.plot(func, interp=False, plotter='imshow') pl.savefig('%s-ref-img.png' % func.__name__) nnt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-nn-img.png' % func.__name__) lpt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-lin-img.png' % func.__name__) nnt.plot(func, interp=False, plotter='contour') pl.savefig('%s-ref-con.png' % func.__name__) nnt.plot(func, interp=True, plotter='contour') pl.savefig('%s-nn-con.png' % func.__name__) lpt.plot(func, interp=True, plotter='contour') pl.savefig('%s-lin-con.png' % func.__name__) pl.ion()
Example #3
Source File: dataset.py From Image-Restoration with MIT License | 6 votes |
def show_pred(images, predictions, ground_truth): # choose 10 indice from images and visualize them indice = [np.random.randint(0, len(images)) for i in range(40)] for i in range(0, 40): plt.figure() plt.subplot(1, 3, 1) plt.tight_layout() plt.title('deformed image') plt.imshow(images[indice[i]]) plt.subplot(1, 3, 2) plt.tight_layout() plt.title('predicted mask') plt.imshow(predictions[indice[i]]) plt.subplot(1, 3, 3) plt.tight_layout() plt.title('ground truth label') plt.imshow(ground_truth[indice[i]]) plt.show() # Load Data Science Bowl 2018 training dataset
Example #4
Source File: camera_test.py From camera.py with MIT License | 6 votes |
def calibrate_division_model_test(): img = rgb2gray(plt.imread('test/kamera2.png')) y0 = np.array(img.shape)[::-1][np.newaxis].T / 2. z_n = np.linalg.norm(np.array(img.shape) / 2.) points = pilab_annotate_load('test/kamera2_lines.xml') points_per_line = 5 num_lines = points.shape[0] / points_per_line lines_coords = np.array([points[i * points_per_line:i * points_per_line + points_per_line] for i in xrange(num_lines)]) c = camera.calibrate_division_model(lines_coords, y0, z_n) import matplotlib.cm as cm plt.figure() plt.imshow(img, cmap=cm.gray) for line in xrange(num_lines): x = lines_coords[line, :, 0] plt.plot(x, lines_coords[line, :, 1], 'g') mc = camera.fit_line(lines_coords[line].T) plt.plot(x, mc[0] * x + mc[1], 'y') xy = c.undistort(lines_coords[line].T) plt.plot(xy[0, :], xy[1, :], 'r') plt.show() plt.close()
Example #5
Source File: make_dataset.py From DeepLearningImplementations with MIT License | 6 votes |
def check_HDF5(size=64): """ Plot images with landmarks to check the processing """ # Get hdf5 file hdf5_file = os.path.join(data_dir, "CelebA_%s_data.h5" % size) with h5py.File(hdf5_file, "r") as hf: data_color = hf["data"] for i in range(data_color.shape[0]): plt.figure() img = data_color[i, :, :, :].transpose(1,2,0) plt.imshow(img) plt.show() plt.clf() plt.close()
Example #6
Source File: usage_example.py From tensorflow-ffmpeg with MIT License | 6 votes |
def _show_video(video, fps=10): # Import matplotlib/pylab only if needed import matplotlib matplotlib.use('TkAgg') import matplotlib.pylab as pl pl.style.use('ggplot') pl.axis('off') if fps < 0: fps = 25 video /= 255. # Pylab works in [0, 1] range img = None pause_length = 1. / fps try: for f in range(video.shape[0]): im = video[f, :, :, :] if img is None: img = pl.imshow(im) else: img.set_data(im) pl.pause(pause_length) pl.draw() except: pass
Example #7
Source File: make_dataset.py From DeepLearningImplementations with MIT License | 6 votes |
def check_HDF5(size=64): """ Plot images with landmarks to check the processing """ # Get hdf5 file hdf5_file = os.path.join(data_dir, "CelebA_%s_data.h5" % size) with h5py.File(hdf5_file, "r") as hf: data_color = hf["data"] for i in range(data_color.shape[0]): plt.figure() img = data_color[i, :, :, :].transpose(1,2,0) plt.imshow(img) plt.show() plt.clf() plt.close()
Example #8
Source File: make_dataset.py From DeepLearningImplementations with MIT License | 6 votes |
def check_HDF5(size): """ Plot images with landmarks to check the processing """ # Get hdf5 file hdf5_file = os.path.join(data_dir, "lfw_%s_data.h5" % size) with h5py.File(hdf5_file, "r") as hf: data_color = hf["data"] label = hf["labels"] attrs = label.attrs["label_names"] for i in range(data_color.shape[0]): plt.figure(figsize=(20, 10)) img = data_color[i, :, :, :].transpose(1,2,0)[:, :, ::-1] # Get the 10 labels with highest values idx = label[i].argsort()[-10:] plt.xlabel(", ".join(attrs[idx]), fontsize=12) plt.imshow(img) plt.show() plt.clf() plt.close()
Example #9
Source File: visualization_utils.py From DeepLearningImplementations with MIT License | 6 votes |
def format_plot(X, epoch=None, title=None, figsize=(15, 10)): plt.figure(figsize=figsize) if X.shape[-1] == 1: plt.imshow(X[:, :, 0], cmap="gray") else: plt.imshow(X) plt.axis("off") plt.gca().xaxis.set_major_locator(mp.ticker.NullLocator()) plt.gca().yaxis.set_major_locator(mp.ticker.NullLocator()) if epoch is not None and title is None: save_path = os.path.join(FLAGS.fig_dir, "current_batch_%s.png" % epoch) elif epoch is not None and title is not None: save_path = os.path.join(FLAGS.fig_dir, "%s_%s.png" % (title, epoch)) elif title is not None: save_path = os.path.join(FLAGS.fig_dir, "%s.png" % title) plt.savefig(save_path, bbox_inches='tight', pad_inches=0) plt.clf() plt.close()
Example #10
Source File: testfuncs.py From neural-network-animation with MIT License | 6 votes |
def plotallfuncs(allfuncs=allfuncs): from matplotlib import pylab as pl pl.ioff() nnt = NNTester(npoints=1000) lpt = LinearTester(npoints=1000) for func in allfuncs: print(func.title) nnt.plot(func, interp=False, plotter='imshow') pl.savefig('%s-ref-img.png' % func.__name__) nnt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-nn-img.png' % func.__name__) lpt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-lin-img.png' % func.__name__) nnt.plot(func, interp=False, plotter='contour') pl.savefig('%s-ref-con.png' % func.__name__) nnt.plot(func, interp=True, plotter='contour') pl.savefig('%s-nn-con.png' % func.__name__) lpt.plot(func, interp=True, plotter='contour') pl.savefig('%s-lin-con.png' % func.__name__) pl.ion()
Example #11
Source File: imaging.py From isp with MIT License | 6 votes |
def __init__(self, name = "unknown", data = -1, is_show = False): self.name = name self.data = data self.size = np.shape(self.data) self.is_show = is_show self.color_space = "unknown" self.bayer_pattern = "unknown" self.channel_gain = (1.0, 1.0, 1.0, 1.0) self.bit_depth = 0 self.black_level = (0, 0, 0, 0) self.white_level = (1, 1, 1, 1) self.color_matrix = [[1., .0, .0],\ [.0, 1., .0],\ [.0, .0, 1.]] # xyz2cam self.min_value = np.min(self.data) self.max_value = np.max(self.data) self.data_type = self.data.dtype # Display image only isShow = True if (self.is_show): plt.imshow(self.data) plt.show()
Example #12
Source File: testfuncs.py From matplotlib-4-abaqus with MIT License | 6 votes |
def plotallfuncs(allfuncs=allfuncs): from matplotlib import pylab as pl pl.ioff() nnt = NNTester(npoints=1000) lpt = LinearTester(npoints=1000) for func in allfuncs: print(func.title) nnt.plot(func, interp=False, plotter='imshow') pl.savefig('%s-ref-img.png' % func.func_name) nnt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-nn-img.png' % func.func_name) lpt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-lin-img.png' % func.func_name) nnt.plot(func, interp=False, plotter='contour') pl.savefig('%s-ref-con.png' % func.func_name) nnt.plot(func, interp=True, plotter='contour') pl.savefig('%s-nn-con.png' % func.func_name) lpt.plot(func, interp=True, plotter='contour') pl.savefig('%s-lin-con.png' % func.func_name) pl.ion()
Example #13
Source File: prod_basis.py From pyscf with Apache License 2.0 | 6 votes |
def generate_png_chess_dp_vertex(self): """Produces pictures of the dominant product vertex a chessboard convention""" import matplotlib.pylab as plt plt.ioff() dab2v = self.get_dp_vertex_doubly_sparse() for i, ab in enumerate(dab2v): fname = "chess-v-{:06d}.png".format(i) print('Matrix No.#{}, Size: {}, Type: {}'.format(i+1, ab.shape, type(ab)), fname) if type(ab) != 'numpy.ndarray': ab = ab.toarray() fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.set_aspect('equal') plt.imshow(ab, interpolation='nearest', cmap=plt.cm.ocean) plt.colorbar() plt.savefig(fname) plt.close(fig)
Example #14
Source File: audio.py From Self-Supervised-Speech-Pretraining-and-Representation-Learning with MIT License | 6 votes |
def plot_spectrogram_to_numpy(spectrogram): spectrogram = spectrogram.transpose(1, 0) fig, ax = plt.subplots(figsize=(12, 3)) im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation='none') plt.colorbar(im, ax=ax) plt.xlabel("Frames") plt.ylabel("Channels") plt.tight_layout() fig.canvas.draw() data = _save_figure_to_numpy(fig) plt.close() return data #################### # PLOT SPECTROGRAM # ####################
Example #15
Source File: streams.py From convis with GNU General Public License v3.0 | 6 votes |
def _repr_html_(self): from . import variable_describe def _plot(fn): from PIL import Image try: import matplotlib.pylab as plt t = np.array(Image.open(fn)) plt.figure() plt.imshow(self._crop(t)) plt.axis('off') return "<img src='data:image/png;base64," + variable_describe._plot_to_string() + "'>" except: return "<br/>Failed to open." s = "<b>ImageSequence</b> size="+str(self.size) s += ", offset = "+str(self.offset) s += ", repeat = "+str(self.repeat) s += ", is_color = "+str(self.is_color) s += ", [frame "+str(self.i)+"/"+str(len(self))+"]" s += "<div style='background:#ff;padding:10px'><b>Input Images:</b>" for t in np.unique(self.file_list)[:10]: s += "<div style='background:#fff; margin:10px;padding:10px; border-left: 4px solid #eee;'>"+str(t)+": "+_plot(t)+"</div>" s += "</div>" return s
Example #16
Source File: testfuncs.py From Computable with MIT License | 6 votes |
def plotallfuncs(allfuncs=allfuncs): from matplotlib import pylab as pl pl.ioff() nnt = NNTester(npoints=1000) lpt = LinearTester(npoints=1000) for func in allfuncs: print(func.title) nnt.plot(func, interp=False, plotter='imshow') pl.savefig('%s-ref-img.png' % func.func_name) nnt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-nn-img.png' % func.func_name) lpt.plot(func, interp=True, plotter='imshow') pl.savefig('%s-lin-img.png' % func.func_name) nnt.plot(func, interp=False, plotter='contour') pl.savefig('%s-ref-con.png' % func.func_name) nnt.plot(func, interp=True, plotter='contour') pl.savefig('%s-nn-con.png' % func.func_name) lpt.plot(func, interp=True, plotter='contour') pl.savefig('%s-lin-con.png' % func.func_name) pl.ion()
Example #17
Source File: make_dataset.py From DeepLearningImplementations with MIT License | 6 votes |
def check_HDF5(size=64): """ Plot images with landmarks to check the processing """ # Get hdf5 file hdf5_file = os.path.join(data_dir, "CelebA_%s_data.h5" % size) with h5py.File(hdf5_file, "r") as hf: data_color = hf["data"] for i in range(data_color.shape[0]): plt.figure() img = data_color[i, :, :, :].transpose(1,2,0) plt.imshow(img) plt.show() plt.clf() plt.close()
Example #18
Source File: make_dataset.py From DeepLearningImplementations with MIT License | 6 votes |
def check_HDF5(jpeg_dir, nb_channels): """ Plot images with landmarks to check the processing """ # Get hdf5 file file_name = os.path.basename(jpeg_dir.rstrip("/")) hdf5_file = os.path.join(data_dir, "%s_data.h5" % file_name) with h5py.File(hdf5_file, "r") as hf: data_full = hf["train_data_full"] data_sketch = hf["train_data_sketch"] for i in range(data_full.shape[0]): plt.figure() img = data_full[i, :, :, :].transpose(1,2,0) img2 = data_sketch[i, :, :, :].transpose(1,2,0) img = np.concatenate((img, img2), axis=1) if nb_channels == 1: plt.imshow(img[:, :, 0], cmap="gray") else: plt.imshow(img) plt.show() plt.clf() plt.close()
Example #19
Source File: evaluation.py From deepecg with MIT License | 5 votes |
def plot_confusion_matrix(y_true, y_pred, classes, figure_size=(8, 8)): """This function plots a confusion matrix.""" # Compute confusion matrix cm = confusion_matrix(y_true, y_pred) cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] * 100 # Build Laussen Labs colormap cmap = LinearSegmentedColormap.from_list('laussen_labs_green', ['w', '#43BB9B'], N=256) # Setup plot plt.figure(figsize=figure_size) # Plot confusion matrix plt.imshow(cm, interpolation='nearest', cmap=cmap) # Modify axes tick_marks = np.arange(len(classes)) plt.xticks(tick_marks, classes, rotation=90) plt.yticks(tick_marks, classes) thresh = cm.max() / 1.5 for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): plt.text(j, i, str(np.round(cm[i, j], 2)) + ' %', horizontalalignment="center", color="white" if cm[i, j] > thresh else "black", fontsize=20) plt.xticks(fontsize=16) plt.yticks(fontsize=16) plt.tight_layout() plt.ylabel('True Label', fontsize=25) plt.xlabel('Predicted Label', fontsize=25) plt.show()
Example #20
Source File: audio.py From Self-Supervised-Speech-Pretraining-and-Representation-Learning with MIT License | 5 votes |
def plot_spectrogram(spec, path): spec = spec.transpose(1, 0) # (seq_len, feature_dim) -> (feature_dim, seq_len) plt.gcf().clear() plt.figure(figsize=(12, 3)) plt.imshow(spec, aspect="auto", origin="lower") plt.colorbar() plt.tight_layout() plt.savefig(path, dpi=300, format="png") plt.close() #################### # PLOT EMBEDDING # ####################
Example #21
Source File: data_utils.py From Pix2Depth with GNU General Public License v3.0 | 5 votes |
def plot_generated_batch(X_full, X_sketch, generator_model, batch_size, image_data_format, suffix, show_plot=False): # Generate images X_gen = generator_model.predict(X_sketch) X_sketch = inverse_normalization(X_sketch) X_full = inverse_normalization(X_full) X_gen = inverse_normalization(X_gen) Xs = X_sketch[:8] Xg = X_gen[:8] Xr = X_full[:8] if image_data_format == "channels_last": X = np.concatenate((Xs, Xg, Xr), axis=0) list_rows = [] for i in range(int(X.shape[0] // 4)): Xr = np.concatenate([X[k] for k in range(4 * i, 4 * (i + 1))], axis=1) list_rows.append(Xr) Xr = np.concatenate(list_rows, axis=0) if image_data_format == "channels_first": X = np.concatenate((Xs, Xg, Xr), axis=0) list_rows = [] for i in range(int(X.shape[0] // 4)): Xr = np.concatenate([X[k] for k in range(4 * i, 4 * (i + 1))], axis=2) list_rows.append(Xr) Xr = np.concatenate(list_rows, axis=1) Xr = Xr.transpose(1,2,0) if show_plot: if Xr.shape[-1] == 1: plt.imshow(Xr[:, :, 0], cmap="gray") else: plt.imshow(Xr) plt.axis("off") plt.savefig("../../figures/current_batch_%s.png" % suffix) plt.clf() plt.close()
Example #22
Source File: audio.py From Self-Supervised-Speech-Pretraining-and-Representation-Learning with MIT License | 5 votes |
def plot_attention(attn, path): fig = plt.figure(figsize=(5, 5)) plt.imshow(attn) plt.savefig(path, format='png') plt.close()
Example #23
Source File: data_utils.py From DeepLearningImplementations with MIT License | 5 votes |
def plot_generated_batch(X_real, generator_model, batch_size, cat_dim, cont_dim, noise_dim, image_data_format, noise_scale=0.5): # Generate images y_cat = sample_cat(batch_size, cat_dim) y_cont = sample_noise(noise_scale, batch_size, cont_dim) noise_input = sample_noise(noise_scale, batch_size, noise_dim) # Produce an output X_gen = generator_model.predict([y_cat, y_cont, noise_input],batch_size=batch_size) X_real = inverse_normalization(X_real) X_gen = inverse_normalization(X_gen) Xg = X_gen[:8] Xr = X_real[:8] if image_data_format == "channels_last": X = np.concatenate((Xg, Xr), axis=0) list_rows = [] for i in range(int(X.shape[0] / 4)): Xr = np.concatenate([X[k] for k in range(4 * i, 4 * (i + 1))], axis=1) list_rows.append(Xr) Xr = np.concatenate(list_rows, axis=0) if image_data_format == "channels_first": X = np.concatenate((Xg, Xr), axis=0) list_rows = [] for i in range(int(X.shape[0] / 4)): Xr = np.concatenate([X[k] for k in range(4 * i, 4 * (i + 1))], axis=2) list_rows.append(Xr) Xr = np.concatenate(list_rows, axis=1) Xr = Xr.transpose(1,2,0) if Xr.shape[-1] == 1: plt.imshow(Xr[:, :, 0], cmap="gray") else: plt.imshow(Xr) plt.savefig("../../figures/current_batch.png") plt.clf() plt.close()
Example #24
Source File: general_utils.py From DeepLearningImplementations with MIT License | 5 votes |
def plot_batch(color_model, q_ab, X_batch_black, X_batch_color, batch_size, h, w, nb_q, epoch): # Format X_colorized X_colorized = color_model.predict(X_batch_black / 100.)[:, :, :, :-1] X_colorized = X_colorized.reshape((batch_size * h * w, nb_q)) X_colorized = q_ab[np.argmax(X_colorized, 1)] X_a = X_colorized[:, 0].reshape((batch_size, 1, h, w)) X_b = X_colorized[:, 1].reshape((batch_size, 1, h, w)) X_colorized = np.concatenate((X_batch_black, X_a, X_b), axis=1).transpose(0, 2, 3, 1) X_colorized = [np.expand_dims(color.lab2rgb(im), 0) for im in X_colorized] X_colorized = np.concatenate(X_colorized, 0).transpose(0, 3, 1, 2) X_batch_color = [np.expand_dims(color.lab2rgb(im.transpose(1, 2, 0)), 0) for im in X_batch_color] X_batch_color = np.concatenate(X_batch_color, 0).transpose(0, 3, 1, 2) list_img = [] for i, img in enumerate(X_colorized[:min(32, batch_size)]): arr = np.concatenate([X_batch_color[i], np.repeat(X_batch_black[i] / 100., 3, axis=0), img], axis=2) list_img.append(arr) plt.figure(figsize=(20,20)) list_img = [np.concatenate(list_img[4 * i: 4 * (i + 1)], axis=2) for i in range(len(list_img) // 4)] arr = np.concatenate(list_img, axis=1) plt.imshow(arr.transpose(1,2,0)) ax = plt.gca() ax.get_xaxis().set_ticks([]) ax.get_yaxis().set_ticks([]) plt.tight_layout() plt.savefig("../../figures/fig_epoch%s.png" % epoch) plt.clf() plt.close()
Example #25
Source File: utils.py From TemporalConvolutionalNetworks with MIT License | 5 votes |
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 -------------
Example #26
Source File: camera_test.py From camera.py with MIT License | 5 votes |
def load_test(): c = camera.Camera(1) c.load('test/camera_01.yaml') # pitch dimensions [-20, -10, 19, 9.5] # xmin, ymin, xmax, ymax points = np.array([[-20, -10, 0], [-20, 9.5, 0], [19, 9.5, 0], [19, -10, 0], [-20, -10, 0]]).T c.plot_world_points(points, 'r-', solve_visibility=False) points = np.array([[0, -10, 0], [0, 9.5, 0]]).T c.plot_world_points(points, 'y-', solve_visibility=False) import matplotlib.pylab as plt plt.imshow(plt.imread('test/cam01.png')) # plt.show() plt.savefig('test/out/camera_load_test.png', dpi=150) plt.close()
Example #27
Source File: device_saver.py From angler with MIT License | 5 votes |
def _calc_trans_ortho(self): # input power self.W_in = self.simulation.W_in print(" -> W_in = {}".format(self.W_in)) # linear powers self.W_right_lin = self.simulation.flux_probe('x', [-self.NPML[0]-int(self.l/2/self.dl), self.ny], int(self.H/2/self.dl)) self.W_top_lin = self.simulation.flux_probe('y', [self.nx, -self.NPML[1]-int(self.l/2/self.dl)], int(self.H/2/self.dl)) # nonlinear powers self.W_right_nl = self.simulation.flux_probe('x', [-self.NPML[0]-int(self.l/2/self.dl), self.ny], int(self.H/2/self.dl), nl=True) self.W_top_nl = self.simulation.flux_probe('y', [self.nx, -self.NPML[1]-int(self.l/2/self.dl)], int(self.H/2/self.dl), nl=True) print(' -> linear transmission (right) = {:.4f}'.format(self.W_right_lin / self.W_in)) print(' -> linear transmission (top) = {:.4f}'.format(self.W_top_lin / self.W_in)) print(' -> nonlinear transmission (right) = {:.4f}'.format(self.W_right_nl / self.W_in)) print(' -> nonlinear transmission (top) = {:.4f}'.format(self.W_top_nl / self.W_in)) self.S = [[self.W_top_lin / self.W_in, self.W_right_lin / self.W_in], [self.W_top_nl / self.W_in, self.W_right_nl / self.W_in]] plt.imshow(self.S, cmap='magma') plt.colorbar() plt.title('power matrix') plt.show()
Example #28
Source File: device_saver.py From angler with MIT License | 5 votes |
def _calc_trans_three(self): # input power self.W_in = self.simulation.W_in print(" -> W_in = {}".format(self.W_in)) # linear powers self.W_top_lin = self.simulation.flux_probe('x', [-self.NPML[0]-int(self.l/2/self.dl), self.ny+int(self.d/2/self.dl)], int(self.H/2/self.dl)) self.W_bot_lin = self.simulation.flux_probe('x', [-self.NPML[0]-int(self.l/2/self.dl), self.ny-int(self.d/2/self.dl)], int(self.H/2/self.dl)) # nonlinear powers self.W_top_nl = self.simulation.flux_probe('x', [-self.NPML[0]-int(self.l/2/self.dl), self.ny+int(self.d/2/self.dl)], int(self.H/2/self.dl), nl=True) self.W_bot_nl = self.simulation.flux_probe('x', [-self.NPML[0]-int(self.l/2/self.dl), self.ny-int(self.d/2/self.dl)], int(self.H/2/self.dl), nl=True) print(' -> linear transmission (top) = {:.4f}'.format(self.W_top_lin / self.W_in)) print(' -> linear transmission (bottom) = {:.4f}'.format(self.W_bot_lin / self.W_in)) print(' -> nonlinear transmission (top) = {:.4f}'.format(self.W_top_nl / self.W_in)) print(' -> nonlinear transmission (bottom) = {:.4f}'.format(self.W_bot_nl / self.W_in)) self.S = [[self.W_top_lin / self.W_in, self.W_top_nl / self.W_in], [self.W_bot_lin / self.W_in, self.W_bot_nl / self.W_in]] plt.imshow(self.S, cmap='magma') plt.colorbar() plt.title('power matrix') plt.show()
Example #29
Source File: dataset.py From UNet-pytorch with MIT License | 5 votes |
def show_batch(sample_batched): """Show image with landmarks for a batch of samples.""" images_batch, masks_batch = sample_batched['image'].numpy().astype(np.uint8), sample_batched['mask'].numpy().astype(np.bool) batch_size = len(images_batch) for i in range(batch_size): plt.figure() plt.subplot(1, 2, 1) plt.tight_layout() plt.imshow(images_batch[i].transpose((1, 2, 0))) plt.subplot(1, 2, 2) plt.tight_layout() plt.imshow(np.squeeze(masks_batch[i].transpose((1, 2, 0)))) # Load Data Science Bowl 2018 training dataset
Example #30
Source File: test_fields_fdfd.py From ceviche with MIT License | 5 votes |
def test_Ez(self): print('\ttesting Ez') F = fdfd_ez(self.omega, self.dL, self.eps_r, self.npml) Hx, Hy, Ez = F.solve(self.source) plot_component = Ez field_max = np.max(np.abs(plot_component)) plt.imshow(np.real(plot_component), cmap='RdBu', vmin=-field_max/5, vmax=field_max/5) plt.show()