Exemplo n.º 1
0
def test_model_manager():
    basedir = os.path.join(PACKAGE_ROOT, 'diffuse', 'tests', 'data')
    kwargs = dict(basedir=basedir,
                  library=os.path.join(basedir, 'models', 'library.yaml'),
                  comp=os.path.join(basedir, 'binning.yaml'))
    ret_dict = make_library(**kwargs)

    # spot check results
    assert(len(ret_dict['model_comp_dict'].keys()) == 30)
 
   # sun
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].model_type == 'MapCubeSource')
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].moving)
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].selection_dependent is False)
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].source_name == 'sun-ic')
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].sourcekey == 'sun-ic_v2r0')
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].source_ver == 'v2r0')

    assert(len(ret_dict['model_comp_dict']['sun-ic_v2r0'].components) == 4)
    assert(ret_dict['model_comp_dict']['sun-ic_v2r0'].components[
           'zmax100'].comp_key == 'zmax100')

    # isotropic
    assert(ret_dict['model_comp_dict'][
           'isotropic_P8R3_SOURCE_V2'].model_type == 'IsoSource')
    assert(ret_dict['model_comp_dict']['isotropic_P8R3_SOURCE_V2'].moving is False)
    assert(ret_dict['model_comp_dict'][
           'isotropic_P8R3_SOURCE_V2'].selection_dependent is False)
    assert(ret_dict['model_comp_dict'][
           'isotropic_P8R3_SOURCE_V2'].source_name == 'isotropic')
    assert(ret_dict['model_comp_dict'][
           'isotropic_P8R3_SOURCE_V2'].sourcekey == 'isotropic_P8R3_SOURCE_V2')
    assert(ret_dict['model_comp_dict']['isotropic_P8R3_SOURCE_V2'].source_ver == 'P8R3_SOURCE_V2')
    assert(ret_dict['model_comp_dict']['isotropic_P8R3_SOURCE_V2'].components is None)

    # galprop ring
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].model_type == 'MapCubeSource')
    assert(ret_dict['model_comp_dict']['merged_HI_5_ref'].moving is False)
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].selection_dependent is False)
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].source_name == 'merged_HI_5')
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].sourcekey == 'merged_HI_5_ref')
    assert(ret_dict['model_comp_dict']['merged_HI_5_ref'].source_ver == 'ref')
    assert(ret_dict['model_comp_dict']['merged_HI_5_ref'].components is None)

    model_manager = ret_dict['ModelManager']

    baseline_model = model_manager.make_model_info('baseline')
    assert(len(baseline_model.model_components) == 30)
Exemplo n.º 2
0
 def run(self, argv):
     """Assemble the source map file for one binning component
     FIXME
     """
     args = self.parser.parse_args(argv)
     components = Component.build_from_yamlfile(args.comp)
     NAME_FACTORY.update_base_dict(args.data)
     model_dict = make_library(**args.__dict__)
     model_manager = model_dict['ModelManager']
     modelkeys = args.args
     data = args.data
     hpx_order = args.hpx_order
     for modelkey in modelkeys:
         model_manager.make_srcmap_manifest(modelkey, components, data)
         fermipy_config = model_manager.make_fermipy_config_yaml(modelkey, components, data, hpxorder=hpx_order)
Exemplo n.º 3
0
 def run_analysis(self, argv):
     """Assemble the source map file for one binning component
     FIXME
     """
     args = self.parser.parse_args(argv)
     components = Component.build_from_yamlfile(args.comp)
     NAME_FACTORY.update_base_dict(args.data)
     model_dict = make_library(**args.__dict__)
     model_manager = model_dict['ModelManager']
     modelkeys = args.args
     data = args.data
     hpx_order = args.hpx_order
     for modelkey in modelkeys:
         model_manager.make_srcmap_manifest(modelkey, components, data)
         fermipy_config = model_manager.make_fermipy_config_yaml(
             modelkey, components, data, hpxorder=hpx_order)
Exemplo n.º 4
0
 def run_analysis(self, argv):
     """ Build the manifest for all the models
     """
     args = self._parser.parse_args(argv)
     components = Component.build_from_yamlfile(args.comp)
     NAME_FACTORY.update_base_dict(args.data)
     model_dict = make_library(**args.__dict__)
     model_manager = model_dict['ModelManager']
     models = load_yaml(args.models)
     data = args.data
     hpx_order = args.hpx_order
     for modelkey in models:
         model_manager.make_srcmap_manifest(modelkey, components, data)
         model_manager.make_fermipy_config_yaml(modelkey, components, data,
                                                hpx_order=hpx_order,
                                                irf_ver=NAME_FACTORY.irf_ver())
