You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unrealistic values with --force-beam and --vectorize #180
When both the flags --vectorize and --force-beam are used in conjunction, some sources get weird values like a ra_err and dec_err of 0, or very high fluxes.
I tried to reproduce this with the existing test images in the pyse repo but I did not manage. I did find some problematic configuration in some test files from Antonia. The following example uses one of these files.
Then run the following command with pyse version v0.6.0: pyse --csv GRB201006A/GRB201006A_final_2min_srcs-t0021-image-pb.fits --force-beam --vectorized --back-size-x 50 --back-size-y 50
Then when I inspect the results using head GRB201006A_final_2min_srcs-t0021-image-pb.csv -n 20 I get:
Note that when I remove either the --vectorize or the --force-beam the results seem fine. It seems to be the combination that causes issues.
This issue relates to a comment made in a different issue: #177 (comment)
To derive the peak brightness, tweaked moments takes the pixel value at the rounded barycenter position and extrapolates that to the barycenter position.
That extrapolation can be based on the (forced) beam or based on the measured source shape. It is an extrapolation over a subtended angle at the subpixel level.
In some edge cases the rounded barycenter positon is not an island pixel.
In that case, tweaked moments is still applied, but the maximum pixel value and the position of that pixel are used to extrapolate from. This appeared to work well.
All the problems seem to occur when the island of pixels is relatively wide, when the rounded barycenter position is not an island pixel and the maximum pixel position is far from the island barycenter. That is rare, but can occur with an extended source with a relatively flat brightness distribution. The extrapolation then leads to incredibly large derived peak brightness, but likely only for forced beam measurements: for free shape the measured axes will be large such that the extrapolation will not lead to large values.
I guess the answer should be that we should not apply "tweaked moments" when the rounded barycenter position does not correspond to an island pixel and use fudge_max_pix times the maximum pixel value instead.
@AntoniaR thanks for catching this, this is a serious error, which was not caught by our extensive regression tests with up to 167,000 artificial sources. But these sources were "well formed", such that the error did not occur.
Perhaps I could include this image in a unit test, but I am not sure how to implement that without ground truth data.
Well, the unit test should perhaps assert that no derived peak brightness should be, say, 20% higher than the maximum pixel value over the entire image, but that would be a pretty coarse test.
Some data for my future reference, selecting island data for derived peak brightnesses > 100 Jy/beam, from this command: pyse GRB201006A_final_2min_srcs-t0021-image-pb.fits --force-beam --vectorized --back-size-x 50 --back-size-y 50:
Activity
HannoSpreeuw commentedon Nov 27, 2025
I think I found the source of the problem.
To derive the peak brightness, tweaked moments takes the pixel value at the rounded barycenter position and extrapolates that to the barycenter position.
That extrapolation can be based on the (forced) beam or based on the measured source shape. It is an extrapolation over a subtended angle at the subpixel level.
In some edge cases the rounded barycenter positon is not an island pixel.
In that case, tweaked moments is still applied, but the maximum pixel value and the position of that pixel are used to extrapolate from. This appeared to work well.
All the problems seem to occur when the island of pixels is relatively wide, when the rounded barycenter position is not an island pixel and the maximum pixel position is far from the island barycenter. That is rare, but can occur with an extended source with a relatively flat brightness distribution. The extrapolation then leads to incredibly large derived peak brightness, but likely only for forced beam measurements: for free shape the measured axes will be large such that the extrapolation will not lead to large values.
I guess the answer should be that we should not apply "tweaked moments" when the rounded barycenter position does not correspond to an island pixel and use
fudge_max_pixtimes the maximum pixel value instead.@AntoniaR thanks for catching this, this is a serious error, which was not caught by our extensive regression tests with up to 167,000 artificial sources. But these sources were "well formed", such that the error did not occur.
Perhaps I could include this image in a unit test, but I am not sure how to implement that without ground truth data.
Well, the unit test should perhaps assert that no derived peak brightness should be, say, 20% higher than the maximum pixel value over the entire image, but that would be a pretty coarse test.
Some data for my future reference, selecting island data for derived peak brightnesses > 100 Jy/beam, from this command:
pyse GRB201006A_final_2min_srcs-t0021-image-pb.fits --force-beam --vectorized --back-size-x 50 --back-size-y 50:AntoniaR commentedon Dec 2, 2025
Is this now in the latest version when I update with pip install?
HannoSpreeuw commentedon Dec 2, 2025
Coming up....I'd like to include #181 as well in a new release.
As soon as that MR is settled, I will release.
So within hours or within minutes.
AntoniaR commentedon Dec 2, 2025
Ah - perfect! I was just querying that issue 🙂
Restrict "tweaked moments" for "free shape"