Healpix C++  3.83
alice3_main.cc
1 /*
2  * This file is part of Healpix_cxx.
3  *
4  * Healpix_cxx is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Healpix_cxx is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Healpix_cxx; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * For more information about HEALPix, see http://healpix.sourceforge.net
19  */
20 
21 /*
22  * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
23  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
24  * (DLR).
25  */
26 
27 /*! \file alice3.cc
28  * Copyright (C) 2005-2015 David Larson, Max-Planck-Society
29  * \author David Larson \author Martin Reinecke
30  */
31 
32 #include <iostream>
33 #include "alice3.h"
34 #include "announce.h"
35 #include "paramfile.h"
36 #include "healpix_map_fitsio.h"
37 #include "lsconstants.h"
38 #include "arr.h"
39 #include "fitshandle.h"
40 #include "vec3.h"
41 #include "string_utils.h"
42 #include "alm.h"
43 #include "alm_healpix_tools.h"
44 #include "planck_rng.h"
45 #include "healpix_map.h"
46 
47 using namespace std;
48 
49 int main(int argc, const char** argv)
50  {
51  module_startup ("alice3", argc, argv);
52  paramfile params (getParamsFromCmdline(argc,argv));
53 
55  // Load a polarized fits file, with Q and U as the second
56  // and third columns (the standard form).
57  read_Healpix_map_from_fits(params.find<string>("in"), Q, 2, 2);
58  read_Healpix_map_from_fits(params.find<string>("in"), U, 3, 2);
59 
60  int nside = params.find<int>("nside");
61  int steps = params.find<int>("steps",100);
62  double step_radian=arcmin2rad*params.find<double>("step_arcmin",10.);
63  int kernel_steps = params.find<int>("kernel_steps",50);
64  double polmin = params.find<double>("polmin",-1e30),
65  polmax = params.find<double>("polmax",1e30);
66  string out = params.find<string>("out");
67 
68  Healpix_Map<double> th(nside,RING,SET_NSIDE);
69  if (params.param_present("texture"))
70  read_Healpix_map_from_fits(params.find<string>("texture"),th);
71  else
72  {
73  planck_rng rng(params.find<int>("rand_seed",42));
74  if (params.param_present("ell"))
75  {
76  int ell = params.find<int>("ell");
77  if (ell<0) ell=2*nside;
78  Alm<xcomplex<double> > a(ell,ell);
79  a.SetToZero();
80  cout << "Background texture using ell = " << ell << endl;
81 
82  a(ell,0)=fcomplex(rng.rand_gauss(),0.);
83  for (int m=0; m<=ell; m++)
84  { a(ell,m).real(rng.rand_gauss()); a(ell,m).imag(rng.rand_gauss()); }
85  alm2map(a, th);
86  }
87  else
88  {
89  for (int i=0; i<th.Npix(); i++)
90  th[i] = rng.rand_uni() - 0.5;
91  }
92  }
93 
94  Healpix_Map<double> hit(nside,RING,SET_NSIDE),
95  tex(nside,RING,SET_NSIDE),
96  mag(nside,RING,SET_NSIDE);
97 
98  {
99  PolarizationHolder ph;
100  ph.Q = Q;
101  ph.U = U;
102 
103  for (int i=0; i<mag.Npix(); i++)
104  tex[i] = th.interpolated_value(mag.pix2ang(i));
105  write_Healpix_map_to_fits(out+"_background.fits",tex,PLANCK_FLOAT32);
106  }
107 
108  lic_main(Q, U, th, hit, tex, mag, steps, kernel_steps, step_radian, polmin, polmax);
109 
110  write_Healpix_map_to_fits(out+"_texture.fits",tex,PLANCK_FLOAT32);
111  write_Healpix_map_to_fits(out+"_mod_texture.fits",mag,PLANCK_FLOAT32);
112  }
void lic_main(const Healpix_Map< double > &Q, const Healpix_Map< double > &U, const Healpix_Map< double > &th, Healpix_Map< double > &hit, Healpix_Map< double > &tex, Healpix_Map< double > &mag, int steps, int kernel_steps, double step_radian, double polmin, double polmax)
Definition: alice3.cc:176
Definition: alm.h:88
void read_Healpix_map_from_fits(fitshandle &inp, Healpix_Map< T > &map, int colnum)
void write_Healpix_map_to_fits(fitshandle &out, const Healpix_Map< T > &map, PDT datatype)
void alm2map(const Alm< xcomplex< T > > &alm, Healpix_Map< T > &map, bool add_map)

Generated on Wed Nov 13 2024 12:18:30 for Healpix C++