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


Python units.day方法代码示例

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


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

示例1: test_log_occulterResults

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_log_occulterResults(self):
        """
        Test that log_occulter_results returns proper dictionary with keys
        """

        atts_list = ['slew_time', 'slew_angle', 'slew_dV', 'slew_mass_used', 'scMass']
        for mod in self.allmods:
            if 'log_occulterResults' in mod.__dict__:
                with RedirectStreams(stdout=self.dev_null):
                    if 'SotoStarshade' in mod.__name__:
                        obj = mod(f_nStars=4, **copy.deepcopy(self.spec))
                    else:
                        obj = mod(**copy.deepcopy(self.spec))
                DRM = {}
                slewTimes = np.ones((5,))*u.day
                sInds = np.arange(5)
                sd = np.ones((5,))*u.rad
                dV = np.ones((5,))*u.m/u.s

                DRM = obj.log_occulterResults(DRM, slewTimes, sInds, sd, dV)

                for att in atts_list:
                    self.assertTrue(att in DRM, 'Missing key in log_occulterResults for %s' % mod.__name__) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:25,代码来源:test_Observatory.py

示例2: test_calc_dMag_per_intTime

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_calc_dMag_per_intTime(self):
        """
        Check calc_dMag_per_intTime i/o 
        """

        for mod in self.allmods:
            if 'calc_dMag_per_intTime' not in mod.__dict__:
                continue
            obj = mod(**copy.deepcopy(self.spec))
            
            dMag = obj.calc_dMag_per_intTime(np.ones(self.TL.nStars)*u.day,
                    self.TL, np.arange(self.TL.nStars), 
                    np.array([0]*self.TL.nStars)/(u.arcsec**2.),np.array([0]*self.TL.nStars)/(u.arcsec**2.),
                    np.array([obj.WA0.value]*self.TL.nStars)*obj.WA0.unit,obj.observingModes[0])
        
            self.assertEqual(dMag.shape,np.arange(self.TL.nStars).shape) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:18,代码来源:test_OpticalSystem.py

示例3: test_ddMag_dt

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_ddMag_dt(self):
        """
        Check ddMag_dt i/o 
        """

        for mod in self.allmods:
            if 'ddMag_dt' not in mod.__dict__:
                continue
            obj = mod(**copy.deepcopy(self.spec))

            ddMag = obj.ddMag_dt(np.ones(self.TL.nStars)*u.day,
                    self.TL, np.arange(self.TL.nStars), 
                    np.array([0]*self.TL.nStars)/(u.arcsec**2.),np.array([0]*self.TL.nStars)/(u.arcsec**2.),
                    np.array([obj.WA0.value]*self.TL.nStars)*obj.WA0.unit,obj.observingModes[0])

            self.assertEqual(ddMag.shape,np.arange(self.TL.nStars).shape) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:18,代码来源:test_OpticalSystem.py

示例4: revisitFilter

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def revisitFilter(self, sInds, tmpCurrentTimeNorm):
        """Helper method for Overloading Revisit Filtering

        Args:
            sInds - indices of stars still in observation list
            tmpCurrentTimeNorm (MJD) - the simulation time after overhead was added in MJD form
        Returns:
            sInds - indices of stars still in observation list
        """
        tovisit = np.zeros(self.TargetList.nStars, dtype=bool)#tovisit is a boolean array containing the 
        if len(sInds) > 0:#so long as there is at least 1 star left in sInds
            tovisit[sInds] = ((self.starVisits[sInds] == min(self.starVisits[sInds])) \
                    & (self.starVisits[sInds] < self.nVisitsMax))# Checks that no star has exceeded the number of revisits
            if self.starRevisit.size != 0:#There is at least one revisit planned in starRevisit
                dt_rev = self.starRevisit[:,1]*u.day - tmpCurrentTimeNorm#absolute temporal spacing between revisit and now.

                #return indices of all revisits within a threshold dt_max of revisit day and indices of all revisits with no detections past the revisit time
                ind_rev2 = [int(x) for x in self.starRevisit[dt_rev < 0*u.d, 0] if (x in sInds)]
                tovisit[ind_rev2] = (self.starVisits[ind_rev2] < self.nVisitsMax)
            sInds = np.where(tovisit)[0]

        return sInds 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:24,代码来源:tieredScheduler_SLSQP.py

