Esempio n. 1
0
	def get_Mprim(self, unit_system="SI"):
		nmu.set_units(system=unit_system)
		mass_unit = nmu.units["mass"]

		Mprime = []
		for sdata, _ in self.data:
			nmu.set_units(sdata["unit_system"])
			Mprime.append( nmu.convert_mass(sdata["system"]["Mprim/Msun"]*nmu.Msun, nmu.units["mass"], mass_unit) )
		return Mprime
Esempio n. 2
0
	def get_Mcomp(self, unit_system="SI"):
		nmu.set_units(system=unit_system)
		mass_unit = nmu.units["mass"]

		Mcomp = []
		for sdata, _ in self.data:
			Mcomp.append( sdata["system"]["Mcomp/Mjup"]*nmu.Mjup )

		return Mcomp
Esempio n. 3
0
	def get_Rprim(self, unit_system="SI"):
		nmu.set_units(system=unit_system)
		length_unit = nmu.units["length"]

		Rprime = []
		for sdata, _ in self.data:
			nmu.set_units(sdata["unit_system"])
			Rprime.append( nmu.convert_length(sdata["system"]["Rprim/Rsun"]*nmu.Rsun, nmu.units["length"], length_unit) )
		return Rprime
Esempio n. 4
0
	def get_Eorb(self, unit_system="SI"):
		nmu.set_units(system=unit_system)
		energy_unit = nmu.units["energy"]

		Eorb = []
		for sdata, _ in self.data:
			nmu.set_units(sdata["unit_system"])
			Eorb.append( nmu.convert_energy(sdata["system"]["Eorb"], nmu.units["energy"], energy_unit) )

		return Eorb
Esempio n. 5
0
	def get_Porb(self, unit_system="SI"):
		nmu.set_units(system=unit_system)
		energy_unit = nmu.units["energy"]
		time_unit = nmu.units["time"]
		
		Porb = []
		for sdata, _ in self.data:
			nmu.set_units(sdata["unit_system"])
			Porb.append( nmu.convert_time(sdata["system"]["Porb"], nmu.units["time"], time_unit) )

		return Porb
Esempio n. 6
0
	def get_E(self, unit_system="SI"):
                nmu.set_units(system=unit_system)
                energy_unit = nmu.units["energy"]

                mE = []
		sE = []
                for sdata, _ in self.data:
                        nmu.set_units(sdata["unit_system"])

			Eorb = nmu.convert_energy(abs(sdata["system"]["Eorb"]), nmu.units["energy"], energy_unit)
			mE.append( sdata["stats"]["mean{sum{E}/|Eorb|}"] * Eorb )
			sE.append( sdata["stats"]["stdv{sum{E}/|Eorb|}"] * Eorb )

                return mE, sE
Esempio n. 7
0
	def get_Edot(self, unit_system="SI"):
		nmu.set_units(system=unit_system)
		energy_unit = nmu.units["energy"]
		time_unit = nmu.units["time"]
		
		mEdot = []
		sEdot = []
		for sdata, _ in self.data:
			nmu.set_units(sdata["unit_system"])

			Eorb = nmu.convert_energy(abs(sdata["system"]["Eorb"]), nmu.units["energy"], energy_unit)
			porb = nmu.convert_time(sdata["system"]["Porb"], nmu.units["time"], time_unit)

			mEdot.append( sdata["stats"]["mean{|sum{Edot}|*(Porb/|Eorb|)}"] * Eorb/porb )		
			sEdot.append( sdata["stats"]["stdv{|sum{Edot}|*(Porb/|Eorb|)}"] * Eorb/porb )
	
		return mEdot, sEdot
Esempio n. 8
0
parser.add_option("", "--legend", default=False, action="store_true")

parser.add_option("", "--time-unit", default=False, type="string")

parser.add_option("", "--Mprim", default=1.0, type="float")
parser.add_option("", "--Rprim", default=1.0, type="float")
parser.add_option("", "--n-lin", default=10, type="int", help="number of modes to include in computation of linear dampling rates")
parser.add_option("", "--n-pts", default=1001, type="int", help="the number of points used to construct the linear dampoing rates curve and to draw the fit curves for averaged data")
parser.add_option("", "--alpha", default=4e-3, type="float")
parser.add_option("", "--c", default=2e-11, type="float")

parser.add_option("", "--maxPorb", default=np.infty, type="float")

opts, args = parser.parse_args()

nmu.set_units(system=opts.unit_system) ### set our system of units
energy_unit = nmu.units["energy"]
if opts.time_unit:
	time_unit = opts.time_unit
