/* * This file is part of Healpix_cxx. * * Healpix_cxx is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Healpix_cxx is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Healpix_cxx; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * For more information about HEALPix, see http://healpix.jpl.nasa.gov */ /* * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt * (DLR). */ /* * Copyright (C) 2003-2010 Max-Planck-Society * Author: Martin Reinecke */ #include "healpix_map_fitsio.h" #include "healpix_map.h" #include "fitshandle.h" using namespace std; namespace { unsigned int healpix_repcount (tsize npix) { if (npix<1024) return 1; if ((npix%1024)==0) return 1024; return isqrt (npix/12); } } // unnamed namespace template void read_Healpix_map_from_fits (fitshandle &inp, Healpix_Map &map, int colnum) { arr myarr; inp.read_entire_column (colnum, myarr); int64 nside = inp.get_key("NSIDE"); planck_assert (int64(myarr.size())==12*nside*nside, string("mismatch between number of map pixels (" +dataToString(myarr.size())+") and Nside ("+dataToString(nside)+")")); map.Set (myarr, string2HealpixScheme(inp.get_key("ORDERING"))); } template void read_Healpix_map_from_fits (fitshandle &inp, Healpix_Map &map, int colnum); template void read_Healpix_map_from_fits (fitshandle &inp, Healpix_Map &map, int colnum); template void read_Healpix_map_from_fits (fitshandle &inp, Healpix_Map &map, int colnum); template void read_Healpix_map_from_fits (const string &filename, Healpix_Map &map, int colnum, int hdunum) { fitshandle inp; inp.open (filename); inp.goto_hdu (hdunum); read_Healpix_map_from_fits (inp,map,colnum); } template void read_Healpix_map_from_fits (const string &filename, Healpix_Map &map, int colnum, int hdunum); template void read_Healpix_map_from_fits (const string &filename, Healpix_Map &map, int colnum, int hdunum); template void read_Healpix_map_from_fits (const string &filename, Healpix_Map &map, int colnum, int hdunum); void prepare_Healpix_fitsmap (fitshandle &out, const Healpix_Base &base, PDT datatype, const arr &colname) { vector cols; int repcount = healpix_repcount (base.Npix()); for (tsize m=0; m void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &map, PDT datatype) { arr colname(1); colname[0] = "signal"; prepare_Healpix_fitsmap (out, map, datatype, colname); out.write_column(1,map.Map()); } template void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &map, PDT datatype); template void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &map, PDT datatype); template void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &map, PDT datatype); template void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, PDT datatype) { arr colname(3); colname[0] = "signal"; colname[1] = "Q-pol"; colname[2] = "U-pol"; prepare_Healpix_fitsmap (out, mapT, datatype, colname); out.write_column(1,mapT.Map()); out.write_column(2,mapQ.Map()); out.write_column(3,mapU.Map()); } template void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, PDT datatype); template void write_Healpix_map_to_fits (fitshandle &out, const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, PDT datatype);