Esempio n. 1
0
    def setUp(self):
        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/template_prototype_testing.json')
        with open(self.script) as f:
            self.spec = json.loads(f.read())

        with RedirectStreams(stdout=self.dev_null):
            self.sim = MissionSim.MissionSim(self.script)
        self.TL = self.sim.TargetList
        self.nStars = self.TL.nStars
        self.star_index = np.array(range(0, self.nStars))
        self.Obs = self.sim.Observatory
        self.mode = self.sim.OpticalSystem.observingModes[0]
        self.TK = self.sim.TimeKeeping
        assert self.nStars > 10, "Need at least 10 stars in the target list for the unit test."
        self.unit = 1./u.arcsec**2

        modtype = getattr(EXOSIMS.Prototypes.ZodiacalLight.ZodiacalLight, '_modtype')
        pkg = EXOSIMS.ZodiacalLight
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__ + '.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1], modtype)
                self.assertTrue(mod._modtype is modtype, '_modtype mismatch for %s' % mod.__name__)
                self.allmods.append(mod)
Esempio n. 2
0
    def __init__(self, dMagLim=25, minComp=0.1, cachedir=None, **specs):
        
        #start the outspec
        self._outspec = {}
        
        # load the vprint function (same line in all prototype module constructors)
        self.vprint = vprint(specs.get('verbose', True))
       
        #if specs contains a completeness_spec then we are going to generate separate instances
        #of planet population and planet physical model for completeness and for the rest of the sim
        if 'completeness_specs' in specs:
            if not specs['completeness_specs'].has_key('modules'):
                specs['completeness_specs']['modules'] = {}
            if not specs['completeness_specs']['modules'].has_key('PlanetPhysicalModel'):
                specs['completeness_specs']['modules']['PlanetPhysicalModel'] = specs['modules']['PlanetPhysicalModel']
            if not specs['completeness_specs']['modules'].has_key('PlanetPopulation'):
                specs['completeness_specs']['modules']['PlanetPopulation'] = specs['modules']['PlanetPopulation']
            self.PlanetPopulation = get_module(specs['completeness_specs']['modules']['PlanetPopulation'],'PlanetPopulation')(**specs['completeness_specs'])
        else:
            self.PlanetPopulation = get_module(specs['modules']['PlanetPopulation'],'PlanetPopulation')(**specs)

        # copy phyiscal model object up to attribute
        self.PlanetPhysicalModel = self.PlanetPopulation.PlanetPhysicalModel
        
        # loading attributes
        self.dMagLim = float(dMagLim)
        self.minComp = float(minComp)
        # find the cache directory
        self.cachedir = get_cache_dir(cachedir)
        
        # populate outspec
        self._outspec['dMagLim'] = self.dMagLim
        self._outspec['minComp'] = self.minComp
        self._outspec['cachedir'] = self.cachedir
Esempio n. 3
0
    def test_get_module_source_2(self):
        r"""Test init-from-source -- not a prototype.

        Approach: Load module from a file we know is present."""
        source = os.path.join(EXO_SOURCE, 'PlanetPopulation', 'KnownRVPlanets.py')
        # basic test
        m = get_module(source)
        self.validate_module(m, 'PlanetPopulation')
        # again -- unspecified type
        m = get_module(source)
        self.validate_module(m, 'PlanetPopulation')
Esempio n. 4
0
    def test_get_module_source_1(self):
        r"""Test init-from-source -- prototype.

        Approach: Load module from a file we know is present."""
        source = os.path.join(EXO_SOURCE, 'Prototypes', 'TimeKeeping.py')
        # basic test
        m = get_module(source, 'TimeKeeping')
        self.validate_module(m, 'TimeKeeping')
        # again -- unspecified type
        m = get_module(source)
        self.validate_module(m, 'TimeKeeping')
