def get_coord(name, path, rotate=False): """Retrieves the named coord. If rotate is true, rotates into the frame in which chi is parallel with the z axis. """ r_array = r(path, rotate) #if rotate==False: chi_array = chi_inertial(path, rotate) # else: # zhat = np.array([0., 0., 1.]) # chi_array = stride_tricks.as_strided(zhat,strides=(0,1*8), # shape=r_array.shape) if name == "t": coord = t(path) elif name == "xA": f = h5py.File(path, 'r') return f["/AhA.dir"]["CoordCenterInertial.dat"].value[:, 1:] elif name == "xB": f = h5py.File(path, 'r') return f["/AhB.dir"]["CoordCenterInertial.dat"].value[:, 1:] elif name == "rvec": coord = r_array elif name == "x": coord = r_array[:, 0] elif name == "y": coord = r_array[:, 1] elif name == "z": coord = r_array[:, 2] elif name == "r": coord = la.norm(r_array, axis=1) elif name == "r2": coord = r_array[:, 0]**2 + r_array[:, 1]**2 + r_array[:, 2]**2 elif name == "rho": rho = r_array rho[:, 2] = 0. coord = rho elif name == "chi": coord = chi_array elif name == "chimag": coord = la.norm(chi_array, axis=1) elif name == "chihat": coord = np.zeros(chi_array.shape) chimag = la.norm(chi_array, axis=1) coord[:, 0] = chi_array[:, 0] / chimag coord[:, 1] = chi_array[:, 1] / chimag coord[:, 2] = chi_array[:, 2] / chimag elif name == "phi": coord = np.arccos(cosphi(r_array)) elif name == "cosphi": coord = cosphi(r_array) elif name == "phi_phase": coord = bbh.accumulating_phi(r_array) elif name == "costheta": coord = bbh.cosang(chi_array, r_array) elif name == "theta": coord = np.arccos(bbh.cosang(chi_array, r_array)) elif name == "theta_phase": coord = bbh.phase(r_array, chi_array) else: raise ValueError("Invalid coordinate name '" + name + "'") return coord
def costheta(rvec, chi): """ Return the angle between chi and rvec. """ chi_ref = stride_tricks.as_strided(np.array(chi), strides=(0, 1 * 8), shape=rvec.shape) return bbh.cosang(rvec, chi_ref)
def _set_values(self, t, V): self.t = np.copy(t) self.length = len(t) zaxis = stride_tricks.as_strided(np.array([0., 0., 1.]), strides=(0, 1 * 8), shape=(self.length, 3)) self.sinangles = bbh.sinang3D(V, zaxis) self.cosangles = bbh.cosang(V, zaxis) axes_raw = np.cross(V, zaxis) self.axes = bbh.unit_vector(axes_raw)
def cosphi(rvec): rhovec, ref = rhoref(rvec) return bbh.cosang(rhovec, ref)
def costheta_r_chi(r_array, chi_array): #main spinA = chi_inertial(fname) return bbh.cosang(spinA, r_array)
def cosphi(r_array): rho = r_array[:, 0:2] rho_ref = stride_tricks.as_strided(rho[0, :], strides=(0, 1 * 8), shape=rho.shape) return bbh.cosang(rho, rho_ref)