Skip to content

Fix statistics of the residual image#299

Open
AlexKurek wants to merge 6 commits into
lofar-astron:masterfrom
AlexKurek:Fix-statistics-of-the-residual-image
Open

Fix statistics of the residual image#299
AlexKurek wants to merge 6 commits into
lofar-astron:masterfrom
AlexKurek:Fix-statistics-of-the-residual-image

Conversation

@AlexKurek

@AlexKurek AlexKurek commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

First:
resid_gaus = cp(img.ch0_arr)

Later the algorithm checks if the mask is defined. If it is, it injects "new" NaNs into resid_gaus

if isinstance(img.mask_arr, N.ndarray):
    pix_masked = N.where(img.mask_arr == True)
    model_gaus[pix_masked] = N.nan
    resid_gaus[pix_masked] = N.nan (1)

The algorithm tries to isolate the non-Nan pixels:
resid_gaus_non_masked = resid_gaus[N.where(~N.isnan(img.ch0_arr))
The problem is, that it searches for the pixels that are not NaN in the original image. But "other" NaNs were added to resid_gaus in (1). So resid_gaus_non_masked still may have NaNs. In that case later N.mean(), N.std() etc. will return NaN-s for the entire array.

EDIT:
Reverted Same for shapelets since it crashes the test. Maybe lets stick to resid_gaus in this PR.

@AlexKurek

Copy link
Copy Markdown
Contributor Author

The test is failing for unrelated reasons ( #309 (comment) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant