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
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 }