calc_powspec_module.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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 }