NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

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)
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, simparams &par, int nside,
00050   arr<double> &weight)
00051   {
00052   bool weighted = params.find<bool>("weighted",false);
00053   par.add ("weighted","WEIGHTED",weighted,"ring weights used?");
00054   weight.alloc (2*nside);
00055   if (weighted)
00056     {
00057     string datadir = params.find<string>("healpix_data");
00058     read_weight_ring (datadir, nside, weight);
00059     for (int m=0; m<weight.size(); ++m) weight[m]+=1;
00060     }
00061   else
00062     weight.fill(1);
00063   }
00064 
00065 void read_pixwin (const string &dir, int nside, arr<double> &temp)
00066   {
00067   fitshandle inp;
00068   inp.open(dir+"/pixel_window_n"+intToString(nside,4)+".fits");
00069   inp.goto_hdu(2);
00070   if (temp.size()==0)
00071     inp.read_entire_column(1,temp);
00072   else
00073     inp.read_column(1,temp);
00074   }
00075 void read_pixwin (const string &dir, int nside, arr<double> &temp,
00076   arr<double> &pol)
00077   {
00078   fitshandle inp;
00079   inp.open(dir+"/pixel_window_n"+intToString(nside,4)+".fits");
00080   inp.goto_hdu(2);
00081   if (temp.size()==0)
00082     inp.read_entire_column(1,temp);
00083   else
00084     inp.read_column(1,temp);
00085   if (pol.size()==0)
00086     inp.read_entire_column(2,pol);
00087   else
00088     inp.read_column(2,pol);
00089   }
00090 
00091 void get_pixwin (paramfile &params, simparams &par, int lmax,
00092   int nside, arr<double> &pixwin)
00093   {
00094   bool do_pixwin = params.find<bool>("pixel_window",false);
00095   par.add("pixel_window","PIXWIN",do_pixwin,"pixel window used?");
00096   pixwin.alloc(lmax+1);
00097   pixwin.fill(1);
00098   if (do_pixwin)
00099     {
00100     string datadir = params.find<string>("healpix_data");
00101     read_pixwin (datadir,nside,pixwin);
00102     }
00103   }
00104 void get_pixwin (paramfile &params, simparams &par, int lmax,
00105   int nside, arr<double> &pixwin, arr<double> &pixwin_pol)
00106   {
00107   bool do_pixwin = params.find<bool>("pixel_window",false);
00108   par.add("pixel_window","PIXWIN",do_pixwin,"pixel window used?");
00109   pixwin.alloc(lmax+1);
00110   pixwin.fill(1);
00111   pixwin_pol.alloc(lmax+1);
00112   pixwin_pol.fill(1);
00113   if (do_pixwin)
00114     {
00115     string datadir = params.find<string>("healpix_data");
00116     read_pixwin (datadir,nside,pixwin,pixwin_pol);
00117     }
00118   }

Generated on Fri Jun 18 16:12:30 2010 for Healpix C++
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650