else:
	time_unit = nmu.units["time"]

if opts.tag:
	opts.tag = "_%s"%opts.tag

opts.clusters = [l.split(",") for l in opts.clusters]

opts.verbose = opts.verbose or opts.vverbose

#=================================================
if opts.Edot:
Esempio n. 9
0
parser.add_option("", "--D1-plots", default=False, action="store_true", help="attempts to build linear plots with annotations for all available statistics")
parser.add_option("", "--D2-plots", default=False, action="store_true", help="attempts to build plots of statistics vs. Nmodes, Ngens, Ntriples")
parser.add_option("", "--D2-bokeh", default=False, action="store_true")

parser.add_option("", "--special-plots", default=False, action="store_true", help="generate plots that do not neatly fall in the D1, D2 catagories")

parser.add_option("", "--unit-system", default="CGS", type="string", help="system of units to use. \"SI\" or \"CGS\" (default)")

parser.add_option("-t", "--tag", default="", type="string")

opts, args = parser.parse_args()

if opts.tag != "":
  opts.tag = "."+opts.tag

nmu.set_units(system=opts.unit_system)
units_time = nmu.units["time"]
units_energy = nmu.units["energy"]

####################################################################################################
#
# find and read in data
#
####################################################################################################
### find list of logs
if opts.cachefilename:
  if opts.verbose: print "reading in filenames from "+opts.cachefilename
  cachefile = open(opts.cachefilename, "r")
  filenames = sorted( [l.strip() for l in cachefile.readlines() ])
  cachefile.close()
else:
Esempio n. 10
0
def harmonic_average(cluster, key, unit_system="SI"):
        """
        computes the harmonic average over the data within cluster
        we compute <Edot> = int dt Edot / int dt
        but we take the integral over Porb, so changing the integration variable to Porb yields

        <Edot> = int dP ( E/P * Edot**-1) * key / int dP ( E/P * Edot**-1 )

        ASSUMES spacing is even in Porb-space (within each cluster!), so the integral's measure drops out
        """
        nmu.set_units(unit_system)
        time_unit = nmu.units["time"]
        energy_unit = nmu.units["energy"]

	P = []
	E = []
	mEdot = []
	sEdot = []
	x = []
	sx = []

	for sdata, mdata in cluster.data:
		nmu.set_units(sdata["unit_system"])

		### convertion to Porb measure
		Porb = nmu.convert_time(sdata["system"]["Porb"], nmu.units["time"], time_unit)
		Eorb = nmu.convert_energy(sdata["system"]["Eorb"], nmu.units["energy"], energy_unit)

		P.append( Porb )
		E.append( Eorb )

		mEdot.append( sdata["stats"]["mean{|sum{Edot}|*(Porb/|Eorb|)}"] * Eorb/Porb )
		sEdot.append( sdata["stats"]["stdv{|sum{Edot}|*(Porb/|Eorb|)}"] * Eorb/Porb )

		if key == "Edot":
			x.append( sdata["stats"]["mean{|sum{Edot}|*(Porb/|Eorb|)}"] * Eorb/Porb )
			sx.append( sdata["stats"]["stdv{|sum{Edot}|*(Porb/|Eorb|)}"] * Eorb/Porb )
		elif key == "E":
			x.append( sdata["stats"]["mean{sum{E}/|Eorb|}"] * Eorb )
			sx.append( sdata["stats"]["stdv{sum{E}/|Eorb|}"] * Eorb )
		else:
			raise KeyError, "key=%s not understood"%key

	### cast to arrays
	P = np.array(P)
	E = np.array(E)
	mEdot = np.array(mEdot)
	sEdot = np.array(sEdot)
	x = np.array(x)
	sx = np.array(sx)

	### compute averages
	integrand = Eorb/(Porb*mEdot)

	num = np.sum( integrand * x )
	den = np.sum( integrand )

	p = np.sum( integrand * P )

	mx = num/den
	mp = p/den

	### compute uncertainties
	T = np.sum( integrand )
	integrate = E/(P*mEdot**2)
	a = np.sum( integrand**2 * sx**2 ) / T**2
	b = np.sum( (integrate * ( x*T - np.sum( x*integrand) ))**2 * sEdot**2 ) / T**4

	smx = a + b ### uncertainty in x
	smp = np.sum( (integrate * ( P*T - np.sum( P*integrand) ))**2 * sEdot**2 ) / T**4 ### uncertainty in p


	return (mx, smx**0.5) , (mp, smp**0.5)


	'''