本文整理汇总了Python中astropy.constants.M_sun方法的典型用法代码示例。如果您正苦于以下问题:Python constants.M_sun方法的具体用法?Python constants.M_sun怎么用?Python constants.M_sun使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.constants
的用法示例。
在下文中一共展示了constants.M_sun方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stellar_info
# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import M_sun [as 别名]
def stellar_info(chain, data):
"""
computes stellar masses and SFRs
"""
gal_do, irlum_dict, nh_dict, BBebv_dict, SFRdict = data.dictkey_arrays #call dictionary info
#relevanta parameters form the MCMC chain
tau_mcmc = chain[:,0]
age_mcmc = chain[:,1]
GA = chain[:,6] - 18. #1e18 is the common normalization factor used in parspace.ymodel in order to have comparable NORMfactors
z = data.z
distance = z2Dlum(z)
#constants
solarlum = const.L_sun.to(u.erg/u.second) #3.839e33
solarmass = const.M_sun
Mstar_list=[]
SFR_list=[]
for i in range (len (tau_mcmc)):
N = 10**GA[i]* 4* pi* distance**2 / (solarlum.value)/ (1+z)
gal_do.nearest_par2dict(tau_mcmc[i], 10**age_mcmc[i], 0.)
tau_dct, age_dct, ebvg_dct=gal_do.t, gal_do.a,gal_do.e
SFR_mcmc =SFRdict[tau_dct, age_dct]
# Calculate Mstar. BC03 templates are normalized to M* = 1 M_sun.
# Thanks to Kenneth Duncan, and his python version of BC03, smpy
Mstar = np.log10(N * 1)
#Calculate SFR. output is in [Msun/yr].
SFR = N * SFR_mcmc
SFR_list.append(SFR.value)
Mstar_list.append(Mstar)
return np.array(Mstar_list) , np.array(SFR_list)
示例2: distForces
# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import M_sun [as 别名]
def distForces(self, TL, sInd, currentTime):
"""Finds lateral and axial disturbance forces on an occulter
Args:
TL (TargetList module):
TargetList class object
sInd (integer):
Integer index of the star of interest
currentTime (astropy Time):
Current absolute mission time in MJD
Returns:
tuple:
dF_lateral (astropy Quantity):
Lateral disturbance force in units of N
dF_axial (astropy Quantity):
Axial disturbance force in units of N
"""
# get spacecraft position vector
r_obs = self.orbit(currentTime)[0]
# sun -> earth position vector
r_Es = self.solarSystem_body_position(currentTime, 'Earth')[0]
# Telescope -> target vector and unit vector
r_targ = TL.starprop(sInd, currentTime)[0] - r_obs
u_targ = r_targ.to('AU').value/np.linalg.norm(r_targ.to('AU').value)
# sun -> occulter vector
r_Os = r_obs.to('AU') + self.occulterSep.to('AU')*u_targ
# Earth-Moon barycenter -> spacecraft vectors
r_TE = r_obs - r_Es
r_OE = r_Os - r_Es
# force on occulter
Mfactor = -self.scMass*const.M_sun*const.G
F_sO = r_Os/(np.linalg.norm(r_Os.to('AU').value)*r_Os.unit)**3. * Mfactor
F_EO = r_OE/(np.linalg.norm(r_OE.to('AU').value)*r_OE.unit)**3. * Mfactor/328900.56
F_O = F_sO + F_EO
# force on telescope
Mfactor = -self.coMass*const.M_sun*const.G
F_sT = r_obs/(np.linalg.norm(r_obs.to('AU').value)*r_obs.unit)**3. * Mfactor
F_ET = r_TE/(np.linalg.norm(r_TE.to('AU').value)*r_TE.unit)**3. * Mfactor/328900.56
F_T = F_sT + F_ET
# differential forces
dF = F_O - F_T*self.scMass/self.coMass
dF_axial = (dF.dot(u_targ)).to('N')
dF_lateral = (dF - dF_axial*u_targ).to('N')
dF_lateral = np.linalg.norm(dF_lateral.to('N').value)*dF_lateral.unit
dF_axial = np.abs(dF_axial)
return dF_lateral, dF_axial