def test_target_completeness_def(self):
        """
        Compare calculated completenesses for multiple targets under default population
        settings.
        """

        with RedirectStreams(stdout=self.dev_null):
            TL = TargetList(ntargs=100, **copy.deepcopy(self.spec))

            mode = list(
                filter(lambda mode: mode['detectionMode'] == True,
                       TL.OpticalSystem.observingModes))[0]
            IWA = mode['IWA']
            OWA = mode['OWA']
            rrange = TL.PlanetPopulation.rrange
            maxd = (rrange[1] / np.tan(IWA)).to(u.pc).value
            mind = (rrange[0] / np.tan(OWA)).to(u.pc).value

            #want distances to span from outer edge below IWA to inner edge above OWA
            TL.dist = np.logspace(np.log10(mind / 10.), np.log10(maxd * 10.),
                                  TL.nStars) * u.pc

        Brown = EXOSIMS.Completeness.BrownCompleteness.BrownCompleteness(
            **copy.deepcopy(self.spec))
        Garrett = EXOSIMS.Completeness.GarrettCompleteness.GarrettCompleteness(
            **copy.deepcopy(self.spec))

        cBrown = Brown.target_completeness(TL)
        cGarrett = Garrett.target_completeness(TL)

        np.testing.assert_allclose(cGarrett, cBrown, rtol=0.1, atol=1e-6)

        # test when scaleOrbits == True
        TL.L = np.exp(
            np.random.uniform(low=np.log(0.1),
                              high=np.log(10.),
                              size=TL.nStars))
        Brown.PlanetPopulation.scaleOrbits = True
        Garrett.PlanetPopulation.scaleOrbits = True

        cBrown = Brown.target_completeness(TL)
        cGarrett = Garrett.target_completeness(TL)

        cGarrett = cGarrett[cBrown != 0]
        cBrown = cBrown[cBrown != 0]
        meandiff = np.mean(np.abs(cGarrett - cBrown) / cBrown)

        self.assertLessEqual(meandiff, 0.1)
Beispiel #2
0
    def test_target_completeness_scaleOrbits(self):
        """
        Compare calculated completenesses for multiple targets with scale orbits set to true
        """
                   
        with RedirectStreams(stdout=self.dev_null):
            TL = TargetList(ntargs=100,**copy.deepcopy(self.spec))
            TL.dist =  np.exp(np.random.uniform(low=np.log(1.0), high=np.log(30.), size=TL.nStars))*u.pc
            TL.L = np.exp(np.random.uniform(low=np.log(0.1), high=np.log(10.), size=TL.nStars))

        Brown = EXOSIMS.Completeness.BrownCompleteness.BrownCompleteness(scaleOrbits=True,**copy.deepcopy(self.spec))
        Garrett = EXOSIMS.Completeness.GarrettCompleteness.GarrettCompleteness(scaleOrbits=True,**copy.deepcopy(self.spec))

        cBrown = Brown.target_completeness(TL)
        cGarrett = Garrett.target_completeness(TL)
        
        cGarrett = cGarrett[cBrown != 0 ]
        cBrown = cBrown[cBrown != 0]
        meandiff = np.mean(np.abs(cGarrett - cBrown)/cBrown)

        self.assertLessEqual(meandiff,0.1)