00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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 }
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 }