healpix_data_io.cc
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 "string_utils.h"
00037
00038 using namespace std;
00039
00040 void read_weight_ring (const string &dir, int nside, arr<double> &weight)
00041 {
00042 fitshandle inp;
00043 inp.open(dir+"/weight_ring_n"+intToString(nside,5)+".fits");
00044 inp.goto_hdu(2);
00045 weight.alloc (2*nside);
00046 inp.read_column(1,weight);
00047 }
00048
00049 void get_ring_weights (paramfile ¶ms, int nside, arr<double> &weight)
00050 {
00051 bool weighted = params.find<bool>("weighted",false);
00052 weight.alloc (2*nside);
00053 if (weighted)
00054 {
00055 string datadir = params.find<string>("healpix_data");
00056 read_weight_ring (datadir, nside, weight);
00057 for (tsize m=0; m<weight.size(); ++m) weight[m]+=1;
00058 }
00059 else
00060 weight.fill(1);
00061 }
00062
00063 void read_pixwin (const string &dir, int nside, arr<double> &temp)
00064 {
00065 fitshandle inp;
00066 inp.open(dir+"/pixel_window_n"+intToString(nside,4)+".fits");
00067 inp.goto_hdu(2);
00068 if (temp.size()==0)
00069 inp.read_entire_column(1,temp);
00070 else
00071 inp.read_column(1,temp);
00072 }
00073 void read_pixwin (const string &dir, int nside, arr<double> &temp,
00074 arr<double> &pol)
00075 {
00076 fitshandle inp;
00077 inp.open(dir+"/pixel_window_n"+intToString(nside,4)+".fits");
00078 inp.goto_hdu(2);
00079 if (temp.size()==0)
00080 inp.read_entire_column(1,temp);
00081 else
00082 inp.read_column(1,temp);
00083 if (pol.size()==0)
00084 inp.read_entire_column(2,pol);
00085 else
00086 inp.read_column(2,pol);
00087 }
00088
00089 void get_pixwin (paramfile ¶ms, int lmax, int nside, arr<double> &pixwin)
00090 {
00091 bool do_pixwin = params.find<bool>("pixel_window",false);
00092 pixwin.alloc(lmax+1);
00093 pixwin.fill(1);
00094 if (do_pixwin)
00095 {
00096 string datadir = params.find<string>("healpix_data");
00097 read_pixwin (datadir,nside,pixwin);
00098 }
00099 }
00100 void get_pixwin (paramfile ¶ms, int lmax, int nside, arr<double> &pixwin,
00101 arr<double> &pixwin_pol)
00102 {
00103 bool do_pixwin = params.find<bool>("pixel_window",false);
00104 pixwin.alloc(lmax+1);
00105 pixwin.fill(1);
00106 pixwin_pol.alloc(lmax+1);
00107 pixwin_pol.fill(1);
00108 if (do_pixwin)
00109 {
00110 string datadir = params.find<string>("healpix_data");
00111 read_pixwin (datadir,nside,pixwin,pixwin_pol);
00112 }
00113 }