Skip to content

Commit 8a8fea8

Browse files
committed
Revert "use cubic interpolation in xi1d interp. use fromiter to avoid memory allocation and copying"
This reverts commit bec09c4.
1 parent ecf56ef commit 8a8fea8

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lya_2pt/optimal_estimator.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def window_squared_angstrom(k, delta_lambda=2.4, R=0.8):
5555
return np.exp(-k**2 * R**2) * np.sinc(k * delta_lambda / 2 / np.pi)**2
5656

5757

58-
def build_xi1d(z1=1.8, z2=4., nz=200, lambda_max=2048):
58+
def build_xi1d(z1=1.8, z2=4., nz=50, lambda_max=2048):
5959
z = np.linspace(z1, z2, nz)
6060

6161
r, dlambda = np.linspace(-lambda_max, lambda_max, int(10 * lambda_max) + 1, retstep=True)
@@ -68,7 +68,7 @@ def build_xi1d(z1=1.8, z2=4., nz=200, lambda_max=2048):
6868
xi_wwindow = np.fft.irfft(fid_pk_angstrom * window_squared_angstrom(k), n=r.size) / dlambda
6969
xi_wwindow = np.fft.fftshift(xi_wwindow, axes=1)
7070

71-
return RGI((z, r), xi_wwindow, method='cubic', bounds_error=False)
71+
return RGI((z, r), xi_wwindow, method='linear', bounds_error=False)
7272

7373

7474
def get_xi_bins(tracer1, tracer2, angle):
@@ -149,26 +149,25 @@ def compute_xi_and_fisher_pair(
149149
):
150150
bins = get_xi_bins_t(tracer1, tracer2, angle)
151151
unique_bins, c_deriv_list, idx_minmax_list = build_deriv(bins)
152-
n_unique_bins = unique_bins.size
153152

154153
# deltas are weighted before this function is called
155-
xi_est[unique_bins] += np.fromiter((
154+
xi_est[unique_bins] += np.array([
156155
2 * np.dot(tracer1.deltas, c_deriv.dot(tracer2.deltas)) for c_deriv in c_deriv_list
157-
), float, n_unique_bins)
156+
])
158157

159158
invcov1_x_c_deriv_list = [c_deriv.T.dot(tracer1.invcov).T for c_deriv in c_deriv_list]
160159
row_slices = [np.s_[rmin:rmax] for (rmin, rmax, _, _) in idx_minmax_list]
161160
col_slices = [np.s_[cmin:cmax] for (_, _, cmin, cmax) in idx_minmax_list]
162161

163162
for i, (bin1, c_deriv, rs) in enumerate(zip(unique_bins, c_deriv_list, row_slices)):
164-
c_deriv_x_invcov2 = c_deriv[rs].dot(tracer2.invcov)
163+
c_deriv_x_invcov2 = c_deriv.dot(tracer2.invcov)
165164

166-
fisher_est[bin1, unique_bins[i:]] += np.fromiter((
167-
np.vdot(c_deriv_x_invcov2[:, cs], invcov1_x_c_deriv[rs, cs])
165+
fisher_est[bin1, unique_bins[i:]] += np.array([
166+
np.vdot(c_deriv_x_invcov2[rs, cs], invcov1_x_c_deriv[rs, cs])
168167
for invcov1_x_c_deriv, cs in zip(invcov1_x_c_deriv_list[i:], col_slices[i:])
169-
), float, n_unique_bins - i)
168+
])
170169

171-
# return xi_est, fisher_est
170+
return xi_est, fisher_est
172171

173172

174173
def compute_xi_and_fisher(healpix_id):

0 commit comments

Comments
 (0)