Skip to content

Fix total_flux computation#295

Open
AlexKurek wants to merge 3 commits into
lofar-astron:masterfrom
AlexKurek:Fix-total-flux-computation
Open

Fix total_flux computation#295
AlexKurek wants to merge 3 commits into
lofar-astron:masterfrom
AlexKurek:Fix-total-flux-computation

Conversation

@AlexKurek

@AlexKurek AlexKurek commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Background noise within the bounding box (but outside the island) was included in the island's total flux. To fix this, we mask the area outside the island.
There are a lot of differences in the .gaul file after this.

@AlexKurek

AlexKurek commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

This is how self.image[in_bbox_and_unmasked] currently looks. It confirms, that total flux of the bounding box is computed, not the total flux of a source.

Adding this:

Its primary use is a container for all kinds of data describing island.
    """
    _img_save_count = 0

    def __init__(self, img, mask, mean, rms, labels, bbox, idx,
                 beamarea, origin=None, noise_mask=None, copy=False):

and this:

        self.islmean = bbox_mean_im[in_bbox_and_unmasked].mean()

        if Island._img_save_count < 5:
            import matplotlib.pyplot as plt
            plot_data = N.full(self.image.shape, N.nan)
            plot_data[in_bbox_and_unmasked] = self.image[in_bbox_and_unmasked]
            
            plt.figure(figsize=(6, 5))
            plt.imshow(plot_data, origin='lower', cmap='viridis')
            plt.colorbar(label='Flux')
            plt.title(f'Island ID: {idx}')

            plt.savefig(f'island_{Island._img_save_count}.png', bbox_inches='tight')
            plt.close()
            
            Island._img_save_count += 1

        self.total_flux = N.nansum(self.image[in_bbox_and_unmasked])/beamarea

will show:
island_0
island_1
island_2
island_3
island_4

@AlexKurek

Copy link
Copy Markdown
Contributor Author

After this PR:
island_0
island_1
island_2
island_3
island_4

Tagging @gmloose since you may be interested to see this.

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