Skip to content

Commit

Permalink
add more moment checks
Browse files Browse the repository at this point in the history
  • Loading branch information
esheldon committed Nov 1, 2024
1 parent 1340fab commit 8b81c5d
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions ngmix/tests/test_gmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,18 @@ def test_higher_order():
rho4s = np.zeros(ntrial)
rho6s = np.zeros(ntrial)
rho8s = np.zeros(ntrial)

rho_M21 = np.zeros(ntrial)
rho_M12 = np.zeros(ntrial)
rho_M30 = np.zeros(ntrial)
rho_M03 = np.zeros(ntrial)

rho_M31 = np.zeros(ntrial)
rho_M13 = np.zeros(ntrial)

rho_M40 = np.zeros(ntrial)
rho_M14 = np.zeros(ntrial)

for i in range(ntrial):
obj = galsim.Gaussian(fwhm=fwhm)

Expand Down Expand Up @@ -581,6 +593,30 @@ def test_higher_order():
M44_ind = MOMENTS_NAME_MAP["M44"]
rho8s[i] = res['sums'][M44_ind] / res['sums'][f_ind] / sigma**8

M21_ind = MOMENTS_NAME_MAP["M21"]
rho_M21[i] = res['sums'][M21_ind] / res['sums'][f_ind] / sigma**3

M12_ind = MOMENTS_NAME_MAP["M12"]
rho_M12[i] = res['sums'][M12_ind] / res['sums'][f_ind] / sigma**3

M30_ind = MOMENTS_NAME_MAP["M30"]
rho_M30[i] = res['sums'][M30_ind] / res['sums'][f_ind] / sigma**3

M03_ind = MOMENTS_NAME_MAP["M03"]
rho_M03[i] = res['sums'][M03_ind] / res['sums'][f_ind] / sigma**3

M31_ind = MOMENTS_NAME_MAP["M31"]
rho_M31[i] = res['sums'][M31_ind] / res['sums'][f_ind] / sigma**3

M13_ind = MOMENTS_NAME_MAP["M13"]
rho_M13[i] = res['sums'][M13_ind] / res['sums'][f_ind] / sigma**3

M40_ind = MOMENTS_NAME_MAP["M40"]
rho_M40[i] = res['sums'][M40_ind] / res['sums'][f_ind] / sigma**3

M14_ind = MOMENTS_NAME_MAP["M14"]
rho_M14[i] = res['sums'][M14_ind] / res['sums'][f_ind] / sigma**3

rho4_mean = rho4s.mean()
rho4_std = rho4s.std()
print(f'rho4: {rho4_mean:.3g} std: {rho4_std:.3g}')
Expand All @@ -595,3 +631,27 @@ def test_higher_order():
rho8_std = rho8s.std()
print(f'rho8: {rho8_mean:.3g} std: {rho8_std:.3g}')
assert np.abs(rho8_mean - 24) < 1e-5

rho_M21_mean = rho_M21.mean()
assert np.abs(rho_M21_mean) < 1e-5

rho_M12_mean = rho_M12.mean()
assert np.abs(rho_M12_mean) < 1e-5

rho_M30_mean = rho_M30.mean()
assert np.abs(rho_M30_mean) < 1e-5

rho_M03_mean = rho_M03.mean()
assert np.abs(rho_M03_mean) < 1e-5

rho_M31_mean = rho_M31.mean()
assert np.abs(rho_M31_mean) < 1e-5

rho_M13_mean = rho_M13.mean()
assert np.abs(rho_M13_mean) < 1e-5

rho_M40_mean = rho_M40.mean()
assert np.abs(rho_M40_mean) < 1e-5

rho_M14_mean = rho_M14.mean()
assert np.abs(rho_M14_mean) < 1e-5

0 comments on commit 8b81c5d

Please sign in to comment.