コード例 #1
0
ファイル: test_chealpix2.c プロジェクト: bkloppenborg/simtoi
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;
}
コード例 #2
0
ファイル: pg_healpix.c プロジェクト: segasai/pg_healpix
Datum pgheal_ang2ipix_nest(PG_FUNCTION_ARGS)
{

	q3c_ipix_t nside = PG_GETARG_INT64(0);
	q3c_coord_t ra = PG_GETARG_FLOAT8(1);
	q3c_coord_t dec = PG_GETARG_FLOAT8(2);
	q3c_ipix_t ipix;
	q3c_coord_t theta;
	q3c_coord_t phi;
	if ((!isfinite(ra))||(!isfinite(dec)))
	{
		PG_RETURN_NULL();
	}
	get_theta_phi(ra,dec, &theta, &phi);
	nside_check(nside);
	angle_check(theta);
	ang2pix_nest(nside, theta, phi, &ipix);
	PG_RETURN_INT64(ipix);
}
コード例 #3
0
/// Finds pixels on the surface of the sphere using sphere-sphere intersection
/// testing.
void CHealpixSpheroid::FindPixels(double radius, double theta, double phi,
			double d_radius, double d_theta, double d_phi,
			vector<unsigned int> &pixels_ids)
{
	// Look up the (x,y,z) position of the target (r, theta, phi) center.
	long target_pixel = 0;
	const unsigned int n_sides = pow(2, mParams["n_side_power"].getValue());
	ang2pix_nest(n_sides, theta, phi, &target_pixel);
	double pixel_radius = pixel_radii[target_pixel];

	vec3 temp = pixel_xyz[target_pixel];

	double x = pixel_radius * cos(phi) * sin(theta);
	double y = pixel_radius * sin(phi) * sin(theta);
	double z = pixel_radius * cos(theta);

	vec3 target_xyz = vec3(x,y,z);

//	cout << "us :   :" << target_xyz.x << " " << target_xyz.y << " " << target_xyz.z << endl;

	// Compute the maximum allowable distance
	double polar_radius = mParams["r_pole"].getValue();
	double target_radius = polar_radius * std::sqrt(d_theta * d_theta + d_phi * d_phi);

	vec3 t_pix_xyz;

	for(unsigned int i = 0; i < mPixelTemperatures.size(); i++)
	{
		t_pix_xyz = pixel_xyz[i];
		t_pix_xyz *= pixel_radii[i];

		double distance = length(target_xyz - t_pix_xyz);

		if(distance <= target_radius)
			pixels_ids.push_back(i);
	}

}