def to_str(self): """ converts to standard string form for mode list ASCii files """ x, expx = nm_u.float_to_scientific(self.metric_value) k, expk = nm_u.float_to_scientific(self.k) return "%.14fe%d\t%s\t%s\t%.14fe%d" % (x, expx, self.dmode1.to_str_nlmwy(tuple=True), self.dmode2.to_str_nlmwy(tuple=True), k, expk)
def to_str_nlmwy(self, tuple=False): w, wexp = float_to_scientific(self.w) y, yexp = float_to_scientific(self.y) if tuple: return "(%d, %d, %d, %.14fe%d, %.14fe%d)" % (self.n, self.l, self.m, w, wexp, y, yexp) else: return "%d %d %d %.14fe%d %.14fe%d" % (self.n, self.l, self.m, w, wexp, y, yexp)
) # === Ethr if opts.verbose: print "Ethr" pkl_obj["Ethr"] = {} for ethr in sorted(ethr_modeNos.keys()): g, l = ethr_modeNos[ethr] pkl_obj["Ethr"][ethr] = [(g, sum(mE[g]), sum(myE[g])), (l, sum(mE[l]), sum(myE[l]))] if opts.verbose: print "\tEthr=", ethr, "\n\tN>=", len(g), "\n\t\tmE=", sum(mE[g]), "\n\t\tmyE=", sum( myE[g] ), "\n\tN<=", len(l), "\n\t\tmE=", sum(mE[l]), "\n\t\tmyE=", sum(myE[l]) if opts.plot: tag = "Ethr-g-%.3fe%d" % nmu.float_to_scientific(ethr) + opts.tag if opts.vverbose: print tag savefig( plot( t_P, q, system, gens, mode_nums=g, verbose=opts.vverbose, tc=opts.tc, xmin=opts.time_xmin, xmax=opts.time_xmax, ymin=opts.time_ymin, ymax=opts.time_ymax,
print "\n%f < t < %f" % rt[0], rt[-1] print "dt = %f" % rt[1]-rt[0] print "num samples = %d" % len(rt) ############################################################################################## # # compute and report individual statistics # ############################################################################################## print "Network Statistics:" if opts.liapunov: # compute the numerical value of the liapunov exponent: essentially fit residuals to an exponential (_, Ty_fit, Tchi2_red), (_, y_fit, chi2_red) = liapunov.nmode_liapunov_exp(rt, r) # network totals for each mode print "\ty_fit = %fe%d" % nmu.float_to_scientific(Ty_fit) print "\tchi2_red = %f" % Tchi2_red if opts.sum_sqr_err: # compute the sum-square-errors statistic tot_SSE, SSE = liapunov.sum_sqr_err(r) # these are normalized by the number of sample points print "\tsum{r**2}/len(r) = %fe%d" % nmu.float_to_scientific(tot_SSE) if opts.chi2: # compute the chi2 goodness of fit statistic Tchi2s, chi2s = liapunov.nmode_chi2(rq1, rq2) # returns the reduced chi2 goodness of fit test between the two time series print "\tchi2{rq1,rq2}/len(rq1) = %fe%d" % nmu.float_to_scientific(Tchi2s) if opts.inner_product: # compute the inner product of the data, normalized by the inner products of the separate time streams Tinner_prod, inner_prods = liapunov.nmode_inner_product(rq1, rq2) # standard definition of inner product in time domain
df_F : %f f_F[-1] : %f""" % (opts.freqfilename, opts.fcurrent, freq[0], freq[1]-freq[0], freq[-1]) ### add to pickle object if opts.pstefilename: sdata["freq_domain"] = {"frqfilename":opts.freqfilename, "var":opts.fcurrent, "f_F[0]":freq[0], "df_F":freq[1]-freq[0], "f_F[-1]":freq[-1]} ### print parameters of the system print >> stefile, """SYSTEM logfilename : %s Nmodes : %d Ngens : %d Ntriples : %d Mprim/Msun : %f Rprim/Rsun : %f Mcomp/Mjup : %f""" % (opts.logfilename, N_m, len(network.gens()[0]), len(network.to_triples()), Mprim, Rprim, Mcomp) _val, _valexp = nm_u.float_to_scientific(dimEo) print >> stefile, "\tEo : %fe%d %s" % (_val, _valexp, nm_u.units['energy']) _val, _valexp = nm_u.float_to_scientific(Porb) print >> stefile, "\tPorb : %fe%d %s" % (_val, _valexp, nm_u.units['time']) _val, _valexp = nm_u.float_to_scientific(Oorb) print >> stefile, "\tOorb : %fe%d rad/%s" % (_val, _valexp, nm_u.units['time']) print >> stefile, "\tecc : %f%d" % nm_u.float_to_scientific(system.eccentricity) _val, _valexp = nm_u.float_to_scientific(aorb) print >> stefile, "\taorb : %fe%d %s" % (_val, _valexp, nm_u.units['length']) _val, _valexp = nm_u.float_to_scientific(Eorb) print >> stefile, "\tEorb : %fe%d %s" % (_val, _valexp, nm_u.units['energy']) ### add to pickle object if opts.pstefilename: sdata["system"] = {"logfilename":opts.logfilename, "Nmodes":N_m, "Ngens":len(network.gens()[0]), "Ntriples":len(network.to_triples()), "Mprim/Msun":Mprim, "Rprim/Rsun":Rprim, "Mcomp/Mjup":Mcomp, "Eo":dimEo, "Porb":Porb, "ecc":system.eccentricity, "Eorb":Eorb, "Ngi":[len(gen) for gen in network.gens()[0]]} ### print network totals
#################################################################################################### if opts.verbose: print "downselecting a subset of modes based on integration data" if opts.verbose: print "reading in network parameters from %s" % opts.logfilename system = nm_u.load_log(opts.logfilename) network = system.network Oorb = system.Oorb Porb = 2*np.pi/Oorb if opts.verbose: print "reading time-domain data from %s" % opts.filename t_P, q, N_m = nm_u.load_out(opts.filename, tmin=opts.min_t_Porb, tmax=opts.max_t_Porb, downsample=opts.file_downsample) remove = [] for Athr, method in zip(Athrs, downselection_methods): if opts.verbose: _athr, _athrexp = nm_u.float_to_scientific(Athr) if method == "Alast": if opts.verbose: print "downselecting modes using %s and Athr=%fe%d" % (method, _athr, _athrexp) remove += pn.downselect_Alast(q, Athr, network)[1] elif method == "Amean": if opts.verbose: print "downselecting modes using %s and Athr=%fe%d" % (method, _athr, _athrexp) remove += pn.downselect_Amean(q, Athr, network)[1] elif method == "Afit": if opts.verbose: print "downselecting modes using %s and Athr=%fe%d" % (method, _athr, _athrexp) remove += pn.downselect_Afit(q, Athr, network, t_P=t_P)[1] else: raise ValueError, "unknown downselection method: %s\nplease supply at last one downselection method from the following:\n\tAlst\n\tAmean\n\tAfit" remove = list(set(remove)) # generate a unique set of modes to remove if opts.verbose: print "attempting to remove %d/%d modes from the network" % (len(remove), N_m)