rotalm_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.sourceforge.net
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-2011 Max-Planck-Society
00029  *  Author: Martin Reinecke
00030  */
00031 
00032 #include "alm.h"
00033 #include "alm_fitsio.h"
00034 #include "fitshandle.h"
00035 #include "alm_powspec_tools.h"
00036 #include "trafos.h"
00037 #include "announce.h"
00038 #include "string_utils.h"
00039 #include "lsconstants.h"
00040 
00041 using namespace std;
00042 
00043 namespace {
00044 
00045 Trafo maketrafo (int num)
00046   {
00047   switch (num)
00048     {
00049     case  1: return Trafo(2000,2000,Equatorial,Galactic);
00050     case  2: return Trafo(2000,2000,Galactic,Equatorial);
00051     case  3: return Trafo(2000,2000,Equatorial,Ecliptic);
00052     case  4: return Trafo(2000,2000,Ecliptic,Equatorial);
00053     case  5: return Trafo(2000,2000,Ecliptic,Galactic);
00054     case  6: return Trafo(2000,2000,Galactic,Ecliptic);
00055     case  7: return Trafo(1950,1950,Equatorial,Galactic);
00056     case  8: return Trafo(1950,1950,Galactic,Equatorial);
00057     case  9: return Trafo(1950,1950,Equatorial,Ecliptic);
00058     case 10: return Trafo(1950,1950,Ecliptic,Equatorial);
00059     case 11: return Trafo(1950,1950,Ecliptic,Galactic);
00060     case 12: return Trafo(1950,1950,Galactic,Ecliptic);
00061     default: planck_fail("Unsupported transformation "+dataToString(num));
00062     }
00063   }
00064 
00065 } // unnamed namespace
00066 
00067 int main(int argc, const char **argv)
00068   {
00069 PLANCK_DIAGNOSIS_BEGIN
00070   module_startup("rotalm_cxx", (argc==5)||(argc==7),
00071     "Usage: rotalm_cxx <infile> <outfile> <itransform> <pol>\n"
00072     "or   : rotalm_cxx <infile> <outfile> <psi> <theta> <phi> <pol>\n\n"
00073     "itransform: 1: Equatorial (2000) -> Galactic   (2000)\n"
00074     "            2: Galactic   (2000) -> Equatorial (2000)\n"
00075     "            3: Equatorial (2000) -> Ecliptic   (2000)\n"
00076     "            4: Ecliptic   (2000) -> Equatorial (2000)\n"
00077     "            5: Ecliptic   (2000) -> Galactic   (2000)\n"
00078     "            6: Galactic   (2000) -> Ecliptic   (2000)\n"
00079     "            7: Equatorial (1950) -> Galactic   (1950)\n"
00080     "            8: Galactic   (1950) -> Equatorial (1950)\n"
00081     "            9: Equatorial (1950) -> Ecliptic   (1950)\n"
00082     "           10: Ecliptic   (1950) -> Equatorial (1950)\n"
00083     "           11: Ecliptic   (1950) -> Galactic   (1950)\n"
00084     "           12: Galactic   (1950) -> Ecliptic   (1950)\n\n"
00085     "psi, theta, phi: Euler angles (in degrees)\n\n"
00086     "pol: T or F\n");
00087 
00088   string infile  = argv[1];
00089   string outfile = argv[2];
00090   bool polarisation = stringToData<bool>(argv[argc-1]);
00091   rotmatrix rm;
00092   if (argc==5)
00093     {
00094     int trafo = stringToData<int>(argv[3]);
00095     Trafo tr(maketrafo(trafo));
00096     rm=tr.Matrix();
00097     }
00098   else
00099     {
00100     rm.Make_CPAC_Euler_Matrix(degr2rad*stringToData<double>(argv[5]),
00101                               degr2rad*stringToData<double>(argv[4]),
00102                               degr2rad*stringToData<double>(argv[3]));
00103     }
00104 
00105   Alm<xcomplex<double> > almT,almG,almC;
00106 
00107   if (!polarisation)
00108     {
00109     int lmax, dummy;
00110     get_almsize (infile,lmax,dummy);
00111     read_Alm_from_fits (infile, almT, lmax, lmax);
00112     rotate_alm(almT,rm);
00113     write_Alm_to_fits (outfile,almT,lmax,lmax,PLANCK_FLOAT32);
00114     }
00115   else
00116     {
00117     int lmax, dummy;
00118     get_almsize_pol (infile,lmax,dummy);
00119     read_Alm_from_fits (infile, almT, almG, almC, lmax, lmax);
00120     rotate_alm(almT,almG,almC,rm);
00121     write_Alm_to_fits (outfile,almT,almG,almC,lmax,lmax,PLANCK_FLOAT32);
00122     }
00123 
00124 PLANCK_DIAGNOSIS_END
00125   }

Generated on Thu Oct 8 14:48:52 2015 for Healpix C++