Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

healpix_data_io.cc

00001 /*
00002  *  This file is part of Healpix_cxx.
00003  *
00004  *  Healpix_cxx is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  Healpix_cxx is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with Healpix_cxx; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  *
00018  *  For more information about HEALPix, see http://healpix.jpl.nasa.gov
00019  */
00020 
00021 /*
00022  *  Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
00023  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00024  *  (DLR).
00025  */
00026 
00027 /*
00028  *  Copyright (C) 2003, 2005 Max-Planck-Society
00029  *  Author: Martin Reinecke
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 &params, 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 &params, 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 &params, 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 &params, 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   }

Generated on Fri Jul 8 09:37:15 2005 for Healpix C++