本文整理汇总了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.))