ratt-ru / pfb-imaging

Preconditioned forward/backward clean algorithm
MIT License
7 stars 5 forks source link

Direction dependent degrid with region files #115

Open landmanbester opened 1 week ago

landmanbester commented 1 week ago

I started adding support for degridding different regions to separate columns in the ddpredict branch. The way I set it up is to pass in a single region file possibly containing multiple regions. The number of columns that will end up in the MS is 1 + the number of regions in the file. The part of the model not contained in any regions will be written to model-column and each region will go into f'{model-column}{i}' with i labelling the region number. Overlapping regions are not supported and the degrid application should raise an error if this is detected. I am open to suggestions for modifications/additions to this functionality.

@bngcebetsha note if you are using CORRECTED_DATA you should be able to subtract part of the model by running the init application with --data-column 'CORRECTED_DATA - MODEL_COLUMN_TO_SUBTRACT'. I haven't yet added functionality to subtract multiple columns or do on the fly gain application in this case. You will need to use QuartiCal if you need to do that

landmanbester commented 1 week ago

I think this works as advertised, at least it does on my simulated data. There is something I don't quite understand though viz. when converting the regions to masks I need to do the following

pixel_region = region.to_pixel(wcs)
region_mask = pixel_region.to_mask().to_image((ny, nx))
region_mask = region_mask.T

i.e. I need a transpose. I suspect this has got something to do with the wgridder conventions that are being used here

https://github.com/ratt-ru/pfb-imaging/blob/94b36eccc41f7f3ebbd5e9006d67f54642fd11bf/pfb/operators/gridder.py#L24

but I'm not going to dig into that at this point. Note that the current implementation is a bit wasteful in that it just degrids the full image after zeroing components outside of the mask. We could improve this by only degridding the region (i.e. a smaller image) but that requires specifying the center of the region and therefore also getting the conventions to line up

bngcebetsha commented 1 week ago

I started adding support for degridding different regions to separate columns in the ddpredict branch. The way I set it up is to pass in a single region file possibly containing multiple regions. The number of columns that will end up in the MS is 1 + the number of regions in the file. The part of the model not contained in any regions will be written to model-column and each region will go into f'{model-column}{i}' with i labelling the region number. Overlapping regions are not supported and the degrid application should raise an error if this is detected. I am open to suggestions for modifications/additions to this functionality.

@bngcebetsha note if you are using CORRECTED_DATA you should be able to subtract part of the model by running the init application with --data-column 'CORRECTED_DATA - MODEL_COLUMN_TO_SUBTRACT'. I haven't yet added functionality to subtract multiple columns or do on the fly gain application in this case. You will need to use QuartiCal if you need to do that

Thanks for the feature @landmanbester - I will try the branch out and if I run into issues will message you on chat...thanks again.