Esempio n. 5
0
    def test_get_module_source_1(self):
        r"""Test init-from-source -- prototype.

        Approach: Load module from a file we know is present."""
        source = os.path.join(EXO_SOURCE, 'Prototypes', 'TimeKeeping.py')
        # basic test
        m = get_module(source, 'TimeKeeping')
        self.validate_module(m, 'TimeKeeping')
        # again -- unspecified type
        m = get_module(source)
        self.validate_module(m, 'TimeKeeping')
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')

        modtype = getattr(EXOSIMS.Prototypes.PlanetPhysicalModel.PlanetPhysicalModel,'_modtype')
        pkg = EXOSIMS.PlanetPhysicalModel
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__,pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 7
0
    def test_get_module_source_2(self):
        r"""Test init-from-source -- not a prototype.

        Approach: Load module from a file we know is present."""
        source = os.path.join(EXO_SOURCE, 'PlanetPopulation',
                              'KnownRVPlanets.py')
        # basic test
        m = get_module(source)
        self.validate_module(m, 'PlanetPopulation')
        # again -- unspecified type
        m = get_module(source)
        self.validate_module(m, 'PlanetPopulation')
Esempio n. 8
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')

        modtype = getattr(EXOSIMS.Prototypes.PlanetPhysicalModel.PlanetPhysicalModel,'_modtype')
        pkg = EXOSIMS.PlanetPhysicalModel
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__,pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 9
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        
        modtype = getattr(StarCatalog,'_modtype')
        pkg = EXOSIMS.StarCatalog
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
            if (not 'Gaia' in module_name) and \
            not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 10
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/simplest.json')
        with open(self.script) as f:
            self.spec = json.loads(f.read())
    
        modtype = getattr(SurveySimulation,'_modtype')
        pkg = EXOSIMS.SurveySimulation
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 11
0
    def test_get_module_Mname_ok_2(self):
        r"""Test get-no-folder -- Prototype

        Approach: Load module from a source we know is present."""
        module = 'PlanetPopulation'
        m = get_module(module)
        self.validate_module(m, module)
Esempio n. 12
0
    def __init__(self, **specs):

        # load the vprint function (same line in all prototype module constructors)
        self.vprint = vprint(specs.get('verbose', True))

        # import TargetList class
        self.TargetList = get_module(specs['modules']['TargetList'],
                                     'TargetList')(**specs)

        # bring inherited class objects to top level of Simulated Universe
        TL = self.TargetList
        self.StarCatalog = TL.StarCatalog
        self.PlanetPopulation = TL.PlanetPopulation
        self.PlanetPhysicalModel = TL.PlanetPhysicalModel
        self.OpticalSystem = TL.OpticalSystem
        self.ZodiacalLight = TL.ZodiacalLight
        self.BackgroundSources = TL.BackgroundSources
        self.PostProcessing = TL.PostProcessing
        self.Completeness = TL.Completeness

        # list of possible planet attributes
        self.planet_atts = [
            'plan2star', 'a', 'e', 'I', 'O', 'w', 'M0', 'Rp', 'Mp', 'p', 'r',
            'v', 'd', 's', 'phi', 'fEZ', 'dMag', 'WA'
        ]

        # generate orbital elements, albedos, radii, and masses
        self.gen_physical_properties(**specs)

        # find initial position-related parameters: position, velocity, planet-star
        # distance, apparent separation, surface brightness of exo-zodiacal light
        self.init_systems()
Esempio n. 13
0
 def setUp(self):
     self.dev_null = open(os.devnull, 'w')
     modtype = getattr(EXOSIMS.Prototypes.BackgroundSources.BackgroundSources,'_modtype')
     pkg = EXOSIMS.BackgroundSources
     self.allmods = [get_module(modtype)]
     for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
         if not is_pkg:
             mod = get_module(module_name.split('.')[-1],modtype)
             self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
             self.allmods.append(mod)
     # need a TargetList object for testing
     script = resource_path('test-scripts/template_prototype_testing.json')
     with open(script) as f:
         spec = json.loads(f.read())
     with RedirectStreams(stdout=self.dev_null):
         self.TL = TargetList(**spec)
Esempio n. 14
0
    def test_get_module_Mname_fail_not_there(self):
        r"""Test get-no-folder -- failure

        Approach: Load module from a source we know is not present."""
        module = 'KnownRVPlanets_not_there'
        with self.assertRaises(ValueError):
            m = get_module(module)
