Skip to content

Commit

Permalink
add names to match piff; more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esheldon committed Nov 1, 2024
1 parent 09f244c commit 819a16c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ngmix/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
# notation from piff.util.calculate_moments
# third order

# these are same as above but with the alternative notation
"M00": 5, # same as MF
"M10": 1, # same as Mu
"M01": 0, # same as Mv
"M11": 4, # same as MT
"M20": 2, # same as M1
"M02": 3, # same as M2

# u * r^2
"M21": 6,
# v * r^2
Expand Down
16 changes: 14 additions & 2 deletions ngmix/tests/test_gmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ngmix.shape import g1g2_to_e1e2
from ngmix.shape import Shape
import ngmix.moments
from ngmix.moments import MOMENTS_NAME_MAP
from ngmix import DiagonalJacobian, Observation


Expand Down Expand Up @@ -512,6 +513,17 @@ def test_higher_order_smoke(do_higher):
if do_higher:
assert res['sums'].shape == (17, )
assert res['sums_cov'].shape == (17, 17)

assert MOMENTS_NAME_MAP['M00'] == MOMENTS_NAME_MAP['MF']
assert MOMENTS_NAME_MAP['M10'] == MOMENTS_NAME_MAP['Mu']
assert MOMENTS_NAME_MAP['M01'] == MOMENTS_NAME_MAP['Mv']
assert MOMENTS_NAME_MAP['M11'] == MOMENTS_NAME_MAP['MT']
assert MOMENTS_NAME_MAP['M20'] == MOMENTS_NAME_MAP['M1']
assert MOMENTS_NAME_MAP['M02'] == MOMENTS_NAME_MAP['M2']

for name, ind in MOMENTS_NAME_MAP.items():
# make sure the index is valid
res['sums'][ind]
else:
assert res['sums'].shape == (6, )
assert res['sums_cov'].shape == (6, 6)
Expand Down Expand Up @@ -556,8 +568,8 @@ def test_higher_order():

res = wt.get_weighted_moments(obs, higher=True)

f_ind = ngmix.moments.MOMENTS_NAME_MAP["MF"]
M22_ind = ngmix.moments.MOMENTS_NAME_MAP["M22"]
f_ind = MOMENTS_NAME_MAP["MF"]
M22_ind = MOMENTS_NAME_MAP["M22"]
rho4s[i] = res['sums'][M22_ind] / res['sums'][f_ind] / sigma**4

rho4_mean = rho4s.mean()
Expand Down

0 comments on commit 819a16c

Please sign in to comment.