/* * This file is part of Healpix_cxx. * * Healpix_cxx is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Healpix_cxx is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Healpix_cxx; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * For more information about HEALPix, see http://healpix.jpl.nasa.gov */ /* * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt * (DLR). */ /* * Copyright (C) 2005-2010 Max-Planck-Society * Author: Martin Reinecke */ #include "xcomplex.h" #include "cxxutils.h" #include "paramfile.h" #include "healpix_data_io.h" #include "alm.h" #include "healpix_map.h" #include "healpix_map_fitsio.h" #include "alm_healpix_tools.h" #include "alm_powspec_tools.h" #include "fitshandle.h" #include "levels_facilities.h" #include "lsconstants.h" using namespace std; namespace { template void smoothing_cxx (paramfile ¶ms) { int nlmax = params.template find("nlmax"); string infile = params.template find("infile"); string outfile = params.template find("outfile"); bool polarisation = params.template find("polarisation"); int num_iter = params.template find("iter_order",0); double fwhm = arcmin2rad*params.template find("fwhm_arcmin"); if (fwhm<0) cout << "NOTE: negative FWHM supplied, doing a deconvolution..." << endl; if (!polarisation) { Healpix_Map map; read_Healpix_map_from_fits(infile,map,1,2); arr weight; get_ring_weights (params,map.Nside(),weight); Alm > alm(nlmax,nlmax); double avg=map.average(); map.Add(T(-avg)); if (map.Scheme()==NEST) map.swap_scheme(); map2alm_iter(map,alm,num_iter,weight); smoothWithGauss (alm, fwhm); alm2map(alm,map); map.Add(T(avg)); write_Healpix_map_to_fits (outfile,map,planckType()); } else { Healpix_Map mapT, mapQ, mapU; read_Healpix_map_from_fits(infile,mapT,mapQ,mapU); arr weight; get_ring_weights (params,mapT.Nside(),weight); Alm > almT(nlmax,nlmax), almG(nlmax,nlmax), almC(nlmax,nlmax); double avg=mapT.average(); mapT.Add(T(-avg)); if (mapT.Scheme()==NEST) mapT.swap_scheme(); if (mapQ.Scheme()==NEST) mapQ.swap_scheme(); if (mapU.Scheme()==NEST) mapU.swap_scheme(); map2alm_pol_iter (mapT,mapQ,mapU,almT,almG,almC,num_iter,weight); smoothWithGauss (almT, almG, almC, fwhm); alm2map_pol(almT,almG,almC,mapT,mapQ,mapU); mapT.Add(T(avg)); write_Healpix_map_to_fits (outfile,mapT,mapQ,mapU,planckType()); } } } // unnamed namespace int smoothing_cxx_module (int argc, const char **argv) { module_startup ("smoothing_cxx", argc, argv, 2, ""); paramfile params (argv[1]); bool dp = params.find ("double_precision",false); dp ? smoothing_cxx(params) : smoothing_cxx(params); return 0; }