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 "healpix_data_io.h"
00033 #include "arr.h"
00034 #include "fitshandle.h"
00035 #include "paramfile.h"
00036 #include "simparams.h"
00037
00038 using namespace std;
00039
00040 void read_weight_ring (const string &dir, int nside, arr<double> &weight_T)
00041 {
00042 fitshandle inp;
00043 inp.open(dir+"/weight_ring_n"+intToString(nside,5)+".fits");
00044 inp.goto_hdu(2);
00045 weight_T.alloc (2*nside);
00046 inp.read_column(1,weight_T);
00047 }
00048 void read_weight_ring (const string &dir, int nside, arr<double> &weight_T,
00049 arr<double> &weight_Q, arr<double> &weight_U)
00050 {
00051 fitshandle inp;
00052 inp.open(dir+"/weight_ring_n"+intToString(nside,5)+".fits");
00053 inp.goto_hdu(2);
00054 weight_T.alloc (2*nside); weight_Q.alloc (2*nside); weight_U.alloc (2*nside);
00055 inp.read_column(1,weight_T);
00056 weight_Q.fill(0);
00057 weight_U.fill(0);
00058 }
00059
00060 void get_ring_weights (paramfile ¶ms, simparams &par, int nside,
00061 arr<double> &weight_T)
00062 {
00063 bool weighted = params.find<bool>("weighted",false);
00064 par.add ("weighted","WEIGHTED",weighted,"ring weights used?");
00065 weight_T.alloc (2*nside);
00066 if (weighted)
00067 {
00068 string datadir = params.find<string>("healpix_data");
00069 read_weight_ring (datadir, nside, weight_T);
00070 for (int m=0; m<weight_T.size(); ++m) weight_T[m]+=1;
00071 }
00072 else
00073 weight_T.fill(1);
00074 }
00075 void get_ring_weights (paramfile ¶ms, simparams &par, int nside,
00076 arr<double> &weight_T, arr<double> &weight_Q, arr<double> &weight_U)
00077 {
00078 bool weighted = params.find<bool>("weighted",false);
00079 par.add ("weighted","WEIGHTED",weighted,"ring weights used?");
00080 weight_T.alloc (2*nside); weight_Q.alloc (2*nside); weight_U.alloc (2*nside);
00081 if (weighted)
00082 {
00083 string datadir = params.find<string>("healpix_data");
00084 read_weight_ring (datadir, nside, weight_T, weight_Q, weight_U);
00085 for (int m=0; m<weight_T.size(); ++m) weight_T[m]+=1;
00086 for (int m=0; m<weight_Q.size(); ++m) weight_Q[m]+=1;
00087 for (int m=0; m<weight_U.size(); ++m) weight_U[m]+=1;
00088 }
00089 else
00090 { weight_T.fill(1); weight_Q.fill(1); weight_U.fill(1); }
00091 }
00092
00093 void read_pixwin (const string &dir, int nside, arr<double> &temp)
00094 {
00095 fitshandle inp;
00096 inp.open(dir+"/pixel_window_n"+intToString(nside,4)+".fits");
00097 inp.goto_hdu(2);
00098 if (temp.size()==0)
00099 inp.read_entire_column(1,temp);
00100 else
00101 inp.read_column(1,temp);
00102 }
00103 void read_pixwin (const string &dir, int nside, arr<double> &temp,
00104 arr<double> &pol)
00105 {
00106 fitshandle inp;
00107 inp.open(dir+"/pixel_window_n"+intToString(nside,4)+".fits");
00108 inp.goto_hdu(2);
00109 if (temp.size()==0)
00110 inp.read_entire_column(1,temp);
00111 else
00112 inp.read_column(1,temp);
00113 if (pol.size()==0)
00114 inp.read_entire_column(2,pol);
00115 else
00116 inp.read_column(2,pol);
00117 }
00118
00119 void get_pixwin (paramfile ¶ms, simparams &par, int lmax,
00120 int nside, arr<double> &pixwin)
00121 {
00122 bool do_pixwin = params.find<bool>("pixel_window",false);
00123 par.add("pixel_window","PIXWIN",do_pixwin,"pixel window used?");
00124 pixwin.alloc(lmax+1);
00125 pixwin.fill(1);
00126 if (do_pixwin)
00127 {
00128 string datadir = params.find<string>("healpix_data");
00129 read_pixwin (datadir,nside,pixwin);
00130 }
00131 }
00132 void get_pixwin (paramfile ¶ms, simparams &par, int lmax,
00133 int nside, arr<double> &pixwin, arr<double> &pixwin_pol)
00134 {
00135 bool do_pixwin = params.find<bool>("pixel_window",false);
00136 par.add("pixel_window","PIXWIN",do_pixwin,"pixel window used?");
00137 pixwin.alloc(lmax+1);
00138 pixwin.fill(1);
00139 pixwin_pol.alloc(lmax+1);
00140 pixwin_pol.fill(1);
00141 if (do_pixwin)
00142 {
00143 string datadir = params.find<string>("healpix_data");
00144 read_pixwin (datadir,nside,pixwin,pixwin_pol);
00145 }
00146 }