udgrade_cxx.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 "cxxutils.h"
00033 #include "paramfile.h"
00034 #include "simparams.h"
00035 #include "healpix_map.h"
00036 #include "healpix_map_fitsio.h"
00037 #include "fitshandle.h"
00038
00039 using namespace std;
00040
00041 template<typename T> void udgrade_cxx (paramfile ¶ms, simparams &par)
00042 {
00043 par.add_comment("-------------------");
00044 par.add_comment(" ** udgrade_cxx **");
00045 par.add_comment("-------------------");
00046
00047 string infile = params.template find<string>("infile");
00048 par.add_source_file (infile, 2);
00049 string outfile = params.template find<string>("outfile");
00050 int order = Healpix_Base::nside2order (params.template find<int>("nside"));
00051 bool polarisation = params.template find<bool>("polarisation",false);
00052 bool pessimistic = params.template find<bool>("pessimistic",false);
00053
00054 if (!polarisation)
00055 {
00056 Healpix_Map<T> inmap;
00057 read_Healpix_map_from_fits(infile,inmap,1,2);
00058 Healpix_Map<T> outmap (order, inmap.Scheme());
00059
00060 outmap.Import(inmap,pessimistic);
00061 fitshandle out;
00062 out.create(outfile);
00063 write_Healpix_map_to_fits (out,outmap,FITSUTIL<T>::DTYPE);
00064 }
00065 else
00066 {
00067 Healpix_Map<T> inmap;
00068 read_Healpix_map_from_fits(infile,inmap,1,2);
00069 Healpix_Map<T> outmapT (order, inmap.Scheme()),
00070 outmapQ (order, inmap.Scheme()),
00071 outmapU (order, inmap.Scheme());
00072
00073 outmapT.Import(inmap,pessimistic);
00074 read_Healpix_map_from_fits(infile,inmap,2,2);
00075 outmapQ.Import(inmap,pessimistic);
00076 read_Healpix_map_from_fits(infile,inmap,3,2);
00077 outmapU.Import(inmap,pessimistic);
00078 fitshandle out;
00079 out.create(outfile);
00080 write_Healpix_map_to_fits (out,outmapT,outmapQ,outmapU,FITSUTIL<T>::DTYPE);
00081 }
00082 }
00083
00084 int main (int argc, const char **argv)
00085 {
00086 PLANCK_DIAGNOSIS_BEGIN
00087 module_startup ("udgrade_cxx", argc, argv, 2, "<parameter file>");
00088 paramfile params (argv[1]);
00089 simparams par;
00090
00091 bool dp = params.find<bool> ("double_precision",false);
00092 dp ? udgrade_cxx<double>(params,par) : udgrade_cxx<float>(params,par);
00093 PLANCK_DIAGNOSIS_END
00094 }