Skip to content

Commit 3823f8f

Browse files
committed
Fixed offset of 0.5 pixels in sersic_xc and sersic_yc (does not affect the other Sersic parameters).
1 parent d0f58b7 commit 3823f8f

File tree

3 files changed

+49
-45
lines changed

3 files changed

+49
-45
lines changed

notebooks/tutorial.ipynb

Lines changed: 16 additions & 16 deletions
Large diffs are not rendered by default.

statmorph/statmorph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2302,7 +2302,7 @@ def _sersic_model(self):
23022302

23032303
# Prepare data for fitting
23042304
z = image.copy()
2305-
y, x = np.mgrid[0:ny, 0:nx]
2305+
y, x = np.mgrid[0:ny, 0:nx] + 0.5 # center of pixel
23062306
weightmap = self._weightmap_stamp
23072307
# Exclude pixels with image == 0 or weightmap == 0 from the fit.
23082308
fit_weights = np.zeros_like(z)

statmorph/tests/test_statmorph.py

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,38 @@
1515

1616
correct_values = {
1717
'xc_centroid':82.16578971349672,
18-
'yc_centroid':81.0346179734321,
19-
'ellipticity_centroid':0.04855709579575873,
20-
'elongation_centroid':1.0510352177531561,
21-
'orientation_centroid':-0.8579760206619491,
18+
'yc_centroid':81.03461797343211,
19+
'ellipticity_centroid':0.04855709579576,
20+
'elongation_centroid':1.05103521775316,
21+
'orientation_centroid':-0.85797602066195,
2222
'xc_asymmetry':82.23816149429084,
2323
'yc_asymmetry':80.76122537398356,
24-
'ellipticity_asymmetry':0.04862719043000929,
25-
'elongation_asymmetry':1.0511126552502466,
26-
'orientation_asymmetry':-0.8590029492030308,
24+
'ellipticity_asymmetry':0.04862719043001,
25+
'elongation_asymmetry':1.05111265525025,
26+
'orientation_asymmetry':-0.85900294920303,
2727
'rpetro_circ':40.93685686885102,
28-
'rpetro_ellip':41.6568715935214,
28+
'rpetro_ellip':41.65687159352140,
2929
'rhalf_circ':21.60432043808139,
30-
'rhalf_ellip':22.092999181298023,
31-
'r20':11.695409552661776,
30+
'rhalf_ellip':22.09299918129802,
31+
'r20':11.69540955266178,
3232
'r80':32.07888648441381,
33-
'gini':0.3901765299814595,
34-
'm20':-1.5429405756694308,
35-
'gini_m20_bulge':-0.8493683576528599,
36-
'sn_per_pixel':6.7997875,
37-
'concentration':2.191019250473638,
38-
'asymmetry':0.002168820096766045,
39-
'smoothness':0.019515863990804592,
40-
'sersic_amplitude':1296.9528812407366,
41-
'sersic_rhalf':22.45788866708879,
42-
'sersic_n':0.6120682828213252,
43-
'sersic_xc':81.561975952764,
44-
'sersic_yc':80.4046513562675,
45-
'sersic_ellip':0.05083866210052884,
46-
'sersic_theta':2.4783154293185397,
47-
'sky_mean':3.487606,
48-
'sky_median':-2.6854386,
49-
'sky_sigma':150.91754,
33+
'gini':0.39017652998146,
34+
'm20':-1.54294057566943,
35+
'gini_m20_bulge':-0.84936835765286,
36+
'sn_per_pixel':6.79978752136230,
37+
'concentration':2.19101925047364,
38+
'asymmetry':0.00216882009677,
39+
'smoothness':0.01951586399080,
40+
'sersic_amplitude':1296.95301375647091,
41+
'sersic_rhalf':22.45788881197317,
42+
'sersic_n':0.61206811649601,
43+
'sersic_xc':82.06197530371756,
44+
'sersic_yc':80.90465047895643,
45+
'sersic_ellip':0.05083868323144,
46+
'sersic_theta':2.47831539294767,
47+
'sky_mean':3.48760604858398,
48+
'sky_median':-2.68543863296509,
49+
'sky_sigma':150.91754150390625,
5050
}
5151

5252
def test1():
@@ -62,10 +62,14 @@ def test1():
6262
source_morphs = statmorph.source_morphology(image, segmap, mask=mask, gain=gain)
6363
morph = source_morphs[0]
6464

65+
#for key in correct_values:
66+
# print("'%s':%.14f," % (key, morph[key]))
67+
6568
# Check results
6669
assert morph['flag'] == 0
6770
assert morph['flag_sersic'] == 0
68-
for key, value in correct_values.items():
71+
for key in correct_values:
72+
value = morph[key]
6973
value0 = correct_values[key]
7074
relative_error = np.abs((value - value0) / value0)
7175
assert relative_error < 1e-6

0 commit comments

Comments
 (0)