File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -499,6 +499,27 @@ def unittwist2_norm(S):
499499
500500 return (S / th , th )
501501
502+ def wrap_0_pi (theta ):
503+ r"""
504+ Wrap angle to range [0, pi]
505+
506+ :param theta: input angle
507+ :type theta: scalar or ndarray
508+ :return: angle wrapped into range :math:`[0, \pi)`
509+
510+ This is used to fold angles of colatitude. If zero is the angle of the
511+ north pole, colatitude increases to :math:`\pi` at the south pole then
512+ decreases to :math:`0` as we head back to the north pole.
513+ """
514+ n = (theta / np .pi )
515+ if isinstance (n , np .ndarray ):
516+ n = astype (int )
517+ else :
518+ n = int (n )
519+
520+ return np .where (n & 1 == 0 , theta - n * np .pi , (n + 1 ) * np .pi - theta )
521+
522+
502523def wrap_0_2pi (theta ):
503524 r"""
504525 Wrap angle to range [0, 2pi)
You can’t perform that action at this time.
0 commit comments