Пример #1
0
def Ameanvar(q, mode_nums=None):
  """
  returns 2 dictionaries:
    key, value = modeNo, mean{A}
    key, value = modeNo, stdv{A}
  """
  if not mode_nums:
    mode_nums = range(len(q))

  A = nm_s.compute_A(q)
  n = len(A[0])
  Am = [1.0*sum(Ai)/n for Ai in A]
  As = [(1.0*sum((Ai-Aim)**2)/(n-1))**0.5 for Ai, Aim in zip(A, Am)]

  return dict( (modeNo, Am[modeNo]) for modeNo in mode_nums ), dict( (modeNo, As[modeNo]) for modeNo in num_modes )
Пример #2
0
      if opts.verbose: print "saving "+figname
      fig.savefig(figname)
      nmd.plt.close(fig)

    elif "nl-" in diagram_type: ### a class of diagrams
      if opts.verbose: print "\t building coupling_diagaram \"%s\"" % diagram_type
      if opts.coupling_diagram_coloration:

        ### define colormap
        colormap = nmd.plt.get_cmap(opts.coupling_diagram_colormap)

        ### compute colors for each mode based on coloration scheme
        for coloration in opts.coupling_diagram_coloration:
          if coloration == "A":
            if opts.verbose: print "\t\t coloration: A"
            mA = np.array([np.mean(_) for _ in nms.compute_A(q, Eo=1.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"
Пример #3
0
if children.has_key("max_frac_w"):
  daughter_max_frac_w = float(children["max_frac_w"])
else:
  daughter_max_frac_w = 0.9
  if opts.verbose: print "using DEFAULT daughter_max_frac_w=%.3f"%daughter_max_frac_w

parent_forcing = config.getboolean("inclusion","parent_forcing")
daughter_forcing = config.getboolean("inclusion","daughter_forcing")
intercouple = config.getboolean("inclusion","intercouple")
to_unique_couplings = config.getboolean("inclusion","to_unique_couplings")

### compute the threshold energies only once.
if daughter_selection == "collective":
  if opts.verbose: print "reading in integration data from %s and computing energies" % opts.outfilename
  E = [np.mean(a)**2 for a in nm_s.compute_A(nm_u.load_out(opts.outfilename)[1], Eo=1.0)] # growth rate depends on amplitude, so that's what we should average (not energy)
  
new_systems = [copy.deepcopy(system) for npairs in num_pairs]

# iterate over new parents
n_modes = len(modes)
for n_m, (O, mode) in enumerate(modes):
  n, l, m, w, y = mode.get_nlmwy()
  if opts.verbose: print "%d / %d :finding daughter modes\n\tfor mode: %s\n\toscillating at %fe-5 rad/%s\n\tusing %s" % (n_m+1, n_modes, mode.to_str_nlmwy(), O*1e5, nm_u.units['time'], daughter_selection)

  absO = abs(O)
  signO = O/absO
  min_w = daughter_min_frac_w*absO
  max_w = daughter_max_frac_w*absO

  if daughter_selection == "collective":  ### collective modes
Пример #4
0
#
#
#                                  time domain
#
#
####################################################################################################
if time_domain:
  if opts.verbose: print "loading time-domain data from %s" % opts.filename
  t_P, q, N_m = nm_u.load_out(opts.filename, tmin=opts.tmin, tmax=opts.tmax, downsample=opts.tdownsample)

  if not len(t_P):
    raise ValueError, "no data loaded from "+opts.filename

  if opts.amplitude:
    if opts.verbose: print "computing mode amplitudes"
    x = nm_s.compute_A(q, Eo=1.)
    mA = []
    sA = []
    lA = []
    for A in x:
      mA.append( nm_s.sample_mean(A) )
      sA.append( nm_s.sample_var(A, xo=mA[-1])**0.5 )
      lA.append( A[-1] )
    del x

    x = nm_s.compute_E(q, Eo=1.)
    mE = []
    sE = []
    lE = []
    totE = [sum([x[modeNo][i] for modeNo in range(N_m)]) for i in range(len(t_P))]
    mean_tot_E = nm_s.sample_mean(totE)