예제 #1
0
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
예제 #2
0
            mA /= max(mA)

            mode_colors = [colormap(_) for _ in mA]
            mode_order = mA.argsort() # smallest values plotted first

          elif coloration == "E":
            if opts.verbose: print "\t\t coloration: E"
            mE = np.array([np.mean(_) for _ in nms.compute_E(q, Eo=1.0)])
            mE /= max(mE)

            mode_colors = [colormap(_) for _ in mE]
            mode_order = mE.argsort()

          elif coloration == "disp":
            if opts.verbose: print "\t\t coloration: disp"
            myE = np.array([-np.mean(_) for _ in nms.viscous_disp(q, network, Eo=1.0)[-1]])
            myE /= max(myE)

            mode_colors = [colormap(_) for _ in myE]
            mode_order = myE.argsort()

          else:
            if opts.verbose: print "\t\tcoloration \"%s\" not understood. skipping..." % coloration
            continue

          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=diagram_type.split("-")[-1], genNos=[int(l) for l in opts.coupling_diagram_genNos.split()], verbose=opts.verbose, mode_colors=mode_colors, mode_order=mode_order, fig_ax=(fig,ax))
          ax.grid(opts.grid, which="both")
예제 #3
0
        print "separating modes by collective Ethr:"
    collE_modeNos = {}
    for collE in opts.collE:
        if opts.verbose:
            print "\tcollE:", collE
        collE_modeNos[collE] = [
            [network.modeNoD[nlms] for nlms in _]
            for _ in pn.downselect_collE(collE, system, freqs=None, mode_nums=None)
        ]

        # =================================================
        ### plot data!
        # =================================================

        ### compute stuff for statistics
    myE = -np.array([np.mean(_) for _ in nms.viscous_disp(q, network, Eo=1.0)[-1]])
    myE /= sum(myE)
    mE = np.array([np.mean(_) for _ in nms.compute_E(q, Eo=1.0)])
    mE /= sum(mE)

    pkl_obj = {"myE": myE, "mE": mE}

    # === total data set
    if opts.plot:
        if opts.verbose:
            print "total data"
        tag = "" + opts.tag
        savefig(
            plot(t_P, q, system, gens, mode_nums=None, verbose=opts.vverbose, tc=opts.tc),
            opts.outfilename,
            opts.logfilename,
예제 #4
0
      sAsin_lag.append( nm_s.sample_var(A, xo=mAsin_lag[-1])**0.5 )
      lAsin_lag.append( A[-1] )
    del x
    msin_lag = []
    ssin_lag = []
    lsin_lag = []
    for A in xx:
      msin_lag.append( nm_s.sample_mean(A) )
      ssin_lag.append( nm_s.sample_var(A, xo=msin_lag[-1])**0.5 )
      lsin_lag.append( A[-1] )
    del xx
#    Asin_lag, sin_lag = nm_s.phase_lag(t_P, q, network, Eo=1.)

  if opts.yE:
    if opts.verbose: print "computing (viscous) energy disipation rates"
    x, xx = nm_s.viscous_disp(q, network, Eo=1.)
    mean_tot_yE = nm_s.sample_mean(x)
    var_tot_yE = nm_s.sample_var(x, xo=mean_tot_yE)
    del x
    myE = []
    syE = []
    lyE = []
    for A in xx:
      myE.append( nm_s.sample_mean(A) )
      syE.append( nm_s.sample_var(A, xo=myE[-1])**0.5 )
      lyE.append( A[-1] )
    del xx

    if opts.conc_fit:
      if opts.verbose: print "\tattempting to fit concentration diagram"
      myE_fp, myE_cvr, myE_rchi2 = nm_s.broken_PowLaw_fitter(range(opts.conc_fit_start+1, opts.conc_fit_stop+1), np.array(sorted(myE)[opts.conc_fit_start:opts.conc_fit_stop])/mean_tot_yE, np.ones((opts.conc_fit_stop-opts.conc_fit_start)), max_iters=opts.conc_fit_iters, rtol=opts.conc_fit_rtol, verbose=opts.conc_verbose)