int main(void) { double theta, phi; double vec[3]; long nside; long ipix, npix, dpix, ip2, ip1; printf("Starting C Healpix pixel routines test\n"); nside = 1024; dpix = 23; /* Find the number of pixels in the full map */ npix = nside2npix(nside); printf("Number of pixels in full map: %ld\n", npix); printf("dpix: %ld\n", dpix); printf("Nest -> ang -> vec -> ang -> Ring -> Nest\n"); for (ipix = 0; ipix < npix; ipix +=dpix) { pix2ang_nest(nside, ipix, &theta, &phi); ang2vec(theta, phi, vec); vec2ang(vec, &theta, &phi); ang2pix_ring(nside, theta, phi, &ip2); ring2nest(nside,ip2,&ip1); if (ip1 != ipix) {printf("Error: %ld %ld %ld %ld\n",nside,ipix,ip2,ip1);} } printf("Ring -> ang -> Nest -> Ring\n"); for (ipix = 0; ipix < npix; ipix +=dpix) { pix2ang_ring(nside, ipix, &theta, &phi); ang2pix_nest(nside, theta, phi, &ip2); nest2ring(nside,ip2,&ip1); if (ip1 != ipix) {printf("Error: %ld %ld %ld %ld\n",nside,ipix,ip2,ip1);} } printf("Nest -> vec -> Ring -> Nest\n"); for (ipix = 0; ipix < npix; ipix +=dpix) { pix2vec_nest(nside, ipix, vec); vec2pix_ring(nside, vec, &ip2); ring2nest(nside,ip2,&ip1); if (ip1 != ipix) {printf("Error: %ld %ld %ld %ld\n",nside,ipix,ip2,ip1);} } printf("Ring -> vec -> Nest -> Ring\n"); for (ipix = 0; ipix < npix; ipix +=dpix) { pix2vec_ring(nside, ipix, vec); vec2pix_nest(nside, vec, &ip2); nest2ring(nside,ip2,&ip1); if (ip1 != ipix) {printf("Error: %ld %ld %ld %ld\n",nside,ipix,ip2,ip1);} } printf("%ld\n", nside); printf("test completed\n\n"); /* Later */ return 0; }
int main() { std::cout << "****** ang2vec ******" << std::endl; double theta = PI / 2; double phi = PI / 2; double vec[3]; ang2vec(theta, phi, vec); displayVec(vec); std::cout << "****** npix2nisde ******" << std::endl; long npix = 786432; std::cout << npix2nside(npix) << std::endl; std::cout << "****** nside2npix ******" << std::endl; long nside = 256; std::cout << nside2npix(nside) << std::endl; std::cout << "****** pix2ang ******" << std::endl; long ipring = 10000; // ipring -> Index_Pixel_Ring pix2ang_ring(nside, ipring, &theta, &phi); std::cout << "theta = " << theta << std::endl; std::cout << "phi = " << phi << std::endl; std::cout << "****** pix2vec ******" << std::endl; pix2vec_ring(nside, ipring, vec); displayVec(vec); std::cout << "****** ang2pix ******" << std::endl; ang2pix_ring(nside, theta, phi, &ipring); std::cout << "ipring = " << ipring << std::endl; std::cout << "****** vec2pix ******" << std::endl; vec2pix_ring(nside, vec, &ipring); std::cout << "ipring = " << ipring << std::endl; std::cout << "****** ring2nest ******" << std::endl; long ipnest; ring2nest(nside, ipring, &ipnest); std::cout << "ipnest = " << ipnest << std::endl; std::cout << "****** nest2ring ******" << std::endl; nest2ring(nside, ipnest, &ipring); std::cout << "ipring = " << ipring << std::endl; }
void he_udgrade(flouble *map_in,long nside_in, flouble *map_out,long nside_out, int nest) { long npix_in=nside2npix(nside_in); long npix_out=nside2npix(nside_out); if(nside_in==nside_out) { long ii; for(ii=0;ii<npix_out;ii++) map_out[ii]=map_in[ii]; } else if(nside_in>nside_out) { long ii; long np_ratio=npix_in/npix_out; double i_np_ratio=1./((double)np_ratio); for(ii=0;ii<npix_out;ii++) { int jj; double tot=0; if(nest) { for(jj=0;jj<np_ratio;jj++) tot+=map_in[jj+ii*np_ratio]; map_out[ii]=tot*i_np_ratio; } else { long inest_out; ring2nest(nside_out,ii,&inest_out); for(jj=0;jj<np_ratio;jj++) { long iring_in; nest2ring(nside_in,jj+np_ratio*inest_out,&iring_in); tot+=map_in[iring_in]; } map_out[ii]=tot*i_np_ratio; } } } else { long ii; long np_ratio=npix_out/npix_in; for(ii=0;ii<npix_in;ii++) { int jj; if(nest) { flouble value=map_in[ii]; for(jj=0;jj<np_ratio;jj++) map_out[jj+ii*np_ratio]=value; } else { long inest_in; flouble value=map_in[ii]; ring2nest(nside_in,ii,&inest_in); for(jj=0;jj<np_ratio;jj++) { long iring_out; nest2ring(nside_out,jj+inest_in*np_ratio,&iring_out); map_out[iring_out]=value; } } } } }