Healpix C++  3.83
syn_alm_cxx_module.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 /*
28  * Copyright (C) 2003-2015 Max-Planck-Society
29  * Author: Martin Reinecke
30  */
31 
32 #include "xcomplex.h"
33 #include "paramfile.h"
34 #include "planck_rng.h"
35 #include "alm.h"
36 #include "alm_fitsio.h"
37 #include "powspec.h"
38 #include "powspec_fitsio.h"
39 #include "alm_powspec_tools.h"
40 #include "fitshandle.h"
41 #include "levels_facilities.h"
42 #include "lsconstants.h"
43 #include "announce.h"
44 
45 using namespace std;
46 
47 namespace {
48 
49 template<typename T> void syn_alm_cxx (paramfile &params)
50  {
51  int nlmax = params.template find<int>("nlmax");
52  int nmmax = params.template find<int>("nmmax",nlmax);
53  planck_assert(nmmax<=nlmax,"nmmax must not be larger than nlmax");
54  string infile = params.template find<string>("infile");
55  string outfile = params.template find<string>("outfile");
56  int rand_seed = params.template find<int>("rand_seed");
57  double fwhm = arcmin2rad*params.template find<double>("fwhm_arcmin",0.);
58  bool polarisation = params.template find<bool>("polarisation");
59  bool full_ps = params.template find<bool>("full_ps",false);
60 
61  PowSpec powspec;
62  int nspecs = polarisation ? (full_ps ? 6 : 4 ) : 1;
63  read_powspec_from_fits (infile, powspec, nspecs, nlmax);
64  powspec.smoothWithGauss(fwhm);
65 
66  planck_rng rng(rand_seed);
67 
68  if (polarisation)
69  {
71  almT(nlmax,nmmax), almG(nlmax,nmmax), almC(nlmax,nmmax);
72  create_alm_pol (powspec, almT, almG, almC, rng);
73  write_Alm_to_fits(outfile,almT,almG,almC,nlmax,nmmax,planckType<T>());
74  }
75  else
76  {
77  Alm<xcomplex<T> > almT(nlmax,nmmax);
78  create_alm (powspec, almT, rng);
79  write_Alm_to_fits(outfile,almT,nlmax,nmmax,planckType<T>());
80  }
81  }
82 
83 } // unnamed namespace
84 
85 int syn_alm_cxx_module (int argc, const char **argv)
86  {
87  module_startup ("syn_alm_cxx", argc, argv);
88  paramfile params (getParamsFromCmdline(argc,argv));
89 
90  bool dp = params.find<bool> ("double_precision",false);
91  dp ? syn_alm_cxx<double>(params) : syn_alm_cxx<float>(params);
92  return 0;
93  }
void write_Alm_to_fits(fitshandle &out, const Alm< xcomplex< T > > &alms, int lmax, int mmax, PDT datatype)
Definition: alm_fitsio.cc:151
void create_alm_pol(const PowSpec &ps, Alm< xcomplex< T > > &almT, Alm< xcomplex< T > > &almG, Alm< xcomplex< T > > &almC, planck_rng &rng)
Definition: alm.h:88
void read_powspec_from_fits(fitshandle &inp, PowSpec &powspec, int nspecs, int lmax)
void create_alm(const PowSpec &powspec, Alm< xcomplex< T > > &alm, planck_rng &rng)

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