Esempio n. 15
0
    def test_get_module_Mname_ok_1(self):
        r"""Test get-no-folder -- Prototype

        Approach: Load module from a source we know is present."""
        module = 'TimeKeeping'
        m = get_module(module)
        self.validate_module(m, module)
Esempio n. 16
0
    def test_get_module_Mname_fail_not_there(self):
        r"""Test get-no-folder -- failure

        Approach: Load module from a source we know is not present."""
        module = 'KnownRVPlanets_not_there'
        with self.assertRaises(ValueError):
            m = get_module(module)
Esempio n. 17
0
    def test_get_module_Mname_ok_1(self):
        r"""Test get-no-folder -- Prototype

        Approach: Load module from a source we know is present."""
        module = 'TimeKeeping'
        m = get_module(module)
        self.validate_module(m, module)
Esempio n. 18
0
    def test_get_module_Mname_ok_2(self):
        r"""Test get-no-folder -- Prototype

        Approach: Load module from a source we know is present."""
        module = 'PlanetPopulation'
        m = get_module(module)
        self.validate_module(m, module)
Esempio n. 19
0
 def __init__(self, keepStarCatalog=False, minComp=0.1, **specs):
     """
     Initializes target list
     
     """
     
     #validate inputs
     assert isinstance(keepStarCatalog,bool),\
             "keepStarCatalog must be a boolean."
     assert isinstance(minComp,numbers.Number),\
             "minComp must be a number."
     self.minComp = float(minComp)
     
     # get desired module names (specific or prototype) and instantiate objects
     self.StarCatalog = get_module(specs['modules']['StarCatalog'],'StarCatalog')(**specs)
     self.OpticalSystem = get_module(specs['modules']['OpticalSystem'],'OpticalSystem')(**specs)
     self.ZodiacalLight = get_module(specs['modules']['ZodiacalLight'],'ZodiacalLight')(**specs)
     self.PostProcessing = get_module(specs['modules']['PostProcessing'],'PostProcessing')(**specs)
     self.Completeness = get_module(specs['modules']['Completeness'],'Completeness')(**specs)
     
     # bring inherited class objects to top level of Simulated Universe
     Comp = self.Completeness
     PPro = self.PostProcessing
     self.PlanetPopulation = Comp.PlanetPopulation
     self.PlanetPhysicalModel = Comp.PlanetPhysicalModel
     self.BackgroundSources = PPro.BackgroundSources
     
     # list of possible Star Catalog attributes
     self.catalog_atts = ['Name', 'Spec', 'parx', 'Umag', 'Bmag', 'Vmag', 'Rmag', 
             'Imag', 'Jmag', 'Hmag', 'Kmag', 'dist', 'BV', 'MV', 'BC', 'L', 
             'coords', 'pmra', 'pmdec', 'rv', 'Binary_Cut']
     
     # now populate and filter the list
     self.populate_target_list(**specs)
     self.filter_target_list(**specs)
     
     # generate any completeness update data needed
     Comp.gen_update(self)
     
     # have target list, no need for catalog now
     if not keepStarCatalog:
         del self.StarCatalog
     
     # populate outspec
     self._outspec['nStars'] = self.nStars
     self._outspec['keepStarCatalog'] = keepStarCatalog
     self._outspec['minComp'] = self.minComp
Esempio n. 20
0
    def test_get_module_Mname_ok_star(self):
        r"""Test get-no-folder -- found by searching below EXOSIMS for a named non-Prototype module.

        Approach: Load module from a *non-Prototype* source we know is present."""
        module = 'KnownRVPlanets'
        m = get_module(module)
        # this is a non-Prototype module of type PlanetPopulation
        self.validate_module(m, 'PlanetPopulation')
Esempio n. 21
0
    def test_get_module_Mname_ok_star(self):
        r"""Test get-no-folder -- found by searching below EXOSIMS for a named non-Prototype module.

        Approach: Load module from a *non-Prototype* source we know is present."""
        module = 'KnownRVPlanets'
        m = get_module(module)
        # this is a non-Prototype module of type PlanetPopulation
        self.validate_module(m, 'PlanetPopulation')
