def compute_psi_dx8(self, theta, phi, rad): z = np.dot(self.siam.get(rad),[0, 0, 1]) vecz = qarray.norm(qarray.rotate(self.qsatgal_interp, z)) e_phi = np.hstack([-np.sin(phi)[:,np.newaxis], np.cos(phi)[:,np.newaxis], np.zeros([len(phi),1])]) e_theta = np.hstack([(np.cos(theta)*np.cos(phi))[:,np.newaxis], (np.cos(theta)*np.sin(phi))[:,np.newaxis], -np.sin(theta)[:,np.newaxis]]) psi = np.arctan2(-qarray.arraylist_dot(vecz, e_phi), -qarray.arraylist_dot(vecz, e_theta)) return psi.flatten()
def relativistic_add(v,u): #http://en.wikipedia.org/wiki/Velocity-addition_formula v2 = qarray.arraylist_dot(v,v) c2 = physcon.c ** 2 v_dot_u = qarray.arraylist_dot(v,u) #turn into column vector #if len(v_dot_u) > 1: # v_dot_u = v_dot_u[:,np.newaxis] u_II = v_dot_u / v2 * v u_I_ = u - u_II return (v + u_II + np.sqrt(1 - v2/c2) * u_I_) / (1 + v_dot_u/c2)
def get_4piconv(self, ch, theta, phi, psi, horn_pointing=False): l.info('Computing dipole temperature with 4pi convolver') vel = qarray.amplitude(self.satellite_v).flatten() beta = vel / physcon.c gamma = 1./np.sqrt(1-beta**2) unit_vel = self.satellite_v/vel[:,None] if horn_pointing: # psi comes from the S channel, so there is no need # to remove psi_pol psi_nopol = psi else: # remove psi_pol psi_nopol = psi - np.radians(ch.get_instrument_db_field("psi_pol")) # rotate vel to ecliptic # phi around z #ecl_rotation = qarray.rotation([0,0,1], -phi) # theta around y ecl_rotation = qarray.norm( qarray.mult( qarray.rotation([0,0,1], -psi_nopol) , qarray.mult( qarray.rotation([0,1,0], -theta) , qarray.rotation([0,0,1], -phi) ) )) # psi around z #ecl_rotation = qarray.mult(qarray.rotation([0,0,1], -psi) , ecl_rotation) # vel in beam ref frame vel_rad = qarray.rotate(ecl_rotation, unit_vel) cosdir = qarray.arraylist_dot(vel_rad, self.beam_sum[ch.tag]).flatten() #return beta * cosdir * T_CMB return (1. / ( gamma * (1 - beta * cosdir ) ) - 1) * T_CMB
def get(self, ch, vec, maximum=False): l.info('Computing dipole temperature') #T_dipole_CMB = doppler_factor(qarray.arraylist_dot(self.satellite_v,vec).flatten()) * T_CMB vel = qarray.amplitude(self.satellite_v).flatten() beta = vel / physcon.c gamma=1/np.sqrt(1-beta**2) if maximum: cosdir = 1 else: cosdir = qarray.arraylist_dot(qarray.norm(self.satellite_v), vec).flatten() T_dipole_CMB = T_CMB / (gamma * ( 1 - beta * cosdir )) #T_dipole_CMB = T_CMB * (1 - beta * cosdir ) if self.K_CMB: return T_dipole_CMB - T_CMB else: T_dipole_RJ = ch.Planck_to_RJ( T_dipole_CMB ) - ch.Planck_to_RJ(T_CMB) return T_dipole_RJ
def get_fourpi_prod(self, vel_rad, comps, ch): return qarray.arraylist_dot(vel_rad, [self.fourpi[comp][ch.tag] for comp in comps]).flatten()
pixels = np.tile(pix_1det, ndet) # polarization weights bore_v_proj_ortog = np.hstack([ -bore_v[:, [1]], bore_v[:, [0]], np.zeros(len(bore_v))[:, np.newaxis] ]) bore_v_proj_ortog /= np.linalg.norm(bore_v_proj_ortog, axis=1)[:, np.newaxis] local_north_v = np.cross(bore_v, bore_v_proj_ortog) bore_quat_inv = qa.inv(bore_quat) local_north_v_fp = qa.rotate(bore_quat_inv, local_north_v) psi_ref = np.arccos(qa.arraylist_dot(local_north_v_fp, z_axis).flatten()) psi_ref[np.isnan(psi_ref)] = 0 psi = { "1A": psi_ref, "1B": psi_ref + np.pi / 2, "2A": psi_ref + np.pi / 4, "2B": psi_ref + np.pi * 3 / 4, } del pix_1det, bore_v, rot_spin, bore_quat_inv, local_north_v_fp, local_north_v, bore_v_proj_ortog pars = {} pars["base_first"] = 60.0 pars["fsample"] = fsample pars["nside_map"] = nside pars["nside_cross"] = nside // 2
def test_arraylist_dot_multidim(self): result = np.hstack(np.dot(v1,v2) for v1,v2 in zip(self.vec2, self.vec2+1))[:,np.newaxis] np.testing.assert_array_almost_equal(qarray.arraylist_dot(self.vec2, self.vec2 +1), result)
def test_arraylist_dot_1dimbymultidim(self): np.testing.assert_array_almost_equal(qarray.arraylist_dot(self.vec2, self.vec), np.dot(self.vec2,self.vec)[:,np.newaxis])
def test_arraylist_dot_onedimarrays(self): np.testing.assert_array_almost_equal(qarray.arraylist_dot(self.vec, self.vec +1), np.dot(self.vec, self.vec +1))
# polarization weights det_v_proj_ortog = np.hstack([ -det_v[:, [1]], det_v[:, [0]], np.zeros(len(det_v))[:, np.newaxis] ]) det_v_proj_ortog /= np.linalg.norm(det_v_proj_ortog, axis=1)[:, np.newaxis] local_north_v = np.cross(det_v, det_v_proj_ortog) det_quat_inv = qa.inv(bore_quat) local_north_v_fp = qa.rotate(det_quat_inv, local_north_v) loc_pol_v = qa.rotate(np.array(fp[det]["quat"]), x_axis)[0] loc_pol_v_z = qa.rotate(qa.rotation(y_axis, -np.pi / 2), loc_pol_v) psi[det] = np.arccos( qa.arraylist_dot(local_north_v_fp, loc_pol_v_z).flatten()) psi[det][np.isnan(psi[det])] = 0 pars = {} pars["base_first"] = 60.0 pars["fsample"] = fsample pars["nside_map"] = nside pars["nside_cross"] = nside // 2 pars["nside_submap"] = nside // 4 pars["write_map"] = True pars["write_binmap"] = True pars["write_matrix"] = True pars["write_wcov"] = True pars["write_hits"] = True pars["write_leakmatrix"] = True