I have a set of close of 10,000 points on the sky. They are plotted using the RA (right ascension) and DEC (declination) on the sky. When plotted, they take the shape of a circle.
What I would like to do is to slice the circle into 8 equal parts and remove each part one at a time and do some calculations using the remaining parts.
To do so I came up with this illustration in mind, i.e. slicing them using the arcs.
I know that the equation of the arc is given by:
S = r * theta
where
r --> radius
theta --> angle (in our case 45 degrees)
I would somehow like to do this like:
slice1 = []
for a,b in zip(ra,dec):
if a>some value and a<some value and b>some value and b<some value:
slice1.append(a,b)
If they were a square, it becomes really easy, and the above equation can immediately be applied.
So once I have my slice, I can then do a numpy.where()
to find out the rest of my circle.
I can easily slice it into four slices by just mentioning the min(RA),max(RA),min(DEC) and max(DEC)
. One such example when I do it for the first quadrant will give me this:
RA>0.0 and RA<max(RA) DEC>0.0 and DEC<max(DEC)
I don't know how to go about doing this in my case (i.e. into 8 quadrants!!), wherein I only have the x,y coordinates of my data points!!
You should probably use math.atan2:
Basically, atan2 returns the angle to the point from the x axis. By dividing it into intervals of pi/4, you get your slices. But beware -
atan2
returns angles between -pi and pi, so you should number your slices from -4 to 3 (or you can add pi to the angle, or convert it in some other way).EDIT: Modifying your code, it would look like this:
You can compute the array of slice numbers directly with with
numpy
operators:meaning:
-pi
...pi
for each point witharctan2
pi
to make it a positive interval0
..N-1
First, find the quadrant using your formula. The octant can then be determined by comparing
abs(x)
withabs(y)
.In the lower octant,
abs(x) >= abs(y)
. The other one hasabs(x) < abs(y)