I want to crop a FITS image area between two circles. For example, I want to crop out an area in the FITS image between circles of radii of R1 and R2. How do I go about it?
Asked
Active
Viewed 907 times
1
-
By "crop" do you mean mask, as in an [aperture](https://photutils.readthedocs.io/en/stable/aperture.html)? – Iguananaut Jul 01 '20 at 11:25
-
I'm working with FITS images, where I've to estimate the counts in an area between two concentric circles of different radii. Can you help me? – SlightDecoy Jul 02 '20 at 12:04
1 Answers
2
You will probably find what you're looking for in the regions package: https://astropy-regions.readthedocs.io/en/latest/
It can create regions with pixel or sky coordinates, combine them, and create pixel masks:
In [1]: from regions import CirclePixelRegion, PixCoord
In [2]: c1 = CirclePixelRegion(center=PixCoord(6, 6), radius=3)
In [3]: c2 = CirclePixelRegion(center=PixCoord(9, 9), radius=3)
In [4]: (c1 & c2).to_mask().data
Out[4]:
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
In [5]: (c1 | c2).to_mask().data
Out[5]:
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])

saimn
- 443
- 2
- 10