calc_powspec_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) 2004-2011 Max-Planck-Society
00029  *  Author: Martin Reinecke
00030  */
00031 
00032 #include "fitshandle.h"
00033 #include "paramfile.h"
00034 #include "alm.h"
00035 #include "alm_fitsio.h"
00036 #include "powspec.h"
00037 #include "powspec_fitsio.h"
00038 #include "alm_powspec_tools.h"
00039 #include "levels_facilities.h"
00040 #include "announce.h"
00041 
00042 using namespace std;
00043 
00044 int calc_powspec_module (int argc, const char **argv)
00045   {
00046   module_startup ("calc_powspec",argc,argv);
00047   paramfile params (getParamsFromCmdline(argc,argv));
00048 
00049   bool pol=params.find<bool>("pol",false);
00050   string alm1=params.find<string>("alm1");
00051   string ps=params.find<string>("ps");
00052 
00053   if (!params.param_present("alm2"))
00054     {
00055     int lmax,mmax;
00056     pol ? get_almsize_pol(alm1,lmax,mmax)
00057         : get_almsize    (alm1,lmax,mmax);
00058     Alm<xcomplex<float> > almT, almG, almC;
00059     pol ? read_Alm_from_fits (alm1,almT,almG,almC,lmax,mmax)
00060         : read_Alm_from_fits (alm1,almT,lmax,mmax);
00061     PowSpec powspec;
00062     pol ? extract_powspec (almT,almG,almC,powspec)
00063         : extract_powspec (almT,powspec);
00064     write_powspec_to_fits (ps,powspec,pol ? 6 : 1);
00065     }
00066   else
00067     {
00068     planck_assert(!pol, "polarisation not supported for cross-powerspectra");
00069     int lmax,mmax;
00070     get_almsize(alm1,lmax,mmax);
00071     Alm<xcomplex<float> > Alm1;
00072     read_Alm_from_fits (alm1,Alm1,lmax,mmax);
00073     string alm2=params.find<string>("alm2");
00074     get_almsize(alm2,lmax,mmax);
00075     Alm<xcomplex<float> > Alm2;
00076     read_Alm_from_fits (alm2,Alm2,lmax,mmax);
00077     PowSpec powspec;
00078     extract_crosspowspec (Alm1,Alm2,powspec);
00079     write_powspec_to_fits (ps,powspec,1);
00080     }
00081 
00082   return 0;
00083   }

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