Healpix C++  3.82
alm_fitsio.h
Go to the documentation of this file.
1 /*
2  * This file is part of Healpix_cxx.
3  *
4  * Healpix_cxx is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Healpix_cxx is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Healpix_cxx; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * For more information about HEALPix, see http://healpix.sourceforge.net
19  */
20 
21 /*
22  * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
23  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
24  * (DLR).
25  */
26 
27 /*! \file alm_fitsio.h
28  * FITS I/O for spherical harmonic coefficients
29  *
30  * Copyright (C) 2003-2017 Max-Planck-Society
31  * \author Martin Reinecke
32  */
33 
34 #ifndef PLANCK_ALM_FITSIO_H
35 #define PLANCK_ALM_FITSIO_H
36 
37 #include <string>
38 #include "xcomplex.h"
39 #include "datatypes.h"
40 #include "fitshandle.h"
41 
42 template<typename T> class Alm;
43 
44 /*! \defgroup alm_fitsio_group FITS-based I/O of a_lm */
45 /*! \{ */
46 
47 /*! Returns the maximum \a l and \a m multipole moments found in the FITS HDU
48  pointed to be \a inp in \a lmax and \a mmax. */
49 void get_almsize(fitshandle &inp, int &lmax, int &mmax);
50 /*! Returns the maximum \a l and \a m multipole moments found in the HDU
51  \a hdunum of file \a filename in \a lmax and \a mmax. */
52 void get_almsize(const std::string &filename, int &lmax, int &mmax,
53  int hdunum=2);
54 /*! Returns the maximum \a l and \a m multipole moments found in the HDUs
55  2, 3 and 4 of file \a filename in \a lmax and \a mmax. */
56 void get_almsize_pol(const std::string &filename, int &lmax, int &mmax);
57 
58 /*! Reads the a_lm of the FITS binary table pointed to by \a inp into
59  \a alms. \a alms is reallocated with the parameters \a lmax and \a mmax.
60  Values not present in the FITS table are set to zero; values outside
61  the requested (l,m) range are ignored. */
62 template<typename T> void read_Alm_from_fits
63  (fitshandle &inp, Alm<xcomplex<T> > &alms, int lmax, int mmax);
64 /*! Returns the a_lm of the FITS binary table pointed to by \a inp.
65  Values not present in the FITS table are set to zero; values outside
66  the requested (l,m) range are ignored. */
67 template<typename T> inline Alm<xcomplex<T> > read_Alm_from_fits
68  (fitshandle &inp, int lmax, int mmax)
69  {
70  Alm<xcomplex<T> > res;
71  read_Alm_from_fits (inp, res, lmax, mmax);
72  return res;
73  }
74 /*! Opens the FITS file \a filename, jumps to the HDU \a hdunum, then reads
75  the a_lm from the FITS binary table there into \a alms. \a alms is
76  reallocated with the parameters \a lmax and \a mmax.
77  Values not present in the FITS table are set to zero; values outside
78  the requested \a (l,m) range are ignored. */
79 template<typename T> void read_Alm_from_fits
80  (const std::string &filename, Alm<xcomplex<T> > &alms,
81  int lmax, int mmax, int hdunum=2);
82 /*! Opens the FITS file \a filename, jumps to the HDU \a hdunum, then returns
83  the a_lm from the FITS binary table there.
84  Values not present in the FITS table are set to zero; values outside
85  the requested \a (l,m) range are ignored. */
86 template<typename T> inline Alm<xcomplex<T> > read_Alm_from_fits
87  (const std::string &filename, int lmax, int mmax, int hdunum=2)
88  {
89  Alm<xcomplex<T> > res;
90  read_Alm_from_fits (filename, res, lmax, mmax, hdunum);
91  return res;
92  }
93 
94 template<typename T> inline void read_Alm_from_fits
95  (const std::string &filename, Alm<xcomplex<T> > &almT,
96  Alm<xcomplex<T> > &almG, Alm<xcomplex<T> > &almC,
97  int lmax, int mmax, int firsthdu=2)
98  {
99  read_Alm_from_fits (filename, almT, lmax, mmax, firsthdu);
100  read_Alm_from_fits (filename, almG, lmax, mmax, firsthdu+1);
101  read_Alm_from_fits (filename, almC, lmax, mmax, firsthdu+2);
102  }
103 
104 /*! Inserts a new binary table into \a out, which contains three columns
105  of type PLANCK_INT32, \a datatype and \a datatype, respectively.
106  The data in \a alms is written into this table; values outside
107  the requested (\a lmax, \a mmax) range are omitted. */
108 template<typename T> void write_Alm_to_fits
109  (fitshandle &out, const Alm<xcomplex<T> > &alms,
110  int lmax, int mmax, PDT datatype);
111 
112 template<typename T> inline void write_Alm_to_fits
113  (const std::string &outfile, const Alm<xcomplex<T> > &alms,
114  int lmax, int mmax, PDT datatype)
115  {
116  fitshandle out;
117  out.create(outfile);
118  write_Alm_to_fits (out, alms, lmax, mmax, datatype);
119  }
120 
121 template<typename T> inline void write_Alm_to_fits
122  (const std::string &outfile, const Alm<xcomplex<T> > &almT,
123  const Alm<xcomplex<T> > &almG, const Alm<xcomplex<T> > &almC,
124  int lmax, int mmax, PDT datatype)
125  {
126  fitshandle out;
127  out.create(outfile);
128  write_Alm_to_fits (out, almT, lmax, mmax, datatype);
129  write_Alm_to_fits (out, almG, lmax, mmax, datatype);
130  write_Alm_to_fits (out, almC, lmax, mmax, datatype);
131  }
132 
133 /*! Inserts a new binary table into \a out, which contains three columns
134  of type PLANCK_INT32, \a datatype and \a datatype, respectively.
135  The data in \a alms is written into this table; values outside
136  the requested (\a lmax, \a mmax) range are omitted. Values with an absolute
137  magnitude of zero are not written. */
138 template<typename T> void write_compressed_Alm_to_fits
139  (fitshandle &out, const Alm<xcomplex<T> > &alms,
140  int lmax, int mmax, PDT datatype);
141 
142 /*! \} */
143 
144 #endif
void write_Alm_to_fits(fitshandle &out, const Alm< xcomplex< T > > &alms, int lmax, int mmax, PDT datatype)
Definition: alm_fitsio.cc:151
void read_Alm_from_fits(fitshandle &inp, Alm< xcomplex< T > > &alms, int lmax, int mmax)
Definition: alm_fitsio.cc:95
Definition: alm.h:88
void get_almsize_pol(const std::string &filename, int &lmax, int &mmax)
void get_almsize(fitshandle &inp, int &lmax, int &mmax)
Definition: alm_fitsio.cc:42
void write_compressed_Alm_to_fits(fitshandle &out, const Alm< xcomplex< T > > &alms, int lmax, int mmax, PDT datatype)
Definition: alm_fitsio.cc:199

Generated on Thu Jul 28 2022 17:32:07 for Healpix C++