示例5: scheduleRevisit

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [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

        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,代码行数:26,代码来源:coroOnlyScheduler.py

示例6: revisitFilter

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def revisitFilter(self, sInds, tmpCurrentTimeNorm):
        """Helper method for Overloading Revisit Filtering

        Args:
            sInds - indices of stars still in observation list
            tmpCurrentTimeNorm (MJD) - the simulation time after overhead was added in MJD form
        Returns:
            sInds - indices of stars still in observation list
        """
        tovisit = np.zeros(self.TargetList.nStars, dtype=bool)#tovisit is a boolean array containing the 
        if len(sInds) > 0:#so long as there is at least 1 star left in sInds
            tovisit[sInds] = ((self.starVisits[sInds] == min(self.starVisits[sInds])) \
                    & (self.starVisits[sInds] < self.nVisitsMax))# Checks that no star has exceeded the number of revisits
            if self.starRevisit.size != 0:#There is at least one revisit planned in starRevisit
                dt_rev = self.starRevisit[:,1]*u.day - tmpCurrentTimeNorm#absolute temporal spacing between revisit and now.

                ind_rev2 = [int(x) for x in self.starRevisit[dt_rev < 0*u.d, 0] if (x in sInds)]
                tovisit[ind_rev2] = (self.starVisits[ind_rev2] < self.nVisitsMax)
            sInds = np.where(tovisit)[0]
        return sInds 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:22,代码来源:linearJScheduler_det_only.py

示例7: revisitFilter

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def revisitFilter(self, sInds, tmpCurrentTimeNorm):
        """Helper method for Overloading Revisit Filtering
        Args:
            sInds - indices of stars still in observation list
            tmpCurrentTimeNorm (MJD) - the simulation time after overhead was added in MJD form
        Returns:
            sInds - indices of stars still in observation list
        """
        tovisit = np.zeros(self.TargetList.nStars, dtype=bool)#tovisit is a boolean array containing the 
        if len(sInds) > 0:#so long as there is at least 1 star left in sInds
            tovisit[sInds] = ((self.starVisits[sInds] == min(self.starVisits[sInds])) \
                    & (self.starVisits[sInds] < self.nVisitsMax))# Checks that no star has exceeded the number of revisits
            if self.starRevisit.size != 0:#There is at least one revisit planned in starRevisit
                dt_rev = self.starRevisit[:,1]*u.day - tmpCurrentTimeNorm#absolute temporal spacing between revisit and now.

                #return indices of all revisits within a threshold dt_max of revisit day and indices of all revisits with no detections past the revisit time
                # ind_rev = [int(x) for x in self.starRevisit[np.abs(dt_rev) < self.dt_max, 0] if (x in sInds and self.no_dets[int(x)] == False)]
                # ind_rev2 = [int(x) for x in self.starRevisit[dt_rev < 0*u.d, 0] if (x in sInds and self.no_dets[int(x)] == True)]
                # tovisit[ind_rev] = (self.starVisits[ind_rev] < self.nVisitsMax)#IF duplicates exist in ind_rev, the second occurence takes priority
                ind_rev2 = [int(x) for x in self.starRevisit[dt_rev < 0*u.d, 0] if (x in sInds)]
                tovisit[ind_rev2] = (self.starVisits[ind_rev2] < self.nVisitsMax)
            sInds = np.where(tovisit)[0]

        return sInds 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:26,代码来源:tieredScheduler_sotoSS.py

示例8: advancetToStartOfNextOB

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def advancetToStartOfNextOB(self):
        """Advances to Start of Next Observation Block
        This method is called in the allocate_time() method of the TimeKeeping 
        class object, when the allocated time requires moving outside of the current OB.
        If no OB duration was specified, a new Observing Block is created for 
        each observation in the SurveySimulation module. Updates attributes OBnumber, 
        currentTimeNorm and currentTimeAbs.

        """
        self.OBnumber += 1#increase the observation block number
        self.currentTimeNorm = self.OBstartTimes[self.OBnumber]#update currentTimeNorm
        self.currentTimeAbs = self.OBstartTimes[self.OBnumber] + self.missionStart#update currentTimeAbs

        # begin Survey, and loop until mission is finished
        log_begin = 'OB%s:'%(self.OBnumber)#prints because this is the beginning of the nesxt observation block
        self.vprint(log_begin)
        self.vprint("Advanced currentTimeNorm to beginning of next OB %.2fd"%(self.currentTimeNorm.to('day').value)) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:19,代码来源:TimeKeeping.py

示例9: revisitFilter

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def revisitFilter(self,sInds,tmpCurrentTimeNorm):
        """Helper method for Overloading Revisit Filtering

        Args:
            sInds - indices of stars still in observation list
            tmpCurrentTimeNorm (MJD) - the simulation time after overhead was added in MJD form
        Returns:
            sInds - indices of stars still in observation list
        """

        tovisit = np.zeros(self.TargetList.nStars, dtype=bool)
        if len(sInds) > 0:
            tovisit[sInds] = ((self.starVisits[sInds] == min(self.starVisits[sInds])) \
                    & (self.starVisits[sInds] < self.nVisitsMax))#Checks that no star has exceeded the number of revisits and the indicies of all considered stars have minimum number of observations
            #The above condition should prevent revisits so long as all stars have not been observed
            if self.starRevisit.size != 0:
                dt_rev = np.abs(self.starRevisit[:,1]*u.day - tmpCurrentTimeNorm)
                ind_rev = [int(x) for x in self.starRevisit[dt_rev < self.dt_max,0] 
                        if x in sInds]
                tovisit[ind_rev] = (self.starVisits[ind_rev] < self.nVisitsMax)
            sInds = np.where(tovisit)[0]
        return sInds 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:24,代码来源:SurveySimulation.py

示例10: test_estimate_mass_basic

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_estimate_mass_basic():
    """Assert the basic functions of estimate_mass
    """
    M = estimate_mass(cnumax, cdeltanu, cteff)
    assert(M.unit == u.solMass)  # Check units
    assert(np.isclose(M.value, cM.n, rtol=cM.s))  # Check right answer

    # Check units on parameters
    M = estimate_mass(u.Quantity(cnumax, u.microhertz), cdeltanu, cteff)
    assert(np.isclose(M.value, cM.n, rtol=cM.s))

    M = estimate_mass(cnumax, u.Quantity(cdeltanu, u.microhertz), cteff)
    assert(np.isclose(M.value, cM.n, rtol=cM.s))

    M = estimate_mass(cnumax, cdeltanu, u.Quantity(cteff, u.Kelvin))
    assert(np.isclose(M.value, cM.n, rtol=cM.s))

    # Check works with a random selection of appropriate units
    M = estimate_mass(u.Quantity(cnumax, u.microhertz).to(1/u.day),
                      u.Quantity(cdeltanu, u.microhertz).to(u.hertz),
                      cteff)
    assert(np.isclose(M.value, cM.n, rtol=cM.s)) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:24,代码来源:test_stellar_estimators.py

示例11: test_estimate_numax_basics

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_estimate_numax_basics():
    """Test if we can estimate a numax."""
    f, p, true_numax, _ = generate_test_spectrum()
    snr = SNRPeriodogram(f*u.microhertz, u.Quantity(p, None))
    numax = snr.to_seismology().estimate_numax()

    #Assert recovers numax within 10%
    assert(np.isclose(true_numax, numax.value, atol=.1*true_numax))
    #Assert numax has unit equal to input frequency unit
    assert(numax.unit == u.microhertz)

    # Assert you can recover numax with a chopped periodogram
    rsnr = snr[(snr.frequency.value>1600) & (snr.frequency.value<3200)]
    numax = rsnr.to_seismology().estimate_numax()
    assert(np.isclose(true_numax, numax.value, atol=.1*true_numax))

    # Assert numax estimator works when input frequency is not in microhertz
    fday = u.Quantity(f*u.microhertz, 1/u.day)
    snr = SNRPeriodogram(fday, u.Quantity(p, None))
    numax = snr.to_seismology().estimate_numax()
    nmxday = u.Quantity(true_numax*u.microhertz, 1/u.day)
    assert(np.isclose(nmxday, numax, atol=.1*nmxday)) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:24,代码来源:test_butler.py

示例12: test_estimate_deltanu_kwargs

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_estimate_deltanu_kwargs():
    """Test if we can estimate a deltanu using its various keyword arguments
    """
    f, p, _, true_deltanu = generate_test_spectrum()
    snr = SNRPeriodogram(f*u.microhertz, u.Quantity(p, None))
    butler = snr.to_seismology()

    # Assert custom numax works
    numax = butler.estimate_numax()
    deltanu = butler.estimate_deltanu(numax=numax)
    assert(np.isclose(deltanu.value, true_deltanu, atol=.25*true_deltanu))

    # Assert you can't pass custom numax outside of appropriate range
    with pytest.raises(ValueError):
        deltanu = butler.estimate_deltanu(numax= -5.)
    with pytest.raises(ValueError):
        deltanu = butler.estimate_deltanu(numax=5000)

    # Assert it doesn't matter what units of frequency numax is passed in as
    daynumax = u.Quantity(numax.value*u.microhertz, 1/u.day)
    deltanu = butler.estimate_deltanu(numax=daynumax)
    assert(np.isclose(deltanu.value, true_deltanu, atol=.25*true_deltanu))
    assert(deltanu.unit == u.microhertz) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:25,代码来源:test_butler.py

示例13: test_fold_v2

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_fold_v2():
    """The API of LightCurve.fold() changed in Lightkurve v2.x when we adopted
    AstroPy's TimeSeries.fold() method. This test verifies the new API."""
    lc = LightCurve(time=np.linspace(0, 10, 100), flux=np.zeros(100)+1)

    # Can period be passed as a float?
    fld = lc.fold(period=1)
    fld2 = lc.fold(period=1*u.day)
    assert_array_equal(fld.phase, fld2.phase)
    assert isinstance(fld.time, TimeDelta)
    fld.plot_river()
    plt.close()

    # Does phase normalization work?
    fld = lc.fold(period=1, normalize_phase=True)
    assert isinstance(fld.time, u.Quantity)
    fld.plot_river()
    plt.close() 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:20,代码来源:test_lightcurve.py

示例14: test_flatten

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [as 别名]
def test_flatten():
    npts = 10000
    np.random.seed(12069424)
    lc = LightCurve(time=np.arange(npts),
                    flux=np.random.normal(1, 0.1, npts),
                    flux_err=np.zeros(npts)+0.1)
    lc = lc.normalize()
    p = lc.to_periodogram(normalization='psd', freq_unit=1/u.day)

    # Check method returns equal frequency
    assert all(p.flatten(method='logmedian').frequency == p.frequency)
    assert all(p.flatten(method='boxkernel').frequency == p.frequency)

    # Check logmedian flatten of white noise returns mean of ~unity
    assert np.isclose(np.mean(p.flatten(method='logmedian').power.value), 1.0,
                      atol=0.05)

    # Check return trend works
    s, b = p.flatten(return_trend=True)
    assert all(b.power == p.smooth(method='logmedian', filter_width=0.01).power)
    assert all(s.power == p.flatten().power)
    str(s)
    s.plot()
    plt.close() 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:26,代码来源:test_periodogram.py

示例15: test_period_semi

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import day [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


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