Esempio n. 22
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')

        # self.spec = {"modules": {"PlanetPhysicalModel": "PlanetPhysicalModel"}}
        self.script = resource_path('test-scripts/template_minimal.json')
        with open(self.script) as f:
            self.spec = json.loads(f.read())

        modtype = getattr(EXOSIMS.Prototypes.Observatory.Observatory, '_modtype')
        pkg = EXOSIMS.Observatory
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__ + '.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1], modtype)
                self.assertTrue(mod._modtype is modtype, '_modtype mismatch for %s' % mod.__name__)
                self.allmods.append(mod)
Esempio n. 23
0
    def test_get_module_non_exosims_error_no_modtype(self):
        r"""Test non-EXOSIMS loading -- no _modtype attribute at all

        Approach: Load module having no _modtype attribute."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationErrorMissingModtype'
        modtype = 'PlanetPopulation'
        with self.assertRaises(AssertionError):
            m = get_module(module, modtype)
Esempio n. 24
0
    def test_get_module_non_exosims_ok_1(self):
        r"""Test non-EXOSIMS loading -- simple source.

        Approach: Load module from a source we know is present."""
        module = 'tests.TestModules.TimeKeeping.TimeKeepingModified'
        modtype = 'TimeKeeping'
        m = get_module(module, modtype)
        self.validate_module(m, modtype)
Esempio n. 25
0
    def test_get_module_non_exosims_ok_2(self):
        r"""Test non-EXOSIMS loading -- simple source.

        Approach: Load module from a source we know is present."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationModified'
        modtype = 'PlanetPopulation'
        m = get_module(module, modtype)
        self.validate_module(m, modtype)
Esempio n. 26
0
    def test_get_module_non_exosims_notthere_module(self):
        r"""Test non-EXOSIMS loading -- failure due to absent module

        Approach: Load a module we know is not present."""
        module = 'tests.TestModules.TimeKeepingNotThere'
        modtype = 'TimeKeeping'
        with self.assertRaises(ValueError):
            m = get_module(module, modtype)
Esempio n. 27
0
    def test_get_module_non_exosims_notthere_module(self):
        r"""Test non-EXOSIMS loading -- failure due to absent module

        Approach: Load a module we know is not present."""
        module = 'tests.TestModules.TimeKeepingNotThere'
        modtype = 'TimeKeeping'
        with self.assertRaises(ValueError):
            m = get_module(module, modtype)
Esempio n. 28
0
    def test_get_module_source_fail_wrong_type(self):
        r"""Test init-from-source -- failure.

        Approach: Load module, but ask for the wrong type."""
        source = os.path.join(EXO_SOURCE, 'Prototypes', 'TimeKeeping.py')
        # 
        with self.assertRaises(AssertionError):
            m = get_module(source, 'WrongModuleType')
Esempio n. 29
0
    def test_get_module_non_exosims_error_modtype_mismatch(self):
        r"""Test non-EXOSIMS loading -- _modtype attribute mismatch.

        Approach: Load module, ask for the wrong modtype."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationModified'
        modtype = 'TimeKeeping'  # note: TimeKeeping vs. PlanetPopulation
        with self.assertRaises(AssertionError):
            m = get_module(module, modtype)
Esempio n. 30
0
    def test_get_module_Mname_Fname_1(self):
        r"""Test get-from-named-folder -- prototype.

        Approach: Load module from a file we know is present."""
        module = 'TimeKeeping'
        # basic test
        m = get_module(module, module)
        self.validate_module(m, module)
Esempio n. 31
0
    def test_get_module_Mname_Fname_1(self):
        r"""Test get-from-named-folder -- prototype.

        Approach: Load module from a file we know is present."""
        module = 'TimeKeeping'
        # basic test
        m = get_module(module, module)
        self.validate_module(m, module)
Esempio n. 32
0
    def test_get_module_source_fail_wrong_type(self):
        r"""Test init-from-source -- failure.

        Approach: Load module, but ask for the wrong type."""
        source = os.path.join(EXO_SOURCE, 'Prototypes', 'TimeKeeping.py')
        #
        with self.assertRaises(AssertionError):
            m = get_module(source, 'WrongModuleType')
Esempio n. 33
0
    def test_get_module_non_exosims_error_no_modtype(self):
        r"""Test non-EXOSIMS loading -- no _modtype attribute at all

        Approach: Load module having no _modtype attribute."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationErrorMissingModtype'
        modtype = 'PlanetPopulation'
        with self.assertRaises(AssertionError):
            m = get_module(module, modtype)
