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 /*! \file alm_fitsio.h 00028 * FITS I/O for spherical harmonic coefficients 00029 * 00030 * Copyright (C) 2003-2010 Max-Planck-Society 00031 * \author Martin Reinecke 00032 */ 00033 00034 #ifndef PLANCK_ALM_FITSIO_H 00035 #define PLANCK_ALM_FITSIO_H 00036 00037 #include <string> 00038 #include "xcomplex.h" 00039 #include "datatypes.h" 00040 #include "fitshandle.h" 00041 00042 template<typename T> class Alm; 00043 00044 /*! \defgroup alm_fitsio_group FITS-based I/O of a_lm */ 00045 /*! \{ */ 00046 00047 /*! Returns the maximum \a l and \a m multipole moments found in the FITS HDU 00048 pointed to be \a inp in \a lmax and \a mmax. */ 00049 void get_almsize(fitshandle &inp, int &lmax, int &mmax); 00050 /*! Returns the maximum \a l and \a m multipole moments found in the HDU 00051 \a hdunum of file \a filename in \a lmax and \a mmax. */ 00052 void get_almsize(const std::string &filename, int &lmax, int &mmax, 00053 int hdunum=2); 00054 /*! Returns the maximum \a l and \a m multipole moments found in the HDUs 00055 2, 3 and 4 of file \a filename in \a lmax and \a mmax. */ 00056 void get_almsize_pol(const std::string &filename, int &lmax, int &mmax); 00057 00058 /*! Reads the a_lm of the FITS binary table pointed to by \a inp into 00059 \a alms. \a alms is reallocated with the parameters \a lmax and \a mmax. 00060 Values not present in the FITS table are set to zero; values outside 00061 the requested (l,m) range are ignored. */ 00062 template<typename T> void read_Alm_from_fits 00063 (fitshandle &inp, Alm<xcomplex<T> > &alms, int lmax, int mmax); 00064 /*! Opens the FITS file \a filename, jumps to the HDU \a hdunum, then reads 00065 the a_lm from the FITS binary table there into \a alms. \a alms is 00066 reallocated with the parameters \a lmax and \a mmax. 00067 Values not present in the FITS table are set to zero; values outside 00068 the requested \a (l,m) range are ignored. */ 00069 template<typename T> void read_Alm_from_fits 00070 (const std::string &filename, Alm<xcomplex<T> > &alms, 00071 int lmax, int mmax, int hdunum=2); 00072 00073 template<typename T> inline void read_Alm_from_fits 00074 (const std::string &filename, Alm<xcomplex<T> > &almT, 00075 Alm<xcomplex<T> > &almG, Alm<xcomplex<T> > &almC, 00076 int lmax, int mmax, int firsthdu=2) 00077 { 00078 read_Alm_from_fits (filename, almT, lmax, mmax, firsthdu); 00079 read_Alm_from_fits (filename, almG, lmax, mmax, firsthdu+1); 00080 read_Alm_from_fits (filename, almC, lmax, mmax, firsthdu+2); 00081 } 00082 00083 /*! Inserts a new binary table into \a out, which contains three columns 00084 of type PLANCK_INT32, \a datatype and \a datatype, respectively. 00085 The data in \a alms is written into this table; values outside 00086 the requested (\a lmax, \a mmax) range are omitted. */ 00087 template<typename T> void write_Alm_to_fits 00088 (fitshandle &out, const Alm<xcomplex<T> > &alms, 00089 int lmax, int mmax, PDT datatype); 00090 00091 template<typename T> inline void write_Alm_to_fits 00092 (const std::string &outfile, const Alm<xcomplex<T> > &alms, 00093 int lmax, int mmax, PDT datatype) 00094 { 00095 fitshandle out; 00096 out.create(outfile); 00097 write_Alm_to_fits (out, alms, lmax, mmax, datatype); 00098 } 00099 00100 template<typename T> inline void write_Alm_to_fits 00101 (const std::string &outfile, const Alm<xcomplex<T> > &almT, 00102 const Alm<xcomplex<T> > &almG, const Alm<xcomplex<T> > &almC, 00103 int lmax, int mmax, PDT datatype) 00104 { 00105 fitshandle out; 00106 out.create(outfile); 00107 write_Alm_to_fits (out, almT, lmax, mmax, datatype); 00108 write_Alm_to_fits (out, almG, lmax, mmax, datatype); 00109 write_Alm_to_fits (out, almC, lmax, mmax, datatype); 00110 } 00111 00112 /*! Inserts a new binary table into \a out, which contains three columns 00113 of type PLANCK_INT32, \a datatype and \a datatype, respectively. 00114 The data in \a alms is written into this table; values outside 00115 the requested (\a lmax, \a mmax) range are omitted. Values with an absolute 00116 magnitude of zero are not written. */ 00117 template<typename T> void write_compressed_Alm_to_fits 00118 (fitshandle &out, const Alm<xcomplex<T> > &alms, 00119 int lmax, int mmax, PDT datatype); 00120 00121 /*! \} */ 00122 00123 #endif