def plot(t_P, q, system, gens, mode_nums=None, verbose=False, tc="x", xmin=False, xmax=False, ymin=False, ymax=False): """ a wrapper for plotting routines we'll use a lot """ n_l_m = system.network.nlm ans = [] ### amp-time if verbose: print "amp_time" fig, ax = nmp.amp_plot(t_P, q, n_l_m=n_l_m, mode_nums=mode_nums) ax.set_ylabel(r"$|" + tc + "_i|$") ax.set_xlabel(r"$t/P_{\mathrm{orb}}$") if ymin: ax.set_ylim(ymin=ymin) if ymax: ax.set_ylim(ymax=ymax) if xmin: ax.set_xlim(xmin=xmin) if xmax: ax.set_xlim(xmax=xmax) ans.append((fig, ax)) ### multi-gen-amp-time if verbose: print "multi-gen_amp_time" fig, axs = nmp.multi_gen_amp_plot(t_P, q, gens, n_l_m=n_l_m, mode_nums=mode_nums) for ax in axs: ax.set_ylabel(r"$|" + tc + "|$") ax.set_xlabel(r"$t/P_{\mathrm{orb}}$") if ymin: ax.set_ylim(ymin=ymin) if ymax: ax.set_ylim(ymax=ymax) if xmin: ax.set_xlim(xmin=xmin) if xmax: ax.set_xlim(xmax=xmax) ans.append((fig, axs)) ### coupling diagrams colormap = nmd.plt.get_cmap("jet") ### nl-placement disp if verbose: print "nl-placmenet disp" myE = -np.array([np.mean(_) for _ in nms.viscous_disp(q, network, Eo=1.0)[-1]]) mode_colors = [colormap(_) for _ in myE] mode_order = myE.argsort() fig = nmd.plt.figure() ax = fig.add_axes([0.1, 0.1, 0.750, 0.8]) cbax = fig.add_axes([0.875, 0.1, 0.025, 0.8]) fig, ax = nmd.coupling_tree_nl( system, tree_type="placement", genNos=[], verbose=verbose, mode_colors=mode_colors, mode_order=mode_order, fig_ax=(fig, ax), mode_nums=mode_nums, ) # colorbar = nmd.matplotlib.colorbar.ColorbarBase(cbax, cmap=colormap, orientation='vertical', norm=nmd.matplotlib.colors.LogNorm()) colorbar = nmd.matplotlib.colorbar.ColorbarBase(cbax, cmap=colormap, orientation="vertical") colorbar.ax.set_ylabel(r"$\gamma_i A_i^2/\mathrm{max}\{\gamma_i A_i^2\}$") ans.append((fig, ax, colorbar)) ### nl-placement E if verbose: print "nl-placement E" mE = np.array([np.mean(_) for _ in nms.compute_E(q, Eo=1.0)]) mode_colors = [colormap(_) for _ in mE / max(mE)] mode_order = mE.argsort() fig = nmd.plt.figure() ax = fig.add_axes([0.1, 0.1, 0.750, 0.8]) cbax = fig.add_axes([0.875, 0.1, 0.025, 0.8]) fig, ax = nmd.coupling_tree_nl( system, tree_type="placement", genNos=[], verbose=verbose, mode_colors=mode_colors, mode_order=mode_order, fig_ax=(fig, ax), mode_nums=mode_nums, ) # colorbar = nmd.matplotlib.colorbar.ColorbarBase(cbax, cmap=colormap, orientation='vertical', norm=nmd.matplotlib.colors.LogNorm()) colorbar = nmd.matplotlib.colorbar.ColorbarBase(cbax, cmap=colormap, orientation="vertical") colorbar.ax.set_ylabel(r"$A_i^2/\mathrm{max}\{A_i^2\}$") ans.append((fig, ax, colorbar)) ### nl-siblings gens for genNo in xrange(1, len(gens)): if verbose: print "nl-siblings gen%d" % genNo fig, ax = nmd.coupling_tree_nl( system, tree_type="siblings", genNos=[genNo], verbose=verbose, mode_nums=mode_nums ) ans.append((fig, ax)) return ans
################################################## if plots: if opts.tag: opts.tag += "_" rt_P1 = [t/system1.Porb for t in rt] n_l_m = [(n,l,m) for (n,l,m,s), i, j in common_nlms] if opts.verbose: print "generating plots" ### if opts.res: # plot the residuals if opts.verbose: print "\tres" fig, ax = nmp.amp_plot(rt_P1, r, n_l_m=n_l_m) ax.set_xlabel(r"$t/P_{\mathrm{orb}}^1$") ax.set_ylabel(r"$|r_i|$") ax.grid(opts.grid) if not opts.no_legend: ax.legend() figname = "%s/%sres.png" % (opts.output_dir, opts.tag) if opts.verbose: print "saving %s" % figname fig.savefig(figname) nmp.plt.close(fig) ### if opts.cross_correlation: # compute the cross-correlation between the data. This should be like function of the relative -time between sample points