Healpix C++  3.83
rotalm_cxx.cc
1 /*
2  * This file is part of Healpix_cxx.
3  *
4  * Healpix_cxx is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Healpix_cxx is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Healpix_cxx; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * For more information about HEALPix, see http://healpix.sourceforge.net
19  */
20 
21 /*
22  * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
23  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
24  * (DLR).
25  */
26 
27 /*
28  * Copyright (C) 2005-2011 Max-Planck-Society
29  * Author: Martin Reinecke
30  */
31 
32 #include "alm.h"
33 #include "alm_fitsio.h"
34 #include "fitshandle.h"
35 #include "alm_powspec_tools.h"
36 #include "trafos.h"
37 #include "announce.h"
38 #include "string_utils.h"
39 #include "lsconstants.h"
40 
41 using namespace std;
42 
43 namespace {
44 
45 Trafo maketrafo (int num)
46  {
47  switch (num)
48  {
49  case 1: return Trafo(2000,2000,Equatorial,Galactic);
50  case 2: return Trafo(2000,2000,Galactic,Equatorial);
51  case 3: return Trafo(2000,2000,Equatorial,Ecliptic);
52  case 4: return Trafo(2000,2000,Ecliptic,Equatorial);
53  case 5: return Trafo(2000,2000,Ecliptic,Galactic);
54  case 6: return Trafo(2000,2000,Galactic,Ecliptic);
55  case 7: return Trafo(1950,1950,Equatorial,Galactic);
56  case 8: return Trafo(1950,1950,Galactic,Equatorial);
57  case 9: return Trafo(1950,1950,Equatorial,Ecliptic);
58  case 10: return Trafo(1950,1950,Ecliptic,Equatorial);
59  case 11: return Trafo(1950,1950,Ecliptic,Galactic);
60  case 12: return Trafo(1950,1950,Galactic,Ecliptic);
61  default: planck_fail("Unsupported transformation "+dataToString(num));
62  }
63  }
64 
65 } // unnamed namespace
66 
67 int main(int argc, const char **argv)
68  {
69 PLANCK_DIAGNOSIS_BEGIN
70  module_startup("rotalm_cxx", (argc==5)||(argc==7),
71  "Usage: rotalm_cxx <infile> <outfile> <itransform> <pol>\n"
72  "or : rotalm_cxx <infile> <outfile> <psi> <theta> <phi> <pol>\n\n"
73  "itransform: 1: Equatorial (2000) -> Galactic (2000)\n"
74  " 2: Galactic (2000) -> Equatorial (2000)\n"
75  " 3: Equatorial (2000) -> Ecliptic (2000)\n"
76  " 4: Ecliptic (2000) -> Equatorial (2000)\n"
77  " 5: Ecliptic (2000) -> Galactic (2000)\n"
78  " 6: Galactic (2000) -> Ecliptic (2000)\n"
79  " 7: Equatorial (1950) -> Galactic (1950)\n"
80  " 8: Galactic (1950) -> Equatorial (1950)\n"
81  " 9: Equatorial (1950) -> Ecliptic (1950)\n"
82  " 10: Ecliptic (1950) -> Equatorial (1950)\n"
83  " 11: Ecliptic (1950) -> Galactic (1950)\n"
84  " 12: Galactic (1950) -> Ecliptic (1950)\n\n"
85  "psi, theta, phi: Euler angles (in degrees)\n\n"
86  "pol: T or F\n");
87 
88  string infile = argv[1];
89  string outfile = argv[2];
90  bool polarisation = stringToData<bool>(argv[argc-1]);
91  rotmatrix rm;
92  if (argc==5)
93  {
94  int trafo = stringToData<int>(argv[3]);
95  Trafo tr(maketrafo(trafo));
96  rm=tr.Matrix();
97  }
98  else
99  {
100  rm.Make_CPAC_Euler_Matrix(degr2rad*stringToData<double>(argv[5]),
101  degr2rad*stringToData<double>(argv[4]),
102  degr2rad*stringToData<double>(argv[3]));
103  }
104 
105  Alm<xcomplex<double> > almT,almG,almC;
106 
107  if (!polarisation)
108  {
109  int lmax, dummy;
110  get_almsize (infile,lmax,dummy);
111  read_Alm_from_fits (infile, almT, lmax, lmax);
112  rotate_alm(almT,rm);
113  write_Alm_to_fits (outfile,almT,lmax,lmax,PLANCK_FLOAT32);
114  }
115  else
116  {
117  int lmax, dummy;
118  get_almsize_pol (infile,lmax,dummy);
119  read_Alm_from_fits (infile, almT, almG, almC, lmax, lmax);
120  rotate_alm(almT,almG,almC,rm);
121  write_Alm_to_fits (outfile,almT,almG,almC,lmax,lmax,PLANCK_FLOAT32);
122  }
123 
124 PLANCK_DIAGNOSIS_END
125  }
void write_Alm_to_fits(fitshandle &out, const Alm< xcomplex< T > > &alms, int lmax, int mmax, PDT datatype)
Definition: alm_fitsio.cc:151
void read_Alm_from_fits(fitshandle &inp, Alm< xcomplex< T > > &alms, int lmax, int mmax)
Definition: alm_fitsio.cc:95
Definition: alm.h:88
void get_almsize_pol(const std::string &filename, int &lmax, int &mmax)
void get_almsize(fitshandle &inp, int &lmax, int &mmax)
Definition: alm_fitsio.cc:42

Generated on Wed Nov 13 2024 12:18:30 for Healpix C++