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


Python Bootstrap.perturb_catalog方法代码示例

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


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

示例1: main

# 需要导入模块: from bootstrap import Bootstrap [as 别名]
# 或者: from bootstrap.Bootstrap import perturb_catalog [as 别名]
def main():
	# Set up logging
    logging.basicConfig(
            level=logging.INFO,
            format='%(asctime)s  %(message)s',
            datefmt='%Y-%d-%m %I:%M:%S %p')

    # Get parameters from the provided parameter file
    param_file_path = sys.argv[1]
    params = parameters.get_params(param_file_path)

    zkey = params['zkey']
    mkey = params['mkey']
    rkey = params['ra_key']
    dkey = params['dec_key']

    t0 = time.time()

    if params['bins']['bin_in_lookback_time'] == True:
        z_pref = 'lookt'
    else:
        z_pref = 'z'
    # Stack in Slices or ALL AT ONCE Choice made here
    if params['bins']['stack_all_z_at_once'] == True: n_slices = 1
    else: n_slices = len(params['bins']['z_nodes']) - 1

    #Save Parameter file in folder
    save_paramfile(params)

    for i in range(n_slices):
        if params['bins']['stack_all_z_at_once'] == True:
            j = None
            stacked_flux_density_key = 'all_'+z_pref
        else:
            j = i
            if params['bins']['bin_in_lookback_time'] == True:
                stacked_flux_density_key = '{:.2f}'.format(params['bins']['t_nodes'][j])+'-'+'{:.2f}'.format(params['bins']['t_nodes'][j+1])
            else:
                stacked_flux_density_key = str(params['bins']['t_nodes'][j])+'-'+str(params['bins']['t_nodes'][j+1])

        print stacked_flux_density_key
        # From parameter file read maps, psfs, cats, and divide them into bins
        sky_library   = get_maps(params)
        cats          = get_catalogs(params)
        if params['bootstrap'] == True:
            pcat = Bootstrap(cats.table)

        # Bootstrap Loop Starts here
        for iboot in np.arange(params['number_of_boots'])+params['boot0']:
            #stacked_flux_densities = {}
            if params['bootstrap'] == True:
                print 'Running ' +str(int(iboot))+' of '+ str(int(params['boot0'])) +'-'+ str(int(params['boot0']+params['number_of_boots']-1)) + ' bootstraps'

                pcat.perturb_catalog(perturb_z = params['perturb_z'])
                bootcat = Field_catalogs(pcat.pseudo_cat,zkey=zkey,mkey=mkey,rkey=rkey,dkey=dkey)
                binned_ra_dec = get_bin_radec(params, bootcat, single_slice = j)
                if params['save_bin_ids'] == False:
                    bin_ids = None
                else:
                    bin_ids = get_bin_ids(params, bootcat, single_slice = j)
                out_file_path   = params['io']['output_folder']+'/bootstrapped_fluxes/'+params['io']['shortname']
                out_file_suffix = '_'+stacked_flux_density_key+'_boot_'+str(int(iboot))
            else:
                binned_ra_dec = get_bin_radec(params, cats, single_slice = j)
                if params['save_bin_ids'] == False:
                    bin_ids = None
                else:
                    bin_ids = get_bin_ids(params, cats, single_slice = j)
                out_file_path   = params['io']['output_folder'] + '/simstack_fluxes/' + params['io']['shortname']
                out_file_suffix = '_'+stacked_flux_density_key

            # Do simultaneous stacking
            if params['float_background'] == True:
                stacked_flux_densities = stack_libraries_in_layers_w_background(sky_library,binned_ra_dec)
            else:
                stacked_flux_densities = stack_libraries_in_layers(sky_library,binned_ra_dec)

            save_stacked_fluxes(stacked_flux_densities,params, out_file_path,out_file_suffix, IDs=bin_ids)
        #pdb.set_trace()

    # Summarize timing
    t1 = time.time()
    tpass = t1-t0

    logging.info("Done!")
    logging.info("")
    logging.info("Total time                        : {:.4f} minutes\n".format(tpass/60.))
开发者ID:marcoviero,项目名称:simstack,代码行数:89,代码来源:run_simstack_cmd_line.py


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