Returns the effective precession spin from mass1, mass2, spin1x,
    spin1y, spin2x, and spin2y.
166305
def chi_p(mass1, mass2, spin1x, spin1y, spin2x, spin2y):
    
    xi1 = secondary_xi(mass1, mass2, spin1x, spin1y, spin2x, spin2y)
    xi2 = primary_xi(mass1, mass2, spin1x, spin1y, spin2x, spin2y)
    return chi_p_from_xi1_xi2(xi1, xi2)
1268415
def spin1_polar(self):
        """"""
        return coordinates.cartesian_to_spherical_polar(
                                     self.spin1x, self.spin1y, self.spin1z)
635414
public Vector getSpinVector(double theta, double phi) {
        Vector spinvector = new Vector(3);
        spinvector.vector[0] = Math.sin(theta) * Math.cos(phi);
        spinvector.vector[1] = Math.sin(theta) * Math.sin(phi);
        spinvector.vector[2] = Math.cos(phi);
        return spinvector;
    }
960641
def pointing_vector(self, s, time):
        
        t = time - self._t0
        longitude = self._longitude + self._dlongdt * t

        # define the basis vectors in the spin (primed) coordinates in terms of
        # the Roche coordinates.
        # ez' = s
        # ex' =  (ex - s(s.ex)) /|i - s(s.ex)|
        # ey' = s x ex'
        ex = np.array([1., 0., 0.])
        ezp = s
        exp = (ex - s*np.dot(s,ex))
        eyp = np.cross(s, exp)

        return np.sin(self._colat)*np.cos(longitude)*exp +\
                  np.sin(self._colat)*np.sin(longitude)*eyp +\
                  np.cos(self._colat)*ezp
553459
def tau3_from_mass1_mass2(mass1, mass2, f_lower):
    
    """
    mtotal = mass1 + mass2
    eta = eta_from_mass1_mass2(mass1, mass2)
    return tau3_from_mtotal_eta(mtotal, eta, f_lower)
696166
def chi_eff(mass1, mass2, spin1z, spin2z):
    """"""
    return (spin1z * mass1 + spin2z * mass2) / (mass1 + mass2)
605994
def chi_p_from_spherical(mass1, mass2, spin1_a, spin1_azimuthal, spin1_polar,
                         spin2_a, spin2_azimuthal, spin2_polar):
    
    spin1x, spin1y, _ = _spherical_to_cartesian(
        spin1_a, spin1_azimuthal, spin1_polar)
    spin2x, spin2y, _ = _spherical_to_cartesian(
        spin2_a, spin2_azimuthal, spin2_polar)
    return chi_p(mass1, mass2, spin1x, spin1y, spin2x, spin2y)
269296
def rotation_coefs(self):
        
        return [np.cos(self.bearing_rads),
                np.sin(self.bearing_rads),
                -1.0*np.sin(self.bearing_rads),
                np.cos(self.bearing_rads)]
292496
def spin_to_binary(linear, quadratic, offset):
        

        # the linear biases are the easiest
        new_linear = {v: 2. * bias for v, bias in iteritems(linear)}

        # next the quadratic biases
        new_quadratic = {}
        for (u, v), bias in iteritems(quadratic):
            new_quadratic[(u, v)] = 4. * bias
            new_linear[u] -= 2. * bias
            new_linear[v] -= 2. * bias

        # finally calculate the offset
        offset += sum(itervalues(quadratic)) - sum(itervalues(linear))

        return new_linear, new_quadratic, offset
488711
def spin_sx(self):
        """"""
        return conversions.secondary_spin(self.mass1, self.mass2, self.spin1x,
                                        self.spin2x)
1014793
def rot1(theta):
    
    return np.array([
        [1, 0, 0],
        [0, np.cos(theta), np.sin(theta)],
        [0, -np.sin(theta), np.cos(theta)]
    ])
117059
def angular_separation(lonp1, latp1, lonp2, latp2):
    

    xp1, yp1, zp1 = lonlat2xyz(lonp1, latp1)
    xp2, yp2, zp2 = lonlat2xyz(lonp2, latp2)

    ## dot products to obtain angles

    angles = np.arccos((xp1 * xp2 + yp1 * yp2 + zp1 * zp2))

    ## As this is a unit sphere, angle = length

    return angles
200378
def phi_s(spin1x, spin1y, spin2x, spin2y):
    
    phi1 = phi_from_spinx_spiny(spin1x, spin1y)
    phi2 = phi_from_spinx_spiny(spin2x, spin2y)
    return (phi1 + phi2) % (2 * numpy.pi)
1293296
def give_dots(R, r, r_, resolution=2*PI/1000, spins=50):
    '''
    '''
    thetas = np.arange(0, 2*PI*spins, resolution)
    Rr = R - r
    x = Rr * np.cos(thetas) + r_*np.cos(Rr / r * thetas)
    y = Rr * np.sin(thetas) - r_*np.sin(Rr / r * thetas)
    return x, y
117601
def mass_2d(self,R,Rs,rho0,r_trunc):

        

        x = R / Rs
        tau = r_trunc / Rs
        gx = self._g(x,tau)
        m_2d = 4 * rho0 * Rs * R ** 2 * gx / x ** 2 * np.pi
        return m_2d
1062527
def chi_eff_from_spherical(mass1, mass2, spin1_a, spin1_polar,
                           spin2_a, spin2_polar):
    """"""
    spin1z = spin1_a * numpy.cos(spin1_polar)
    spin2z = spin2_a * numpy.cos(spin2_polar)
    return chi_eff(mass1, mass2, spin1z, spin2z)
745740
private static int spinsFor(Node pred, boolean haveData) {
        if (MP && pred != null) {
            if (pred.isData != haveData)      // phase change
                return FRONT_SPINS + CHAINED_SPINS;
            if (pred.isMatched())             // probably at front
                return FRONT_SPINS;
            if (pred.waiter == null)          // pred apparently spinning
                return CHAINED_SPINS;
        }
        return 0;
    }