当前位置: 首页>>代码示例>>Python>>正文


Python constants.G属性代码示例

本文整理汇总了Python中astropy.constants.G属性的典型用法代码示例。如果您正苦于以下问题:Python constants.G属性的具体用法?Python constants.G怎么用?Python constants.G使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在astropy.constants的用法示例。


在下文中一共展示了constants.G属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_period_semi

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def test_period_semi():
    # Check that an error is raised if neither a nor porb is given
    with pytest.raises(ValueError) as e:
        body = starry.Secondary(starry.Map())
    assert "Must provide a value for either `porb` or `a`" in str(e.value)

    # Check that the semi --> period conversion works
    pri = starry.Primary(starry.Map(), m=1.0, mass_unit=u.Msun)
    sec = starry.Secondary(
        starry.Map(), a=10.0, m=1.0, length_unit=u.AU, mass_unit=u.Mearth
    )
    sys = starry.System(pri, sec)
    period = sys._get_periods()[0]
    true_period = (
        (
            (2 * np.pi)
            * (sec.a * sec.length_unit) ** (3 / 2)
            / (np.sqrt(G * (pri.m * pri.mass_unit + sec.m * sec.mass_unit)))
        )
        .to(u.day)
        .value
    )
    assert np.allclose(period, true_period) 
开发者ID:rodluger,项目名称:starry,代码行数:25,代码来源:test_units.py

示例2: test_critical_density

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def test_critical_density():
    from astropy.constants import codata2014

    # WMAP7 but with Omega_relativistic = 0
    # These tests will fail if astropy.const starts returning non-mks
    #  units by default; see the comment at the top of core.py.
    # critical_density0 is inversely proportional to G.
    tcos = core.FlatLambdaCDM(70.4, 0.272, Tcmb0=0.0)
    fac = (const.G / codata2014.G).to(u.dimensionless_unscaled).value
    assert allclose(tcos.critical_density0 * fac,
                    9.309668456020899e-30 * (u.g / u.cm**3))
    assert allclose(tcos.critical_density0,
                    tcos.critical_density(0))
    assert allclose(
        tcos.critical_density([1, 5]) * fac,
        [2.70352772e-29, 5.53739080e-28] * (u.g / u.cm**3))
    assert allclose(
        tcos.critical_density([1., 5.]) * fac,
        [2.70352772e-29, 5.53739080e-28] * (u.g / u.cm**3)) 
开发者ID:holzschu,项目名称:Carnets,代码行数:21,代码来源:test_cosmology.py

示例3: test_complex_fractional_rounding_errors

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def test_complex_fractional_rounding_errors():
    # See #3788

    kappa = 0.34 * u.cm**2 / u.g
    r_0 = 886221439924.7849 * u.cm
    q = 1.75
    rho_0 = 5e-10 * u.solMass / u.solRad**3
    y = 0.5
    beta = 0.19047619047619049
    a = 0.47619047619047628
    m_h = 1e6*u.solMass

    t1 = 2 * c.c / (kappa * np.sqrt(np.pi))
    t2 = (r_0**-q) / (rho_0 * y * beta * (a * c.G * m_h)**0.5)

    result = ((t1 * t2)**-0.8)

    assert result.unit.physical_type == 'length'
    result.to(u.solRad) 
开发者ID:holzschu,项目名称:Carnets,代码行数:21,代码来源:test_units.py

