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

udgrade_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) 2003, 2004 Max-Planck-Society
00029  *  Author: Martin Reinecke
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 &params, 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   }

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