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.sourceforge.net
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, 2009 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 "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 &params, 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 &params, 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 &params, 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   }

Generated on Thu Oct 8 14:48:52 2015 for Healpix C++