NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

syn_alm_cxx.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.jpl.nasa.gov
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, 2004, 2005 Max-Planck-Society
00029  *  Author: Martin Reinecke
00030  */
00031 
00032 #include "xcomplex.h"
00033 #include "cxxutils.h"
00034 #include "paramfile.h"
00035 #include "simparams.h"
00036 #include "planck_rng.h"
00037 #include "alm.h"
00038 #include "alm_fitsio.h"
00039 #include "fitshandle.h"
00040 #include "powspec.h"
00041 #include "powspec_fitsio.h"
00042 #include "alm_powspec_tools.h"
00043 
00044 using namespace std;
00045 
00046 template<typename T> void syn_alm_cxx (paramfile &params, simparams &par)
00047   {
00048   par.add_comment("-----------------------");
00049   par.add_comment(" ** syn_alm_cxx 1.0 **");
00050   par.add_comment("-----------------------");
00051 
00052   int nlmax = params.template find<int>("nlmax");
00053   par.add("nlmax","NLMAX",nlmax,"maximum l of the alms");
00054   int nmmax = params.template find<int>("nmmax",nlmax);
00055   par.add("nmmax","NMMAX",nmmax,"maximum m of the alms");
00056   planck_assert(nmmax<=nlmax,"nmmax must not be larger than nlmax");
00057   string infile = params.template find<string>("infile");
00058   par.add_source_file (infile, 2);
00059   string outfile = params.template find<string>("outfile");
00060   int rand_seed = params.template find<int>("rand_seed");
00061   par.add("rand_seed","RANDSEED",rand_seed,"random number seed");
00062   double fwhm = params.template find<double>("fwhm_arcmin",0.);
00063   par.add("fwhm","FWHM",fwhm,"[arcmin] Gaussian smoothing FWHM");
00064   fwhm *= degr2rad/60;
00065   bool polarisation = params.template find<bool>("polarisation");
00066 
00067   PowSpec powspec;
00068   int nspecs = polarisation ? 4 : 1;
00069   read_powspec_from_fits (infile, powspec, nspecs, nlmax);
00070   powspec.Smooth_with_Gauss(fwhm);
00071 
00072   planck_rng rng(rand_seed);
00073 
00074   if (polarisation)
00075     {
00076     Alm<xcomplex<T> >
00077       almT(nlmax,nmmax), almG(nlmax,nmmax), almC(nlmax,nmmax);
00078     create_alm_pol (powspec, almT, almG, almC, rng);
00079 
00080     fitshandle out;
00081     out.create(outfile);
00082     write_Alm_to_fits(out,almT,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00083     out.add_key("PDMTYPE",string("MAPALM"),"Planck data model type");
00084     par.add_keys(out);
00085     write_Alm_to_fits(out,almG,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00086     out.add_key("PDMTYPE",string("MAPALM"),"Planck data model type");
00087     par.add_keys(out);
00088     write_Alm_to_fits(out,almC,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00089     out.add_key("PDMTYPE",string("MAPALM"),"Planck data model type");
00090     par.add_keys(out);
00091     }
00092   else
00093     {
00094     Alm<xcomplex<T> > almT(nlmax,nmmax);
00095     create_alm (powspec, almT, rng);
00096 
00097     fitshandle out;
00098     out.create(outfile);
00099     write_Alm_to_fits(out,almT,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00100     out.add_key("PDMTYPE",string("MAPALM"),"Planck data model type");
00101     par.add_keys(out);
00102     }
00103   }
00104 
00105 int main (int argc, const char **argv)
00106   {
00107 PLANCK_DIAGNOSIS_BEGIN
00108   module_startup ("syn_alm_cxx", argc, argv, 2, "<parameter file>");
00109   paramfile params (argv[1]);
00110   simparams par;
00111 
00112   bool dp = params.find<bool> ("double_precision",false);
00113   dp ? syn_alm_cxx<double>(params,par) : syn_alm_cxx<float>(params,par);
00114 PLANCK_DIAGNOSIS_END
00115   }

Generated on Fri Jun 18 16:12:30 2010 for Healpix C++
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650