예제 #1
0
def load_log(filename, enforce_float=False):
    """
  loads system from pickled file
  """
    import networks
    import gmodes, pmodes
    from mode_selection import compute_wo

    network = networks.network()

    f = open(filename, "r")

    Porb = pickle.load(f)
    eccentricity = pickle.load(f)
    Mprim = pickle.load(f)
    Mcomp = pickle.load(f)
    Rprim = pickle.load(f)

    wo = compute_wo(Mprim, Rprim)

    for mode_tuple, mode_type in pickle.load(f):
        if mode_type == "generic":
            mode = networks.mode().from_tuple(mode_tuple)
        elif mode_type == "gmode":
            mode = gmodes.gmode().from_tuple(mode_tuple, wo=wo)
        elif mode_type == "pmode":
            mode = pmodes.pmode().from_tuple(mode_tuple)
        else:
            sys.exit("unknown mode_type : %s" % mode_type)
        network.modes.append(mode)

    network.K = pickle.load(f)
    if enforce_float:
        network.K = [[(i, j, float(k)) for i, j, k in coup] for coup in network.K]
    network._update()

    f.close()

    system = networks.system(Mprim, Mcomp, Rprim, Porb, eccentricity, net=network)

    return system
예제 #2
0
						raise ValueError, "Mcomp mismatch"
					else:
						Mcomp = sdata["system"]["Mcomp/Mjup"]
			del clusters

		Edot_lin = []
		resonances = set()
		O = np.linspace(minO, maxO, opts.n_pts)
	        l = 2 ### dominant harmonic of the tide
	        m = 2
	        ecc = 0.0 ### take zero eccentricity limit
	        for o in O:
	                n_res = int(round(opts.alpha*l/(m*o), 0))
	                edot_lin = 0.0
	                for n in range(max(1, n_res-opts.n_lin), n_res+opts.n_lin):
	                        mode = gm.gmode(n=n, l=l, m=m, alpha=opts.alpha, c=opts.c, wo=wo)
	                        mode.compute_forcing(2*np.pi/o, ecc, opts.Mprim, Mcomp, opts.Rprim)
	                        w, y, U = mode.get_wyU()
	                        resonances.add( w/m )
	                        for u, k in U:
	                                edot_lin += 2*y*(w*u)**2 / ( (abs(w)-m*k*o)**2 + y**2 ) ### add linear result
	                Edot_lin.append( edot_lin )

		nmu.set_units(opts.unit_system)
		Eo = nmu.G*(opts.Mprim*nmu.Msun)**2 / (opts.Rprim*nmu.Rsun)

		Edot_lin = np.array(Edot_lin)*Eo

	        ### plot linear result
	        #ax.semilogy(O, Edot_lin, color='k', alpha=0.5)
	        iax.plot(nmu.convert_time((2*np.pi/O), nmu.units["time"], time_unit), Edot_lin, color='k', alpha=0.5)