ratt-ru / breizorro

Image masking tool(s) possibly of Breton spiritual origin
GNU General Public License v3.0
5 stars 2 forks source link

add option to number islands in mask #2

Closed o-smirnov closed 3 years ago

o-smirnov commented 4 years ago

I think this is a scipy one-liner

twillis449 commented 3 years ago

What I've wanted for the work I've been doing is to sort the masks by the area they cover as the objects I've been interested in are usually the largest ones in the field - but not always :(

IanHeywood commented 3 years ago

I think this can also be used to automatically set the box size by plugging in some hueristics. Here are the top five island sizes from five different fields in a ThunderKAT X-ray binary monitoring block:

img_1589683557_sdp_l0_1024ch_GRS1915+105.ms_datablind-MFS-image.mask.fits 609
Top five island sizes:
[60474. 44847. 20788. 15890. 10520.]

img_1589683557_sdp_l0_1024ch_4U1630.ms_datablind-MFS-image.mask.fits 1170
Top five island sizes:
[105655.  34736.  33450.  30092.  16009.]

img_1589683557_sdp_l0_1024ch_MAXIJ1348.ms_datablind-MFS-image.mask.fits 616
Top five island sizes:
[52515. 40128. 34811. 22786. 22178.]

img_1589683557_sdp_l0_1024ch_MAXIJ1820.ms_datablind-MFS-image.mask.fits 950
Top five island sizes:
[2427. 2194. 1825. 1590. 1542.]

img_1589683557_sdp_l0_1024ch_GX_339-4.ms_datablind-MFS-image.mask.fits 649
Top five island sizes:
[1435. 1234. 1105. 1018.  959.]

As a first go:

if biggest_island < 5000:
    box_size = 50
else:
    box_size = 350

would automatically make this block way more pipelineable for a fixed sigma.

IanHeywood commented 3 years ago

I implemented this in this script:

https://github.com/IanHeywood/oxkat/blob/primaries/tools/pyMakeMask.py

It does as good a job as usual on fields dominated by compact features, but when it detects a large island it remakes the mask with a box size of 500. This results in slightly shallower albeit much cleaner masks for fields dominated by extended stuff.

Should be easy to implement such a thing here if needed. I am testing it out inside an imaging / selfcal loop now.

IanHeywood commented 3 years ago

Just noting another idea here for automatically masking complex fields: try running the mask maker on (2+) well-separated sub-bands and using logical AND on the results. Spurious sidelobe-related features should move radially in the sub-band mask, real emission should be stationary.