示例4: __init__

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def __init__(self, smaknee=30, esigma=0.175/np.sqrt(np.pi/2.), 
            prange=[0.083, 0.882], Rprange=[1, 22.6], **specs):
        
        specs['prange'] = prange
        specs['Rprange'] = Rprange
        PlanetPopulation.__init__(self, **specs)
        
        # calculate norm for sma distribution with decay point (knee)
        self.smaknee = float(smaknee)
        ar = self.arange.to('AU').value
        # sma distribution without normalization
        tmp_dist_sma = lambda x,s0=self.smaknee: x**(-0.62)*np.exp(-(x/s0)**2)
        self.smanorm = integrate.quad(tmp_dist_sma, ar[0], ar[1])[0]
        
        # calculate norm for eccentricity Rayleigh distribution 
        self.esigma = float(esigma)
        er = self.erange
        self.enorm = np.exp(-er[0]**2/(2.*self.esigma**2)) \
                - np.exp(-er[1]**2/(2.*self.esigma**2))
        
        # define Kepler radius distribution
        Rs = np.array([1,1.4,2.0,2.8,4.0,5.7,8.0,11.3,16,22.6]) #Earth Radii
        Rvals85 = np.array([0.1555,0.1671,0.1739,0.0609,0.0187,0.0071,0.0102,0.0049,0.0014])
        #sma of 85 days
        a85 = ((85.*u.day/2./np.pi)**2*u.solMass*const.G)**(1./3.)
        # sma of 0.8 days (lower limit of Fressin et al 2012)
        a08 = ((0.8*u.day/2./np.pi)**2*u.solMass*const.G)**(1./3.) 
        fac1 = integrate.quad(tmp_dist_sma, a08.to('AU').value, a85.to('AU').value)[0]
        Rvals = integrate.quad(tmp_dist_sma, ar[0], ar[1])[0]*(Rvals85/fac1)
        Rvals[5:] *= 2.5 #account for longer orbital baseline data
        self.Rs = Rs
        self.Rvals = Rvals
        self.eta = np.sum(Rvals)
        
        # populate outspec with attributes specific to KeplerLike1
        self._outspec['smaknee'] = self.smaknee
        self._outspec['esigma'] = self.esigma
        self._outspec['eta'] = self.eta
        
        self.dist_albedo_built = None 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:42,代码来源:KeplerLike1.py

示例5: dump_systems

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def dump_systems(self):
        """Create a dictionary of planetary properties for archiving use.
        
        Args:
            None
        
        Returns:
            systems (dict):
                Dictionary of planetary properties
        
        """
        
        systems = {'a':self.a,
               'e':self.e,
               'I':self.I,
               'O':self.O,
               'w':self.w,
               'M0':self.M0,
               'Mp':self.Mp,
               'mu':(const.G*(self.Mp + self.TargetList.MsTrue[self.plan2star])).decompose(),
               'Rp':self.Rp,
               'p':self.p,
               'plan2star':self.plan2star,
               'star':self.TargetList.Name[self.plan2star]}
        if not self.commonSystemInclinations == None:
            systems['starI'] = self.TargetList.I
        if self.ZodiacalLight.commonSystemfEZ:
            systems['starnEZ'] = self.ZodiacalLight.nEZ
        
        return systems 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:32,代码来源:SimulatedUniverse.py

