python同切圆,用相同的段来分割一个圆圈,Python

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.

VtpFp.png

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 asome value and b

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 RA0.0 and DEC

sDGq8.png

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 can compute the array of slice numbers directly with with numpy operators:

sliceno = numpy.int32((pi + numpy.arctan2(Y, X)) * (N / (2*pi)))

meaning:

compute the angle -pi...pi for each point with arctan2

shift by pi to make it a positive interval

rescale to 0..N-1

convert to an integer

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值