Exemple #1
0
// Create a quadrilateral window function of ones (rest is zero) given an Nside, and write to outfile:
// Shape is hard-coded below:
void CreateWindow(std::string outfile, int nside) {
  Healpix_Map<MAP_PRECISION> Map;
  std::vector<pointing> vertex;
  std::vector<int> pixlist;
  rangeset<int> pixset;
  int npixels, i, count;
  // Here you define the vertices of the square in radians (theta, phi):
  //              top-left                top-right              bottom-left            bottom-right
  //pointing v1(1.483529, 1.483529), v2(1.483529, 1.658063), v3(1.658063, 1.483529), v4(1.658063, 1.658063); // 10deg x 10deg.
  pointing v1(1.540566, 1.540566), v2(1.540566, 1.601026), v3(1.601026, 1.540566), v4(1.601026, 1.601026); // Square of 12deg^2:
  
  // Create window function in Healpix map:
  vertex.push_back(v1); vertex.push_back(v2); vertex.push_back(v4); vertex.push_back(v3);
  Map.SetNside(nside, RING);
  Map.query_polygon(vertex, pixset);
  pixset.toVector(pixlist);
  npixels = 12*Map.Nside()*Map.Nside();
  for (i=0; i<npixels; i++) Map[i]=0.0;
  count = 0;
  for (i=0; i<pixlist.size(); i++) {
    Map[pixlist[i]]=1.0;
    count++;
  }
  // Print total area:
  printf("Total area (deg^2): %g\n",((double)count)/((double)npixels)*41252.96125);
  // Output file:
  write_Healpix_map_to_fits("!"+outfile, Map, planckType<MAP_PRECISION>());
}