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
if opts.eccentricity != 0: sys.exit("WARNING!: we currently only support eccentricity == 0 sytems") #################################################################################################### # # # generate a new network # (parent selection) # #################################################################################################### if opts.verbose: print "generating a new network (parent selection)" wo = ms.compute_wo(opts.Mprim, opts.Rprim) Oorb = 2*np.pi/opts.Porb system = networks.system(opts.Mprim, opts.Mcomp, opts.Rprim, opts.Porb, opts.eccentricity) network = system.network min_w = opts.parent_min_frac_Oorb*Oorb max_w = opts.parent_max_frac_Oorb*Oorb if opts.verbose: print "computing parent modes using %s" % opts.parent_selection if opts.parent_selection == "Elin": parents = ggg.compute_parents_Elin(Oorb, bounds, N=opts.num_parents, min_w=min_w, max_w=max_w, alpha=opts.alpha, c=opts.c, wo=wo, Mprim=opts.Mprim, Mcomp=opts.Mcomp, Porb=opts.Porb, eccentricity=opts.eccentricity) elif opts.parent_selection == "detuning": parents = ggg.compute_parents_detuning(Oorb, bounds, N=opts.num_parents, min_w=min_w, max_w=max_w, alpha=opts.alpha, c=opts.c, wo=wo, forcing=True, Mprim=opts.Mprim, Mcomp=opts.Mcomp, Porb=opts.Porb, eccentricity=opts.eccentricity) else: sys.exit("unknown parent selection algorithm: %s\nplease supply a parent selection algorithm from the following:\n\tEthr\n\tdetuning" % (opts.parent_selection) ) if opts.verbose: print "attempting to add %d parents to the network" % len(parents) network = network.add_modes(parents, verbose=opts.verbose)