Skip to content

Commit

Permalink
Add comment about ddof
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jun 18, 2018
1 parent 07bffe6 commit 81b9233
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ctapipe/image/hillas.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ def hillas_parameters_5(geom: CameraGeometry, image):
delta_x = pix_x - cog_x
delta_y = pix_y - cog_y

# The ddof=0 makes this comparable to the other methods,
# but ddof=1 should be more correct, mostly affects small showers
# on a percent level
cov = np.cov(delta_x, delta_y, aweights=image, ddof=0)
eig_vals, eig_vecs = np.linalg.eigh(cov)

Expand Down
6 changes: 2 additions & 4 deletions ctapipe/image/tests/test_hillas.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_sample_image_masked(psi='-30d'):
def compare_result(x, y):
ux = u.Quantity(x)
uy = u.Quantity(y)
assert isclose(ux.value, uy.value)
assert isclose(ux.value, uy.value, rtol=0.01)
assert ux.unit == uy.unit


Expand All @@ -78,7 +78,7 @@ def test_hillas():
results['v1'] = hillas_parameters_1(geom, image)
results['v2'] = hillas_parameters_2(geom, image)
results['v3'] = hillas_parameters_3(geom, image)
results['v4'] = hillas_parameters_4(geom, image)
results['v4'] = hillas_parameters_4(geom, image, container=True)
results['v5'] = hillas_parameters_5(geom, image)
# compare each method's output
for aa in results:
Expand All @@ -90,7 +90,6 @@ def test_hillas():
compare_result(results[aa].r, results[bb].r)
compare_result(results[aa].phi.deg, results[bb].phi.deg)
compare_result(results[aa].psi.deg, results[bb].psi.deg)
compare_result(results[aa].miss, results[bb].miss)
compare_result(results[aa].skewness, results[bb].skewness)
# compare_result(results[aa].kurtosis, results[bb].kurtosis)

Expand Down Expand Up @@ -137,7 +136,6 @@ def test_hillas_failure():
hillas_parameters_5(geom, blank_image)



def test_hillas_api_change():
with pytest.raises(ValueError):
hillas_parameters_4(arange(10), arange(10), arange(10))
Expand Down

0 comments on commit 81b9233

Please sign in to comment.