示例6: test_compose_into_arbitrary_units

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def test_compose_into_arbitrary_units():
    # Issue #1438
    from astropy.constants import G
    G.decompose([u.kg, u.km, u.Unit("15 s")]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:6,代码来源:test_units.py

示例7: test_fractional_powers

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def test_fractional_powers():
    """See #2069"""
    m = 1e9 * u.Msun
    tH = 1. / (70. * u.km / u.s / u.Mpc)
    vc = 200 * u.km/u.s

    x = (c.G ** 2 * m ** 2 * tH.cgs) ** Fraction(1, 3) / vc
    v1 = x.to('pc')

    x = (c.G ** 2 * m ** 2 * tH) ** Fraction(1, 3) / vc
    v2 = x.to('pc')

    x = (c.G ** 2 * m ** 2 * tH.cgs) ** (1.0 / 3.0) / vc
    v3 = x.to('pc')

    x = (c.G ** 2 * m ** 2 * tH) ** (1.0 / 3.0) / vc
    v4 = x.to('pc')

    assert_allclose(v1, v2)
    assert_allclose(v2, v3)
    assert_allclose(v3, v4)

    x = u.m ** (1.0 / 101.0)
    assert isinstance(x.powers[0], float)

    x = u.m ** (3.0 / 7.0)
    assert isinstance(x.powers[0], Fraction)
    assert x.powers[0].numerator == 3
    assert x.powers[0].denominator == 7

    x = u.cm ** Fraction(1, 2) * u.cm ** Fraction(2, 3)
    assert isinstance(x.powers[0], Fraction)
    assert x.powers[0] == Fraction(7, 6)

    # Regression test for #9258.
    x = (u.TeV ** (-2.2)) ** (1/-2.2)
    assert isinstance(x.powers[0], Fraction)
    assert x.powers[0] == Fraction(1, 1) 
开发者ID:holzschu,项目名称:Carnets,代码行数:40,代码来源:test_units.py

示例8: promote_coro_targets

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def promote_coro_targets(self, occ_sInds, sInds):
        """
        Determines which coronograph targets to promote to occulter targets

        Args:
            occ_sInds (numpy array):
                occulter targets
            sInds (numpy array):
                coronograph targets

        Returns:
            occ_sInds (numpy array):
                updated occulter targets
        """
        TK = self.TimeKeeping
        SU = self.SimulatedUniverse
        TL = self.TargetList
        promoted_occ_sInds = np.array([], dtype=int)

        # if phase 1 has ended
        if TK.currentTimeAbs > self.phase1_end:
            if self.is_phase1 is True:
                self.vprint( 'Entering detection phase 2: target list for occulter expanded')
                self.is_phase1 = False
            # If we only want to promote stars that have planets in the habitable zone
            if self.promote_hz_stars:
                # stars must have had > n_det_min detections
                promote_stars = sInds[np.where(self.sInd_detcounts[sInds] > self.n_det_min)[0]]
                if np.any(promote_stars):
                    for sInd in promote_stars:
                        pInds = np.where(SU.plan2star == sInd)[0]
                        sp = SU.s[pInds]
                        Ms = TL.MsTrue[sInd]
                        Mp = SU.Mp[pInds]
                        mu = const.G*(Mp + Ms)
                        T = (2.*np.pi*np.sqrt(sp**3/mu)).to('d')
                        # star must have detections that span longer than half a period and be in the habitable zone
                        # and have a smaller radius that a sub-neptune
                        pinds_earthlike = self.is_earthlike(pInds, sInd)
                        if (np.any((T/2.0 < (self.sInd_dettimes[sInd][-1] - self.sInd_dettimes[sInd][0]))) and np.any(pinds_earthlike)) \
                          or ((self.sInd_detcounts[sInd] >= self.nmax_promo_det) and np.any(pinds_earthlike)):
                            earthlikes = pInds[pinds_earthlike]
                            self.known_earths = np.union1d(self.known_earths, earthlikes).astype(int)
                            promoted_occ_sInds = np.append(promoted_occ_sInds, sInd)
                            if sInd not in self.promoted_stars:
                                self.promoted_stars.append(sInd)
                occ_sInds = np.union1d(occ_sInds, promoted_occ_sInds)
            else:
                occ_sInds = np.union1d(occ_sInds, sInds[np.where((self.starVisits[sInds] == self.nVisitsMax) & 
                                                                 (self.occ_starVisits[sInds] == 0))[0]])
        occ_sInds = np.union1d(occ_sInds, np.intersect1d(sInds, self.known_rocky))
        self.promoted_stars = list(np.union1d(self.promoted_stars, np.intersect1d(sInds, self.known_rocky)).astype(int))
        return(occ_sInds.astype(int)) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:55,代码来源:tieredScheduler_SLSQP.py

示例9: scheduleRevisit

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def scheduleRevisit(self, sInd, smin, det, pInds):
        """A Helper Method for scheduling revisits after observation detection

        Args:
            sInd - sInd of the star just detected
            smin - minimum separation of the planet to star of planet just detected
            det - 
            pInds - Indices of planets around target star
        Return:
            updates self.starRevisit attribute
        """
        TK = self.TimeKeeping
        TL = self.TargetList
        SU = self.SimulatedUniverse
        # in both cases (detection or false alarm), schedule a revisit 
        # based on minimum separation
        Ms = TL.MsTrue[sInd]
        if smin is not None and np.nan not in smin: #smin is None if no planet was detected
            sp = smin
            if np.any(det):
                pInd_smin = pInds[det][np.argmin(SU.s[pInds[det]])]
                Mp = SU.Mp[pInd_smin]
            else:
                Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm.copy() + T/2.
        # otherwise, revisit based on average of population semi-major axis and mass
        else:
            sp = SU.s.mean()
            Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm.copy() + 0.75*T
        # if no detections then schedule revisit based off of revisit_wait
        t_rev = TK.currentTimeNorm.copy() + self.revisit_wait[sInd]
        # finally, populate the revisit list (NOTE: sInd becomes a float)
        revisit = np.array([sInd, t_rev.to('day').value])
        if self.starRevisit.size == 0:#If starRevisit has nothing in it
            self.starRevisit = np.array([revisit])#initialize sterRevisit
        else:
            revInd = np.where(self.starRevisit[:,0] == sInd)[0]#indices of the first column of the starRevisit list containing sInd 
            if revInd.size == 0:
                self.starRevisit = np.vstack((self.starRevisit, revisit))
            else:
                self.starRevisit[revInd,1] = revisit[1]#over 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:48,代码来源:tieredScheduler_SLSQP.py

示例10: scheduleRevisit

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def scheduleRevisit(self, sInd, smin, det, pInds):
        """A Helper Method for scheduling revisits after observation detection
        Args:
            sInd - sInd of the star just detected
            smin - minimum separation of the planet to star of planet just detected
            det - 
            pInds - Indices of planets around target star
        Return:
            updates self.starRevisit attribute
        """
        TK = self.TimeKeeping
        TL = self.TargetList
        SU = self.SimulatedUniverse

        # in both cases (detection or false alarm), schedule a revisit 
        # based on minimum separation
        Ms = TL.MsTrue[sInd]
        if smin is not None and smin is not np.nan: #smin is None if no planet was detected
            sp = smin
            if np.any(det):
                pInd_smin = pInds[det][np.argmin(SU.s[pInds[det]])]
                Mp = SU.Mp[pInd_smin]
            else:
                Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm.copy() + T/2.
        # otherwise, revisit based on average of population semi-major axis and mass
        else:
            sp = SU.s.mean()
            Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm.copy() + 0.75*T

        # if no detections then schedule revisit based off of revisit_weight
        if not np.any(det):
            t_rev = TK.currentTimeNorm.copy() + self.revisit_wait
            self.no_dets[sInd] = True
        else:
            self.no_dets[sInd] = False

        t_rev = TK.currentTimeNorm.copy() + self.revisit_wait
        # finally, populate the revisit list (NOTE: sInd becomes a float)
        revisit = np.array([sInd, t_rev.to('day').value])
        if self.starRevisit.size == 0:#If starRevisit has nothing in it
            self.starRevisit = np.array([revisit])#initialize sterRevisit
        else:
            revInd = np.where(self.starRevisit[:,0] == sInd)[0]#indices of the first column of the starRevisit list containing sInd 
            if revInd.size == 0:
                self.starRevisit = np.vstack((self.starRevisit, revisit))
            else:
                self.starRevisit[revInd,1] = revisit[1]#over 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:55,代码来源:linearJScheduler_sotoSS.py

示例11: scheduleRevisit

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def scheduleRevisit(self, sInd, smin, det, pInds):
        """A Helper Method for scheduling revisits after observation detection
        Args:
            sInd - sInd of the star just detected
            smin - minimum separation of the planet to star of planet just detected
            det - 
            pInds - Indices of planets around target star
        Return:
            updates self.starRevisit attribute
        """
        TK = self.TimeKeeping
        TL = self.TargetList
        SU = self.SimulatedUniverse
        # in both cases (detection or false alarm), schedule a revisit 
        # based on minimum separation
        Ms = TL.MsTrue[sInd]
        if smin is not None and smin is not np.nan: #smin is None if no planet was detected
            sp = smin
            if np.any(det):
                pInd_smin = pInds[det][np.argmin(SU.s[pInds[det]])]
                Mp = SU.Mp[pInd_smin]
            else:
                Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm + T/2.
        # otherwise, revisit based on average of population semi-major axis and mass
        else:
            sp = SU.s.mean()
            Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm + 0.75*T

        t_rev = TK.currentTimeNorm.copy() + self.revisit_wait
        # finally, populate the revisit list (NOTE: sInd becomes a float)
        revisit = np.array([sInd, t_rev.to('day').value])
        if self.starRevisit.size == 0:#If starRevisit has nothing in it
            self.starRevisit = np.array([revisit])#initialize starRevisit
        else:
            revInd = np.where(self.starRevisit[:,0] == sInd)[0]#indices of the first column of the starRevisit list containing sInd
            if revInd.size == 0:
                self.starRevisit = np.vstack((self.starRevisit, revisit))
            else:
                self.starRevisit[revInd,1] = revisit[1]#over 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:47,代码来源:linearJScheduler_det_only.py

示例12: promote_coro_targets

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def promote_coro_targets(self, occ_sInds, sInds):
        """
        Determines which coronograph targets to promote to occulter targets

        Args:
            occ_sInds (numpy array):
                occulter targets
            sInds (numpy array):
                coronograph targets

        Returns:
            occ_sInds (numpy array):
                updated occulter targets
        """

        TK = self.TimeKeeping
        SU = self.SimulatedUniverse
        TL = self.TargetList
        promoted_occ_sInds = np.array([], dtype=int)

        # if phase 1 has ended
        if TK.currentTimeAbs > self.phase1_end:
            if self.is_phase1 is True:
                self.vprint('Entering detection phase 2: target list for occulter expanded')
                self.is_phase1 = False
            # If we only want to promote stars that have planets in the habitable zone
            if self.promote_hz_stars:
                # stars must have had >= n_det_min detections
                promote_stars = sInds[np.where(self.sInd_detcounts[sInds] >= self.n_det_min)[0]]
                if np.any(promote_stars):
                    for sInd in promote_stars:
                        pInds = np.where(SU.plan2star == sInd)[0]
                        sp = SU.s[pInds]
                        Ms = TL.MsTrue[sInd]
                        Mp = SU.Mp[pInds]
                        mu = const.G*(Mp + Ms)
                        T = (2.*np.pi*np.sqrt(sp**3/mu)).to('d')
                        # star must have detections that span longer than half a period and be in the habitable zone
                        # and have a smaller radius that a sub-neptune
                        pinds_earthlike = self.is_earthlike(pInds, sInd)
                        if (np.any((T/2.0 < (self.sInd_dettimes[sInd][-1] - self.sInd_dettimes[sInd][0]))) and np.any(pinds_earthlike)) \
                          or ((self.sInd_detcounts[sInd] >= self.nmax_promo_det) and np.any(pinds_earthlike)):
                            earthlikes = pInds[pinds_earthlike]
                            self.known_earths = np.union1d(self.known_earths, pInds[pinds_earthlike]).astype(int)
                            promoted_occ_sInds = np.append(promoted_occ_sInds, sInd)
                            if sInd not in self.promoted_stars:
                                self.promoted_stars.append(sInd)
                occ_sInds = np.union1d(occ_sInds, promoted_occ_sInds)
            else:
                occ_sInds = np.union1d(occ_sInds, sInds[np.where((self.starVisits[sInds] == self.nVisitsMax) & 
                                                                 (self.occ_starVisits[sInds] == 0))[0]])

        occ_sInds = np.union1d(occ_sInds, np.intersect1d(sInds, self.known_rocky))
        self.promoted_stars = list(np.union1d(self.promoted_stars, np.intersect1d(sInds, self.known_rocky)).astype(int))
        return occ_sInds.astype(int) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:57,代码来源:tieredScheduler.py

示例13: promote_coro_targets

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def promote_coro_targets(self, occ_sInds, sInds):
        """
        Determines which coronograph targets to promote to occulter targets
        Args:
            occ_sInds (numpy array):
                occulter targets
            sInds (numpy array):
                coronograph targets
        Returns:
            occ_sInds (numpy array):
                updated occulter targets
        """
        TK = self.TimeKeeping
        SU = self.SimulatedUniverse
        TL = self.TargetList
        promoted_occ_sInds = np.array([], dtype=int)

        # if phase 1 has ended
        if TK.currentTimeAbs > self.phase1_end:
            if self.is_phase1 is True:
                self.vprint( 'Entering detection phase 2: target list for occulter expanded')
                self.is_phase1 = False
            # If we only want to promote stars that have planets in the habitable zone
            if self.promote_hz_stars:
                # stars must have had > n_det_min detections
                promote_stars = sInds[np.where(self.sInd_detcounts[sInds] > self.n_det_min)[0]]
                if np.any(promote_stars):
                    for sInd in promote_stars:
                        pInds = np.where(SU.plan2star == sInd)[0]
                        sp = SU.s[pInds]
                        Ms = TL.MsTrue[sInd]
                        Mp = SU.Mp[pInds]
                        mu = const.G*(Mp + Ms)
                        T = (2.*np.pi*np.sqrt(sp**3/mu)).to('d')
                        # star must have detections that span longer than half a period and be in the habitable zone
                        # and have a smaller radius that a sub-neptune
                        is_earthlike = np.logical_and(
                                          np.logical_and(
                                            (SU.a[pInds] > .95*u.AU), (SU.a[pInds] < 1.67*u.AU)),
                                          (SU.Rp.value[pInds] < 1.75))
                        if (np.any((T/2.0 < (self.sInd_dettimes[sInd][-1] - self.sInd_dettimes[sInd][0]))) 
                          and np.any(is_earthlike)):
                            earthlikes = pInds[np.where(is_earthlike)[0]]
                            self.earth_candidates = np.union1d(self.earth_candidates, earthlikes).astype(int)
                            promoted_occ_sInds = np.append(promoted_occ_sInds, sInd)
                            if sInd not in self.promoted_stars:
                                self.promoted_stars.append(sInd)
                occ_sInds = np.union1d(occ_sInds, promoted_occ_sInds)
            else:
                occ_sInds = np.union1d(occ_sInds, sInds[np.where((self.starVisits[sInds] == self.nVisitsMax) & 
                                                                 (self.occ_starVisits[sInds] == 0))[0]])
        occ_sInds = np.union1d(occ_sInds, np.intersect1d(sInds, self.known_rocky))
        self.promoted_stars = list(np.union1d(self.promoted_stars, np.intersect1d(sInds, self.known_rocky)).astype(int))
        return(occ_sInds.astype(int)) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:56,代码来源:tieredScheduler_sotoSS.py

示例14: scheduleRevisit

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def scheduleRevisit(self, sInd, smin, det, pInds):
        """A Helper Method for scheduling revisits after observation detection
        Args:
            sInd - sInd of the star just detected
            smin - minimum separation of the planet to star of planet just detected
            det - 
            pInds - Indices of planets around target star
        Return:
            updates self.starRevisit attribute
        """
        TK = self.TimeKeeping
        TL = self.TargetList
        SU = self.SimulatedUniverse
        # in both cases (detection or false alarm), schedule a revisit 
        # based on minimum separation
        Ms = TL.MsTrue[sInd]
        if smin is not None and np.nan not in smin: #smin is None if no planet was detected
            sp = smin
            if np.any(det):
                pInd_smin = pInds[det][np.argmin(SU.s[pInds[det]])]
                Mp = SU.Mp[pInd_smin]
            else:
                Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm.copy() + T/2.
        # otherwise, revisit based on average of population semi-major axis and mass
        else:
            sp = SU.s.mean()
            Mp = SU.Mp.mean()
            mu = const.G*(Mp + Ms)
            T = 2.*np.pi*np.sqrt(sp**3/mu)
            t_rev = TK.currentTimeNorm.copy() + 0.75*T
        # if no detections then schedule revisit based off of revisit_wait
        t_rev = TK.currentTimeNorm.copy() + self.revisit_wait
        # finally, populate the revisit list (NOTE: sInd becomes a float)
        revisit = np.array([sInd, t_rev.to('day').value])
        if self.starRevisit.size == 0:#If starRevisit has nothing in it
            self.starRevisit = np.array([revisit])#initialize sterRevisit
        else:
            revInd = np.where(self.starRevisit[:,0] == sInd)[0]#indices of the first column of the starRevisit list containing sInd 
            if revInd.size == 0:
                self.starRevisit = np.vstack((self.starRevisit, revisit))
            else:
                self.starRevisit[revInd,1] = revisit[1]#over 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:47,代码来源:tieredScheduler_sotoSS.py

示例15: gen_physical_properties

# 需要导入模块: from astropy import constants [as 别名]
# 或者: from astropy.constants import G [as 别名]
def gen_physical_properties(self, **specs):
        """Generates the planetary systems' physical properties. 
        
        Populates arrays of the orbital elements, albedos, masses and radii 
        of all planets, and generates indices that map from planet to parent star.
        
        """
        
        PPop = self.PlanetPopulation
        TL = self.TargetList
        
        if(type(self.fixedPlanPerStar) == int):#Must be an integer for fixedPlanPerStar
            #Create array of length TL.nStars each w/ value ppStar
            targetSystems = np.ones(TL.nStars).astype(int)*self.fixedPlanPerStar
        else:
            # treat eta as the rate parameter of a Poisson distribution
            targetSystems = np.random.poisson(lam=PPop.eta, size=TL.nStars)

        plan2star = []
        for j,n in enumerate(targetSystems):
            plan2star = np.hstack((plan2star, [j]*n))
        self.plan2star = plan2star.astype(int)
        self.sInds = np.unique(self.plan2star)
        self.nPlans = len(self.plan2star)
        
        # sample all of the orbital and physical parameters
        self.I, self.O, self.w = PPop.gen_angles(self.nPlans, self.commonSystemInclinations)
        if not self.commonSystemInclinations == None: #OVERWRITE I with TL.I+dI
            self.I = self.I.copy() + TL.I[self.plan2star]
        self.a, self.e, self.p, self.Rp = PPop.gen_plan_params(self.nPlans)
        if PPop.scaleOrbits:
            self.a *= np.sqrt(TL.L[self.plan2star])
        self.gen_M0()                           # initial mean anomaly
        self.Mp = PPop.gen_mass(self.nPlans)    # mass
        
        if self.ZodiacalLight.commonSystemfEZ == True:
            self.ZodiacalLight.nEZ = self.ZodiacalLight.gen_systemnEZ(TL.nStars)

        # The prototype StarCatalog module is made of one single G star at 1pc. 
        # In that case, the SimulatedUniverse prototype generates one Jupiter 
        # at 5 AU to allow for characterization testing.
        # Also generates at least one Jupiter if no planet was generated.
        if TL.Name[0] == 'Prototype' or self.nPlans == 0:
            self.plan2star = np.array([0], dtype=int)
            self.sInds = np.unique(self.plan2star)
            self.nPlans = len(self.plan2star)
            self.a = np.array([5.])*u.AU
            self.e = np.array([0.])
            self.I = np.array([0.])*u.deg # face-on
            self.O = np.array([0.])*u.deg
            self.w = np.array([0.])*u.deg
            self.gen_M0()
            self.Rp = np.array([10.])*u.earthRad
            self.Mp = np.array([300.])*u.earthMass
            self.p = np.array([0.6]) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:57,代码来源:SimulatedUniverse.py


注:本文中的astropy.constants.G属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。