def test_compute_region_densities_and_weights(self):
test_rand_ration = [0.0101507, 0.01101003, 0.01151311, 0.01081756,
0.01281959, 0.01212378, 0.0128798, 0.01246496]
test_ave_weight = np.ones_like(test_rand_ration)
cosmos_data = fits.getdata(
'data/COSMOS_iband_2009_radecidstomp_regionzp_best.fits')
cosmos_zp_cut = cosmos_data[np.logical_and(
cosmos_data.zp_best > 0.3, cosmos_data.zp_best <= 0.5)]
open_hdf5_data_file = h5py.File(self.dummy_args.input_pair_hdf5_file)
hdf5_data_grp = open_hdf5_data_file['data']
id_array, rand_ratio, weight_array, ave_weight = \
pdf_maker_utils._compute_region_densities_and_weights(
cosmos_zp_cut, hdf5_data_grp, self.dummy_args)
for rand, ave, test_rand, test_ave in \
zip(rand_ratio, ave_weight, test_rand_ration,
test_ave_weight):
self.assertAlmostEqual(rand, test_rand)
self.assertAlmostEqual(ave, test_ave)
open_hdf5_data_file.close()
评论列表
文章目录