def pairwiser_massboost_one_row(row, Dc, ra_rad, dec_rad, tzav, Tmapsc, bin_edges, mass, dTw, w2, sum_mass, Npairs): ''' inputs: row: what row to compute Dc: distances ra_rad: ra dec_rad: dec tzav: averaged T vs z Tmapsc: Tdisc-Tring bin_edges: bin edges in Mpc (for n bins, we need n+1) mass: mass in linear scale outputs: dTw: accumulated sum dT * c_ij * M_ij w2: accumulated sum c_ij**2 * M_ij**2 sum_mass: sum M_ij Npairs: counter''' many = len(ra_rad) i = row for j in range(i + 1, many): ang_ij = angle_jit_rad(dec_rad[i], ra_rad[i], dec_rad[j], ra_rad[j]) vecdiff_ij = vecdiff_jit(Dc[i], Dc[j], ang_ij) if (vecdiff_ij > bin_edges[0]) and (vecdiff_ij < bin_edges[-1]): binval_ij = inWhatBinIsIt(vecdiff_ij, bin_edges) dT_ij = (Tmapsc[i] - tzav[i]) - (Tmapsc[j] - tzav[j]) cij = (Dc[i] - Dc[j]) * (1.0 + mt.cos(ang_ij)) / (2.0 * vecdiff_ij) Mij = (mass[i] + mass[j]) / 2. dTw[binval_ij] += dT_ij * cij * Mij w2[binval_ij] += cij**2. * Mij**2 sum_mass[binval_ij] += Mij Npairs[binval_ij] += 1
def do_the_jitted_pairwise(ra_rad, dec_rad, Dc, dT_ksz, row, bin_edges, vecdiff_ij_s, cij_s, dTw_s, w2_s, i_s, j_s, bin_number_s): '''Will do the pairwise calculation fast. returns n_stored which is the length of the vector that survived the r_max cut Results are stored in vecdiff_ij_s, cij_s, dTw_s, and w2_s.''' i = row N_gal = len(ra_rad) n_stored = 0 for j in range(row+1, N_gal): ang_ij = pairwiser.angle_jit_rad(dec_rad[i], ra_rad[i], dec_rad[j], ra_rad[j]) vecdiff_ij = pairwiser.vecdiff_jit(Dc[i], Dc[j], ang_ij) if (vecdiff_ij > bin_edges[0]) and (vecdiff_ij < bin_edges[-1]): binval_ij = inWhatBinIsIt(vecdiff_ij, bin_edges) cij = (Dc[i]-Dc[j])*(1.0 + mt.cos(ang_ij)) / (2*vecdiff_ij) dT_ij = dT_ksz[i]-dT_ksz[j] dTw = dT_ij * cij w2 = cij**2 #store result vecdiff_ij_s[n_stored] = vecdiff_ij cij_s[n_stored] = cij dTw_s[n_stored] = dTw w2_s[n_stored] = w2 i_s[n_stored] = row j_s[n_stored] = j bin_number_s[n_stored] = binval_ij n_stored += 1 return n_stored
def cross_pairwiser_one_row_uneven_bins(row, Dc, ra_rad, dec_rad, tzav1, tzav2, dT1, dT2, bin_edges, dTw, w2): '''Idem to pairwise_one_row_uneven_bins from pairwiser.py''' many = len(ra_rad) i = row for j in range(i + 1, many): ang_ij = angle_jit_rad(dec_rad[i], ra_rad[i], dec_rad[j], ra_rad[j]) vecdiff_ij = vecdiff_jit(Dc[i], Dc[j], ang_ij) # check if separation within bin space if (vecdiff_ij > bin_edges[0]) and (vecdiff_ij < bin_edges[-1]): binval_ij = inWhatBinIsIt(vecdiff_ij, bin_edges) dT_ij = (dT1[i] - tzav1[i]) - (dT2[j] - tzav2[j]) cij = (Dc[i] - Dc[j]) * (1.0 + mt.cos(ang_ij)) / (2.0 * vecdiff_ij) dTw[binval_ij] += dT_ij * cij w2[binval_ij] += cij**2.0
def pairwise_Nit_uneven_bins(Nit, Dc, ra_rad, dec_rad, tzav, Tmapsc, bin_edges, dTw, w2): N_gal = len(Dc) rand_ij = np.zeros(2, dtype=np.int64) for it in xrange(Nit): gen_random_pair(N_gal, rand_ij) i, j = rand_ij[0], rand_ij[1] ang_ij = angle_jit_rad(dec_rad[i], ra_rad[i], dec_rad[j], ra_rad[j]) vecdiff_ij = vecdiff_jit(Dc[i], Dc[j], ang_ij) # Check if this separation is within the bin space if (vecdiff_ij > bin_edges[0]) and (vecdiff_ij < bin_edges[-1]): binval_ij = inWhatBinIsIt(vecdiff_ij, bin_edges) # Now compute and store dT_ij = (Tmapsc[i] - tzav[i]) - (Tmapsc[j] - tzav[j]) cij = (Dc[i] - Dc[j]) * (1.0 + mt.cos(ang_ij)) / (2.0 * vecdiff_ij) dTw[binval_ij] += dT_ij * cij w2[binval_ij] += cij**2.