Healpix C++  3.83
calc_powspec_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) 2004-2011 Max-Planck-Society
29  * Author: Martin Reinecke
30  */
31 
32 #include "fitshandle.h"
33 #include "paramfile.h"
34 #include "alm.h"
35 #include "alm_fitsio.h"
36 #include "powspec.h"
37 #include "powspec_fitsio.h"
38 #include "alm_powspec_tools.h"
39 #include "levels_facilities.h"
40 #include "announce.h"
41 
42 using namespace std;
43 
44 int calc_powspec_module (int argc, const char **argv)
45  {
46  module_startup ("calc_powspec",argc,argv);
47  paramfile params (getParamsFromCmdline(argc,argv));
48 
49  bool pol=params.find<bool>("pol",false);
50  string alm1=params.find<string>("alm1");
51  string ps=params.find<string>("ps");
52 
53  if (!params.param_present("alm2"))
54  {
55  int lmax,mmax;
56  pol ? get_almsize_pol(alm1,lmax,mmax)
57  : get_almsize (alm1,lmax,mmax);
58  Alm<xcomplex<float> > almT, almG, almC;
59  pol ? read_Alm_from_fits (alm1,almT,almG,almC,lmax,mmax)
60  : read_Alm_from_fits (alm1,almT,lmax,mmax);
61  PowSpec powspec;
62  pol ? extract_powspec (almT,almG,almC,powspec)
63  : extract_powspec (almT,powspec);
64  write_powspec_to_fits (ps,powspec,pol ? 6 : 1);
65  }
66  else
67  {
68  planck_assert(!pol, "polarisation not supported for cross-powerspectra");
69  int lmax,mmax;
70  get_almsize(alm1,lmax,mmax);
71  Alm<xcomplex<float> > Alm1;
72  read_Alm_from_fits (alm1,Alm1,lmax,mmax);
73  string alm2=params.find<string>("alm2");
74  get_almsize(alm2,lmax,mmax);
75  Alm<xcomplex<float> > Alm2;
76  read_Alm_from_fits (alm2,Alm2,lmax,mmax);
77  PowSpec powspec;
78  extract_crosspowspec (Alm1,Alm2,powspec);
79  write_powspec_to_fits (ps,powspec,1);
80  }
81 
82  return 0;
83  }
void read_Alm_from_fits(fitshandle &inp, Alm< xcomplex< T > > &alms, int lmax, int mmax)
Definition: alm_fitsio.cc:95
Definition: alm.h:88
void get_almsize_pol(const std::string &filename, int &lmax, int &mmax)
void extract_powspec(const Alm< xcomplex< T > > &alm, PowSpec &powspec)
void get_almsize(fitshandle &inp, int &lmax, int &mmax)
Definition: alm_fitsio.cc:42
void write_powspec_to_fits(fitshandle &out, const PowSpec &powspec, int nspecs)
void extract_crosspowspec(const Alm< xcomplex< T > > &alm1, const Alm< xcomplex< T > > &alm2, PowSpec &powspec)

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