Esempio n. 34
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.specs = {'modules':{'BackgroundSources':' '}}
        script = resource_path('test-scripts/template_minimal.json')
        spec = json.loads(open(script).read())     
        with RedirectStreams(stdout=self.dev_null):
            self.TL = TargetList(**spec)

        modtype = getattr(EXOSIMS.Prototypes.PostProcessing.PostProcessing,'_modtype')
        pkg = EXOSIMS.PostProcessing
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 35
0
    def test_get_module_non_exosims_notthere_package(self):
        r"""Test non-EXOSIMS loading -- failure due to absent package

        Approach: Load module from a package we know is not present."""
        module = 'tests_not_there'
        modtype = 'PlanetPopulation'
        with self.assertRaises(ValueError):
            m = get_module(module, modtype)
Esempio n. 36
0
    def test_get_module_non_exosims_ok_1(self):
        r"""Test non-EXOSIMS loading -- simple source.

        Approach: Load module from a source we know is present."""
        module = 'tests.TestModules.TimeKeeping.TimeKeepingModified'
        modtype = 'TimeKeeping'
        m = get_module(module, modtype)
        self.validate_module(m, modtype)
Esempio n. 37
0
    def test_get_module_non_exosims_ok_2(self):
        r"""Test non-EXOSIMS loading -- simple source.

        Approach: Load module from a source we know is present."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationModified'
        modtype = 'PlanetPopulation'
        m = get_module(module, modtype)
        self.validate_module(m, modtype)
Esempio n. 38
0
    def test_get_module_non_exosims_notthere_package(self):
        r"""Test non-EXOSIMS loading -- failure due to absent package

        Approach: Load module from a package we know is not present."""
        module = 'tests_not_there'
        modtype = 'PlanetPopulation'
        with self.assertRaises(ValueError):
            m = get_module(module, modtype)
Esempio n. 39
0
    def test_get_module_source_fail_not_there(self):
        r"""Test init-from-source -- failure

        Approach: Load module from a file we know is not present."""
        # basic test
        source = os.path.join(EXO_SOURCE, 'NotPresent', 'NotPresent.py')
        with self.assertRaises(ValueError):
            m = get_module(source, 'Not_used')
Esempio n. 40
0
    def test_get_module_non_exosims_error_modtype_mismatch(self):
        r"""Test non-EXOSIMS loading -- _modtype attribute mismatch.

        Approach: Load module, ask for the wrong modtype."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationModified'
        modtype = 'TimeKeeping' # note: TimeKeeping vs. PlanetPopulation
        with self.assertRaises(AssertionError):
            m = get_module(module, modtype)
