Skip to content

Commit 9e4b420

Browse files
committed
Merge remote-tracking branch 'origin/optimal-estimator-various-optimizations' into optimal-estimator
2 parents d0df9f1 + f482f7f commit 9e4b420

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lya_2pt/optimal_estimator.py

Lines changed: 13 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=50, lambda_max=2048):
58+
def build_xi1d(z1=1.8, z2=4., nz=200, 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=50, 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='linear', bounds_error=False)
71+
return RGI((z, r), xi_wwindow, method='cubic', bounds_error=False)
7272

7373

7474
def get_xi_bins(tracer1, tracer2, angle):
@@ -149,25 +149,28 @@ 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
152153

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

158-
invcov1_x_c_deriv_list = [c_deriv.T.dot(tracer1.invcov).T for c_deriv in c_deriv_list]
159159
row_slices = [np.s_[rmin:rmax] for (rmin, rmax, _, _) in idx_minmax_list]
160160
col_slices = [np.s_[cmin:cmax] for (_, _, cmin, cmax) in idx_minmax_list]
161+
invcov1_x_c_deriv_list = [
162+
c_deriv.T[cs].dot(tracer1.invcov).T for c_deriv, cs in zip(c_deriv_list, col_slices)
163+
]
161164

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

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

170-
return xi_est, fisher_est
173+
# return xi_est, fisher_est
171174

172175

173176
def compute_xi_and_fisher(healpix_id):

0 commit comments

Comments
 (0)