NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

smoothing_cxx.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.jpl.nasa.gov
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) 2005 Max-Planck-Society
00029  *  Author: Martin Reinecke
00030  */
00031 
00032 #include "xcomplex.h"
00033 #include "cxxutils.h"
00034 #include "paramfile.h"
00035 #include "simparams.h"
00036 #include "healpix_data_io.h"
00037 #include "alm.h"
00038 #include "healpix_map.h"
00039 #include "healpix_map_fitsio.h"
00040 #include "alm_healpix_tools.h"
00041 #include "alm_powspec_tools.h"
00042 #include "fitshandle.h"
00043 
00044 using namespace std;
00045 
00046 template<typename T> void smoothing_cxx (paramfile &params, simparams &par)
00047   {
00048   int nlmax = params.template find<int>("nlmax");
00049   string infile = params.template find<string>("infile");
00050   string outfile = params.template find<string>("outfile");
00051   bool polarisation = params.template find<bool>("polarisation");
00052   int num_iter = params.template find<int>("iter_order",0);
00053   double fwhm_arcmin = params.template find<double>("fwhm_arcmin");
00054 
00055   if (!polarisation)
00056     {
00057     Healpix_Map<T> map;
00058     read_Healpix_map_from_fits(infile,map,1,2);
00059     arr<double> weight_T;
00060     get_ring_weights (params,par,map.Nside(),weight_T);
00061 
00062     Alm<xcomplex<T> > alm(nlmax,nlmax);
00063     double avg=map.average();
00064     map.add(-avg);
00065     if (map.Scheme()==NEST) map.swap_scheme();
00066 
00067     map2alm_iter(map,alm,num_iter,weight_T);
00068     if (fwhm_arcmin>0) smooth_with_Gauss (alm, fwhm_arcmin);
00069     alm2map(alm,map);
00070 
00071     map.add(avg);
00072     fitshandle out;
00073     out.create (outfile);
00074     write_Healpix_map_to_fits (out,map,FITSUTIL<T>::DTYPE);
00075     par.add_keys(out);
00076     }
00077   else
00078     {
00079     Healpix_Map<T> mapT, mapQ, mapU;
00080     read_Healpix_map_from_fits(infile,mapT,1,2);
00081     read_Healpix_map_from_fits(infile,mapQ,2,2);
00082     read_Healpix_map_from_fits(infile,mapU,3,2);
00083     arr<double> weight;
00084     get_ring_weights (params,par,mapT.Nside(),weight);
00085 
00086     Alm<xcomplex<T> > almT(nlmax,nlmax), almG(nlmax,nlmax), almC(nlmax,nlmax);
00087     double avg=mapT.average();
00088     mapT.add(-avg);
00089     if (mapT.Scheme()==NEST) mapT.swap_scheme();
00090     if (mapQ.Scheme()==NEST) mapQ.swap_scheme();
00091     if (mapU.Scheme()==NEST) mapU.swap_scheme();
00092 
00093     map2alm_pol_iter
00094       (mapT,mapQ,mapU,almT,almG,almC,num_iter,weight);
00095     if (fwhm_arcmin>0) smooth_with_Gauss (almT, almG, almC, fwhm_arcmin);
00096     alm2map_pol(almT,almG,almC,mapT,mapQ,mapU);
00097 
00098     mapT.add(avg);
00099     fitshandle out;
00100     out.create (outfile);
00101     write_Healpix_map_to_fits (out,mapT,mapQ,mapU,FITSUTIL<T>::DTYPE);
00102     par.add_keys(out);
00103     }
00104   }
00105 
00106 int main (int argc, const char **argv)
00107   {
00108 PLANCK_DIAGNOSIS_BEGIN
00109   module_startup ("smoothing_cxx", argc, argv, 2, "<parameter file>");
00110   paramfile params (argv[1]);
00111   simparams par;
00112 
00113   bool dp = params.find<bool> ("double_precision",false);
00114   dp ? smoothing_cxx<double>(params,par) : smoothing_cxx<float>(params,par);
00115 PLANCK_DIAGNOSIS_END
00116   }

Generated on Fri Jun 18 16:12:30 2010 for Healpix C++
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650