Exemplo n.º 5
0
 def run_analysis(self, argv):
     """ Build the manifest for all the models
     """
     args = self._parser.parse_args(argv)
     components = Component.build_from_yamlfile(args.comp)
     NAME_FACTORY.update_base_dict(args.data)
     model_dict = make_library(**args.__dict__)
     model_manager = model_dict['ModelManager']
     models = load_yaml(args.models)
     data = args.data
     hpx_order = args.hpx_order
     for modelkey in models:
         model_manager.make_srcmap_manifest(modelkey, components, data)
         model_manager.make_fermipy_config_yaml(modelkey, components, data,
                                                hpx_order=hpx_order,
                                                irf_ver=NAME_FACTORY.irf_ver())
Exemplo n.º 6
0
def test_model_manager():
    basedir = os.path.join(PACKAGE_ROOT, 'diffuse', 'tests', 'data')
    kwargs = dict(basedir=basedir,
                  sources=os.path.join(basedir, 'catalog_components.yaml'),
                  diffuse=os.path.join(basedir, 'diffuse_components.yaml'),
                  comp=os.path.join(basedir, 'binning.yaml'))
    ret_dict = make_library(**kwargs)

    # spot check results
    assert(len(ret_dict['model_comp_dict'].keys()) == 29)

    # sun
    assert(ret_dict['model_comp_dict'][
           'sun_v00'].model_type == 'MapCubeSource')
    assert(ret_dict['model_comp_dict']['sun_v00'].moving)
    assert(ret_dict['model_comp_dict']['sun_v00'].selection_dependent is False)
    assert(ret_dict['model_comp_dict']['sun_v00'].source_name == 'sun')
    assert(ret_dict['model_comp_dict']['sun_v00'].sourcekey == 'sun_v00')
    assert(ret_dict['model_comp_dict']['sun_v00'].source_ver == 'v00')

    assert(len(ret_dict['model_comp_dict']['sun_v00'].components) == 4)
    assert(ret_dict['model_comp_dict']['sun_v00'].components[
           'zmax100'].comp_key == 'zmax100')

    # residual cr
    assert(ret_dict['model_comp_dict'][
           'residual_cr_v00'].model_type == 'MapCubeSource')
    assert(ret_dict['model_comp_dict']['residual_cr_v00'].moving is False)
    assert(ret_dict['model_comp_dict']['residual_cr_v00'].selection_dependent)
    assert(ret_dict['model_comp_dict'][
           'residual_cr_v00'].source_name == 'residual_cr')
    assert(ret_dict['model_comp_dict'][
           'residual_cr_v00'].sourcekey == 'residual_cr_v00')
    assert(ret_dict['model_comp_dict']['residual_cr_v00'].source_ver == 'v00')

    assert(len(ret_dict['model_comp_dict'][
           'residual_cr_v00'].components) == 10)
    assert(ret_dict['model_comp_dict']['residual_cr_v00'].components[
           'E0_PSF3'].comp_key == 'E0_PSF3')

    # isotropic
    assert(ret_dict['model_comp_dict'][
           'isotropic_v00'].model_type == 'IsoSource')
    assert(ret_dict['model_comp_dict']['isotropic_v00'].moving is False)
    assert(ret_dict['model_comp_dict'][
           'isotropic_v00'].selection_dependent is False)
    assert(ret_dict['model_comp_dict'][
           'isotropic_v00'].source_name == 'isotropic')
    assert(ret_dict['model_comp_dict'][
           'isotropic_v00'].sourcekey == 'isotropic_v00')
    assert(ret_dict['model_comp_dict']['isotropic_v00'].source_ver == 'v00')
    assert(ret_dict['model_comp_dict']['isotropic_v00'].components is None)

    # galprop ring
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].model_type == 'MapCubeSource')
    assert(ret_dict['model_comp_dict']['merged_HI_5_ref'].moving is False)
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].selection_dependent is False)
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].source_name == 'merged_HI_5')
    assert(ret_dict['model_comp_dict'][
           'merged_HI_5_ref'].sourcekey == 'merged_HI_5_ref')
    assert(ret_dict['model_comp_dict']['merged_HI_5_ref'].source_ver == 'ref')
    assert(ret_dict['model_comp_dict']['merged_HI_5_ref'].components is None)

    model_manager = ret_dict['ModelManager']

    baseline_model = model_manager.make_model_info('baseline')
    assert(len(baseline_model.model_components) == 29)