Esempio n. 41
0
    def test_get_module_non_exosims_error_naming(self):
        r"""Test non-EXOSIMS loading -- class name wrong.

        Approach: Load module which defines a class with the wrong name."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationErrorNaming'
        modtype = 'PlanetPopulation'
        with self.assertRaises(AssertionError):
            m = get_module(module, modtype)
Esempio n. 42
0
    def test_get_module_non_exosims_error_naming(self):
        r"""Test non-EXOSIMS loading -- class name wrong.

        Approach: Load module which defines a class with the wrong name."""
        module = 'tests.TestModules.PlanetPopulation.PlanetPopulationErrorNaming'
        modtype = 'PlanetPopulation'
        with self.assertRaises(AssertionError):
            m = get_module(module, modtype)
Esempio n. 43
0
    def test_get_module_source_fail_not_there(self):
        r"""Test init-from-source -- failure

        Approach: Load module from a file we know is not present."""
        # basic test
        source = os.path.join(EXO_SOURCE, 'NotPresent', 'NotPresent.py')
        with self.assertRaises(ValueError):
            m = get_module(source, 'Not_used')
Esempio n. 44
0
    def __init__(self, fixedPlanPerStar=None, Min=None, cachedir=None, **specs):
        
        #start the outspec
        self._outspec = {}

        # load the vprint function (same line in all prototype module constructors)
        self.vprint = vprint(specs.get('verbose', True))

        # save fixed number of planets to generate
        self.fixedPlanPerStar = fixedPlanPerStar
        self._outspec['fixedPlanPerStar'] = fixedPlanPerStar

        # get cache directory
        self.cachedir = get_cache_dir(cachedir)
        self._outspec['cachedir'] = self.cachedir
        
        # check if KnownRVPlanetsUniverse has correct input modules
        if specs['modules']['SimulatedUniverse'] == 'KnownRVPlanetsUniverse':
            val = specs['modules']['TargetList'] == 'KnownRVPlanetsTargetList' \
            and specs['modules']['PlanetPopulation'] == 'KnownRVPlanets'
            assert val == True, 'KnownRVPlanetsUniverse must use KnownRVPlanetsTargetList and KnownRVPlanets'
        else:
            val = specs['modules']['TargetList'] == 'KnownRVPlanetsTargetList' \
            or specs['modules']['PlanetPopulation'] == 'KnownRVPlanets'
            assert val == False, 'KnownRVPlanetsTargetList or KnownRVPlanets should not be used with this SimulatedUniverse'
            
        # import TargetList class
        self.TargetList = get_module(specs['modules']['TargetList'],
                'TargetList')(**specs)
        
        # bring inherited class objects to top level of Simulated Universe
        TL = self.TargetList
        self.StarCatalog = TL.StarCatalog
        self.PlanetPopulation = TL.PlanetPopulation
        self.PlanetPhysicalModel = TL.PlanetPhysicalModel
        self.OpticalSystem = TL.OpticalSystem
        self.ZodiacalLight = TL.ZodiacalLight
        self.BackgroundSources = TL.BackgroundSources
        self.PostProcessing = TL.PostProcessing
        self.Completeness = TL.Completeness
        
        # initial constant mean anomaly
        assert type(Min) is int or type(Min) is float or Min is None, 'Min may be int, float, or None'
        if Min is not None:
            self.Min = float(Min)*u.deg
        else:
            self.Min = Min
        
        # list of possible planet attributes
        self.planet_atts = ['plan2star', 'a', 'e', 'I', 'O', 'w', 'M0', 'Min', 'Rp', 'Mp', 'p',
                'r', 'v', 'd', 's', 'phi', 'fEZ', 'dMag', 'WA']
        
        # generate orbital elements, albedos, radii, and masses
        self.gen_physical_properties(**specs)
        
        # find initial position-related parameters: position, velocity, planet-star 
        # distance, apparent separation, surface brightness of exo-zodiacal light
        self.init_systems()
Esempio n. 45
0
    def test_get_module_Mname_Fname_2(self):
        r"""Test get-from-named-folder -- non-prototype.

        Approach: Load module from a file we know is present."""
        module = 'KnownRVPlanets'
        folder = 'PlanetPopulation'
        # basic test
        m = get_module(module, folder)
        self.validate_module(m, folder)
Esempio n. 46
0
    def test_get_module_Mname_Fname_fail_not_there(self):
        r"""Test get-from-named-folder -- failure

        Approach: Load module from a source we know is not present."""
        module = 'KnownRVPlanets_not_there'
        folder = 'PlanetPopulation'
        # fails with ValueError: not found
        with self.assertRaises(ValueError):
            m = get_module(module, folder)
Esempio n. 47
0
    def test_get_module_Mname_Fname_default(self):
        r"""Test get-from-named-folder -- prototype, shortcut using blanks.

        Approach: Load module from a file we know is present."""
        module = ' '
        folder = 'PlanetPopulation'
        # basic test
        m = get_module(module, folder)
        self.validate_module(m, folder)
Esempio n. 48
0
    def test_get_module_Mname_Fname_2(self):
        r"""Test get-from-named-folder -- non-prototype.

        Approach: Load module from a file we know is present."""
        module = 'KnownRVPlanets'
        folder = 'PlanetPopulation'
        # basic test
        m = get_module(module, folder)
        self.validate_module(m, folder)
Esempio n. 49
0
    def test_get_module_Mname_Fname_default(self):
        r"""Test get-from-named-folder -- prototype, shortcut using blanks.

        Approach: Load module from a file we know is present."""
        module = ' '
        folder = 'PlanetPopulation'
        # basic test
        m = get_module(module, folder)
        self.validate_module(m, folder)
Esempio n. 50
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/template_minimal.json')
        with open(self.script) as f:
            self.spec = json.loads(f.read())
        
        with RedirectStreams(stdout=self.dev_null):
            self.TL = TargetList(ntargs=10,**copy.deepcopy(self.spec))
        
        modtype = getattr(OpticalSystem,'_modtype')
        pkg = EXOSIMS.OpticalSystem
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 51
0
    def test_get_module_Mname_Fname_fail_not_there(self):
        r"""Test get-from-named-folder -- failure

        Approach: Load module from a source we know is not present."""
        module = 'KnownRVPlanets_not_there'
        folder = 'PlanetPopulation'
        # fails with ValueError: not found
        with self.assertRaises(ValueError):
            m = get_module(module, folder)
Esempio n. 52
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/template_minimal.json')
        self.spec = json.loads(open(self.script).read())

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

        modtype = getattr(OpticalSystem, '_modtype')
        pkg = EXOSIMS.OpticalSystem
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(
                pkg.__path__, pkg.__name__ + '.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1], modtype)
                self.assertTrue(mod._modtype is modtype,
                                '_modtype mismatch for %s' % mod.__name__)
                self.allmods.append(mod)
Esempio n. 53
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/simplest.json')

        modtype = getattr(SurveySimulation, '_modtype')
        pkg = EXOSIMS.SurveySimulation
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(
                pkg.__path__, pkg.__name__ + '.'):
            #if (not 'starkAYO' in module_name) and \
            if (not 'SS_char_only' in module_name) and \
            (not 'SS_det_only' in module_name) and \
            (not 'tieredScheduler' in module_name) and \
            not is_pkg:
                mod = get_module(module_name.split('.')[-1], modtype)
                self.assertTrue(mod._modtype is modtype,
                                '_modtype mismatch for %s' % mod.__name__)
                self.allmods.append(mod)
Esempio n. 54
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/template_minimal.json')
        with open(self.script) as f:
            self.spec = json.loads(f.read())
        
        with RedirectStreams(stdout=self.dev_null):
            self.TL = TargetList(ntargs=10,**copy.deepcopy(self.spec))
        self.TL.dist = np.random.uniform(low=0,high=100,size=self.TL.nStars)*u.pc
        
        modtype = getattr(SimulatedUniverse,'_modtype')
        pkg = EXOSIMS.SimulatedUniverse
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 55
0
    def setUp(self):

        self.dev_null = open(os.devnull, 'w')
        self.script = resource_path('test-scripts/template_minimal.json')
        with open(self.script) as f:
            self.spec = json.loads(f.read())
        
        with RedirectStreams(stdout=self.dev_null):
            self.TL = TargetList(ntargs=10,**copy.deepcopy(self.spec))
        self.TL.dist = np.random.uniform(low=0,high=100,size=self.TL.nStars)*u.pc
        
        modtype = getattr(SimulatedUniverse,'_modtype')
        pkg = EXOSIMS.SimulatedUniverse
        self.allmods = [get_module(modtype)]
        for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'):
            if not is_pkg:
                mod = get_module(module_name.split('.')[-1],modtype)
                self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__)
                self.allmods.append(mod)
Esempio n. 56
0
    def setUp(self):
        # print '[setup] ',
        # do not instantiate it
        self.fixture = TimeKeeping

        self.dev_null = open(os.devnull, 'w')
        self.script1 = resource_path('test-scripts/simplest.json')
        self.script2 = resource_path('test-scripts/simplest_initOB.json')
    
        modtype = getattr(SurveySimulation,'_modtype')
        self.allmods = [get_module(modtype)]