syn_alm_cxx_module.cc

00001 /*
00002  *  This file is part of Healpix_cxx.
00003  *
00004  *  Healpix_cxx is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  Healpix_cxx is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with Healpix_cxx; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  *
00018  *  For more information about HEALPix, see http://healpix.sourceforge.net
00019  */
00020 
00021 /*
00022  *  Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
00023  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00024  *  (DLR).
00025  */
00026 
00027 /*
00028  *  Copyright (C) 2003-2015 Max-Planck-Society
00029  *  Author: Martin Reinecke
00030  */
00031 
00032 #include "xcomplex.h"
00033 #include "paramfile.h"
00034 #include "planck_rng.h"
00035 #include "alm.h"
00036 #include "alm_fitsio.h"
00037 #include "powspec.h"
00038 #include "powspec_fitsio.h"
00039 #include "alm_powspec_tools.h"
00040 #include "fitshandle.h"
00041 #include "levels_facilities.h"
00042 #include "lsconstants.h"
00043 #include "announce.h"
00044 
00045 using namespace std;
00046 
00047 namespace {
00048 
00049 template<typename T> void syn_alm_cxx (paramfile &params)
00050   {
00051   int nlmax = params.template find<int>("nlmax");
00052   int nmmax = params.template find<int>("nmmax",nlmax);
00053   planck_assert(nmmax<=nlmax,"nmmax must not be larger than nlmax");
00054   string infile = params.template find<string>("infile");
00055   string outfile = params.template find<string>("outfile");
00056   int rand_seed = params.template find<int>("rand_seed");
00057   double fwhm = arcmin2rad*params.template find<double>("fwhm_arcmin",0.);
00058   bool polarisation = params.template find<bool>("polarisation");
00059   bool full_ps = params.template find<bool>("full_ps",false);
00060 
00061   PowSpec powspec;
00062   int nspecs = polarisation ? (full_ps ? 6 : 4 ) : 1;
00063   read_powspec_from_fits (infile, powspec, nspecs, nlmax);
00064   powspec.smoothWithGauss(fwhm);
00065 
00066   planck_rng rng(rand_seed);
00067 
00068   if (polarisation)
00069     {
00070     Alm<xcomplex<T> >
00071       almT(nlmax,nmmax), almG(nlmax,nmmax), almC(nlmax,nmmax);
00072     create_alm_pol (powspec, almT, almG, almC, rng);
00073     write_Alm_to_fits(outfile,almT,almG,almC,nlmax,nmmax,planckType<T>());
00074     }
00075   else
00076     {
00077     Alm<xcomplex<T> > almT(nlmax,nmmax);
00078     create_alm (powspec, almT, rng);
00079     write_Alm_to_fits(outfile,almT,nlmax,nmmax,planckType<T>());
00080     }
00081   }
00082 
00083 } // unnamed namespace
00084 
00085 int syn_alm_cxx_module (int argc, const char **argv)
00086   {
00087   module_startup ("syn_alm_cxx", argc, argv);
00088   paramfile params (getParamsFromCmdline(argc,argv));
00089 
00090   bool dp = params.find<bool> ("double_precision",false);
00091   dp ? syn_alm_cxx<double>(params) : syn_alm_cxx<float>(params);
00092   return 0;
00093   }

Generated on Thu Oct 8 14:48:52 2015 for Healpix C++