Skip to content

Commit 40396a4

Browse files
authored
Merge pull request #184 from transientskp/Fix_180
For "forced_beam": limit brightness correction
2 parents b316313 + f3b10b1 commit 40396a4

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

sourcefinder/measure.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ def moments_enhanced(
496496
# position of the Gaussian peak.
497497
rounded_barycenter = int(round(xbar)), int(round(ybar))
498498
mask = (posx == rounded_barycenter[0]) & (posy == rounded_barycenter[1])
499-
if mask.any():
499+
in_source_island = mask.any()
500+
if in_source_island:
500501
# In this case the rounded barycenter position is in source_island.
501502
# Note that mask, from the way that posx and posy have been constructed,
502503
# can have no more than one True value.
@@ -517,16 +518,19 @@ def moments_enhanced(
517518
smaj = beam[0]
518519
smin = beam[1]
519520
theta = beam[2]
520-
# Implementation of "tweaked moments", equation 2.66 from
521-
# Spreeuw's thesis. In that formula the "base position" was the
522-
# maximum pixel position, though. Here that is the rounded
523-
# barycenter position, unless it's masked. If it's masked, it
524-
# will be the maximum pixel position.
525-
exponent = np.log(2.0) * (
526-
((np.cos(theta) * deltax + np.sin(theta) * deltay) / smin) ** 2
527-
+ ((np.cos(theta) * deltay - np.sin(theta) * deltax) / smaj) ** 2
528-
)
529-
peak = np.exp(exponent) * basevalue
521+
522+
if in_source_island:
523+
# Implementation of "tweaked moments", equation 2.66 from
524+
# Spreeuw's thesis. In that formula the "base position" was the
525+
# maximum pixel position, though. Here that is the rounded
526+
# barycenter position, unless it's masked. If it's masked, it
527+
# will be the maximum pixel position.
528+
exponent = np.log(2.0) * (
529+
((np.cos(theta) * deltax + np.sin(theta) * deltay) / smin) ** 2
530+
+ ((np.cos(theta) * deltay - np.sin(theta) * deltax) / smaj)
531+
** 2
532+
)
533+
peak = np.exp(exponent) * basevalue
530534

531535
else:
532536
xxbar, yybar, xybar = 0, 0, 0

0 commit comments

Comments
 (0)