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

mult_alm.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) 2003, 2004, 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 "alm_fitsio.h"
00039 #include "alm_powspec_tools.h"
00040 #include "fitshandle.h"
00041 
00042 using namespace std;
00043 
00044 template<typename T> void mult_alm (paramfile &params, simparams &par)
00045   {
00046   par.add_comment("----------------");
00047   par.add_comment(" ** mult_alm **");
00048   par.add_comment("----------------");
00049 
00050   string infile = params.template find<string>("infile");
00051   par.add_source_file (infile, 2);
00052   string outfile = params.template find<string>("outfile");
00053   int nside_pixwin_in = params.template find<int>("nside_pixwin_in",0);
00054   planck_assert (nside_pixwin_in>=0,"nside_pixwin_in must be >= 0");
00055   int nside_pixwin_out = params.template find<int>("nside_pixwin_out",0);
00056   planck_assert (nside_pixwin_out>=0,"nside_pixwin_out must be >= 0");
00057   double fwhm_arcmin_in = params.template find<double>("fwhm_arcmin_in",0);
00058   planck_assert (fwhm_arcmin_in>=0,"fwhm_arcmin_in must be >= 0");
00059   double fwhm_arcmin_out = params.template find<double>("fwhm_arcmin_out",0);
00060   planck_assert (fwhm_arcmin_out>=0,"fwhm_arcmin_out must be >= 0");
00061 
00062   string datadir;
00063   if ((nside_pixwin_in>0) || (nside_pixwin_out>0))
00064     datadir = params.template find<string>("healpix_data");
00065 
00066   bool polarisation = params.template find<bool>("polarisation");
00067   if (!polarisation)
00068     {
00069     int nlmax, nmmax;
00070     get_almsize(infile, nlmax, nmmax, 2);
00071     Alm<xcomplex<T> > alm;
00072     read_Alm_from_fits(infile,alm,nlmax,nmmax,2);
00073     if (fwhm_arcmin_in>0) smooth_with_Gauss (alm, -fwhm_arcmin_in);
00074     arr<double> temp(nlmax+1);
00075     if (nside_pixwin_in>0)
00076       {
00077       read_pixwin(datadir,nside_pixwin_in,temp);
00078       for (int l=0; l<=nlmax; ++l)
00079         temp[l] = 1/temp[l];
00080       alm.ScaleL (temp);
00081       }
00082     if (nside_pixwin_out>0)
00083       {
00084       read_pixwin(datadir,nside_pixwin_out,temp);
00085       alm.ScaleL (temp);
00086       }
00087     if (fwhm_arcmin_out>0) smooth_with_Gauss (alm, fwhm_arcmin_out);
00088     fitshandle out;
00089     out.create (outfile);
00090     write_Alm_to_fits (out,alm,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00091     par.add_keys(out);
00092     }
00093   else
00094     {
00095     int nlmax, nmmax;
00096     get_almsize_pol(infile, nlmax, nmmax);
00097     Alm<xcomplex<T> > almT, almG, almC;
00098     read_Alm_from_fits(infile,almT,nlmax,nmmax,2);
00099     read_Alm_from_fits(infile,almG,nlmax,nmmax,3);
00100     read_Alm_from_fits(infile,almC,nlmax,nmmax,4);
00101     if (fwhm_arcmin_in>0)
00102       smooth_with_Gauss (almT, almG, almC, -fwhm_arcmin_in);
00103     arr<double> temp(nlmax+1), pol(nlmax+1);
00104     if (nside_pixwin_in>0)
00105       {
00106       read_pixwin(datadir,nside_pixwin_in,temp,pol);
00107       for (int l=0; l<=nlmax; ++l)
00108         { temp[l] = 1/temp[l]; pol[l] = 1/pol[l]; }
00109       almT.ScaleL(temp); almG.ScaleL(pol); almC.ScaleL(pol);
00110       }
00111     if (nside_pixwin_out>0)
00112       {
00113       read_pixwin(datadir,nside_pixwin_out,temp,pol);
00114       almT.ScaleL(temp); almG.ScaleL(pol); almC.ScaleL(pol);
00115       }
00116     if (fwhm_arcmin_out>0)
00117       smooth_with_Gauss (almT, almG, almC, fwhm_arcmin_out);
00118     fitshandle out;
00119     out.create (outfile);
00120     write_Alm_to_fits (out,almT,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00121     par.add_keys(out);
00122     write_Alm_to_fits (out,almG,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00123     par.add_keys(out);
00124     write_Alm_to_fits (out,almC,nlmax,nmmax,FITSUTIL<T>::DTYPE);
00125     par.add_keys(out);
00126     }
00127   }
00128 
00129 int main (int argc, const char **argv)
00130   {
00131 PLANCK_DIAGNOSIS_BEGIN
00132   module_startup ("mult_alm", argc, argv, 2, "<parameter file>");
00133   paramfile params (argv[1]);
00134   simparams par;
00135 
00136   bool dp = params.find<bool> ("double_precision",false);
00137   dp ? mult_alm<double>(params,par) : mult_alm<float>(params,par);
00138 PLANCK_DIAGNOSIS_END
00139   }

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