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

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.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 "alm.h"
00033 #include "alm_fitsio.h"
00034 #include "fitshandle.h"
00035 #include "alm_powspec_tools.h"
00036 #include "trafos.h"
00037 
00038 using namespace std;
00039 
00040 Trafo maketrafo (int num)
00041   {
00042   switch (num)
00043     {
00044     case  1: return Trafo(2000,2000,Equatorial,Galactic);
00045     case  2: return Trafo(2000,2000,Galactic,Equatorial);
00046     case  3: return Trafo(2000,2000,Equatorial,Ecliptic);
00047     case  4: return Trafo(2000,2000,Ecliptic,Equatorial);
00048     case  5: return Trafo(2000,2000,Ecliptic,Galactic);
00049     case  6: return Trafo(2000,2000,Galactic,Ecliptic);
00050     case  7: return Trafo(1950,1950,Equatorial,Galactic);
00051     case  8: return Trafo(1950,1950,Galactic,Equatorial);
00052     case  9: return Trafo(1950,1950,Equatorial,Ecliptic);
00053     case 10: return Trafo(1950,1950,Ecliptic,Equatorial);
00054     case 11: return Trafo(1950,1950,Ecliptic,Galactic);
00055     case 12: return Trafo(1950,1950,Galactic,Ecliptic);
00056     default: throw Message_error ("Unsupported transformation");
00057     }
00058   }
00059 
00060 int main(int argc, const char **argv)
00061   {
00062 PLANCK_DIAGNOSIS_BEGIN
00063   announce ("rotalm_cxx");
00064 
00065   if (argc!=5)
00066     {
00067     cout << "Usage: rotalm_cxx <infile> <outfile> <itransform> <pol>"
00068          << endl
00069          << "Transform 1: Equatorial (2000) -> Galactic   (2000)" << endl
00070          << "          2: Galactic   (2000) -> Equatorial (2000)" << endl
00071          << "          3: Equatorial (2000) -> Ecliptic   (2000)" << endl
00072          << "          4: Ecliptic   (2000) -> Equatorial (2000)" << endl
00073          << "          5: Ecliptic   (2000) -> Galactic   (2000)" << endl
00074          << "          6: Galactic   (2000) -> Ecliptic   (2000)" << endl
00075          << "          7: Equatorial (1950) -> Galactic   (1950)" << endl
00076          << "          8: Galactic   (1950) -> Equatorial (1950)" << endl
00077          << "          9: Equatorial (1950) -> Ecliptic   (1950)" << endl
00078          << "         10: Ecliptic   (1950) -> Equatorial (1950)" << endl
00079          << "         11: Ecliptic   (1950) -> Galactic   (1950)" << endl
00080          << "         12: Galactic   (1950) -> Ecliptic   (1950)" << endl
00081          << endl
00082          << "pol: T or F" << endl << endl;
00083     throw Message_error();
00084     }
00085 
00086   string infile  = argv[1];
00087   string outfile = argv[2];
00088   int trafo = stringToData<int>(argv[3]);
00089   bool polarisation = stringToData<bool>(argv[4]);
00090 
00091   Trafo tr(maketrafo(trafo));
00092 
00093   fitshandle out;
00094   out.create (outfile);
00095 
00096   Alm<xcomplex<double> > almT,almG,almC;
00097 
00098   if (!polarisation)
00099     {
00100     int lmax, dummy;
00101     get_almsize (infile,lmax,dummy);
00102     read_Alm_from_fits (infile, almT, lmax, lmax);
00103     rotate_alm(almT,tr.Matrix());
00104     write_Alm_to_fits (out,almT,lmax,lmax,TFLOAT);
00105     }
00106   else
00107     {
00108     int lmax, dummy;
00109     get_almsize_pol (infile,lmax,dummy);
00110     read_Alm_from_fits (infile, almT, lmax, lmax, 2);
00111     read_Alm_from_fits (infile, almG, lmax, lmax, 3);
00112     read_Alm_from_fits (infile, almC, lmax, lmax, 4);
00113     rotate_alm(almT,almG,almC,tr.Matrix());
00114     write_Alm_to_fits (out,almT,lmax,lmax,TDOUBLE);
00115     write_Alm_to_fits (out,almG,lmax,lmax,TDOUBLE);
00116     write_Alm_to_fits (out,almC,lmax,lmax,TDOUBLE);
00117     }
00118 
00119 PLANCK_DIAGNOSIS_END
00120   }

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