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_powspec_tools.h 00028 * Copyright (C) 2003-2014 Max-Planck-Society 00029 * \author Martin Reinecke 00030 */ 00031 00032 #ifndef PLANCK_ALM_POWSPEC_TOOLS_H 00033 #define PLANCK_ALM_POWSPEC_TOOLS_H 00034 00035 #include "xcomplex.h" 00036 00037 template<typename T> class Alm; 00038 class PowSpec; 00039 class planck_rng; 00040 class rotmatrix; 00041 00042 /*! \defgroup alm_ps_group Conversions between a_lm and power spectra */ 00043 /*! \{ */ 00044 00045 /*! Creates a Gaussian realisation of the input power spectrum \a powspec, 00046 using the random number generator \a rng, and returns the result 00047 in \a alm. */ 00048 template<typename T> void create_alm (const PowSpec &powspec, 00049 Alm<xcomplex<T> > &alm, planck_rng &rng); 00050 00051 /*! Creates a Gaussian realisation of the polarised input power spectrum 00052 \a powspec, using the random number generator \a rng, and returns the 00053 result in \a almT, \a almG and \a almC. */ 00054 template<typename T> void create_alm_pol 00055 (const PowSpec &powspec, 00056 Alm<xcomplex<T> > &almT, 00057 Alm<xcomplex<T> > &almG, 00058 Alm<xcomplex<T> > &almC, 00059 planck_rng &rng); 00060 00061 /*! Returns the unpolarised power spectrum of \a alm in \a powspec. */ 00062 template<typename T> void extract_powspec 00063 (const Alm<xcomplex<T> > &alm, PowSpec &powspec); 00064 /*! Returns the cross power spectrum of \a alm1 and \a alm2 in \a powspec. */ 00065 template<typename T> void extract_crosspowspec 00066 (const Alm<xcomplex<T> > &alm1, 00067 const Alm<xcomplex<T> > &alm2, PowSpec &powspec); 00068 /*! Returns the polarised power spectrum of \a almT, \a almG and \a almC 00069 in \a powspec. */ 00070 template<typename T> void extract_powspec 00071 (const Alm<xcomplex<T> > &almT, 00072 const Alm<xcomplex<T> > &almG, 00073 const Alm<xcomplex<T> > &almC, 00074 PowSpec &powspec); 00075 00076 /*! \} */ 00077 00078 /*! Applies a convolution with a Gaussian beam with an FWHM of 00079 \a fwhm (in radian) to \a alm. 00080 \note If \a fwhm<0, a deconvolution with \a -fwhm is performed. 00081 \relates Alm */ 00082 template<typename T> void smoothWithGauss 00083 (Alm<xcomplex<T> > &alm, double fwhm); 00084 /*! Applies a convolution with a Gaussian beam with an FWHM of 00085 \a fwhm (in radian) to \a almT, \a almG and \a almC. 00086 \note If \a fwhm<0, a deconvolution with \a -fwhm is performed. 00087 \relates Alm */ 00088 template<typename T> void smoothWithGauss 00089 (Alm<xcomplex<T> > &almT, 00090 Alm<xcomplex<T> > &almG, 00091 Alm<xcomplex<T> > &almC, 00092 double fwhm); 00093 00094 /*! Applies a function to \a alm that is 1 for all \c l<=lmin, 0 for all 00095 \c l>=lmax, and \c 0.5*(1+cos((l-lmin)/(lmax-lmin)*pi)) in between. 00096 \relates Alm */ 00097 template<typename T> void applyCosineWindow 00098 (Alm<xcomplex<T> > &alm, int lmin, int lmax); 00099 00100 template<typename T> inline void applyCosineWindow 00101 (Alm<xcomplex<T> > &almT, Alm<xcomplex<T> > &almG, Alm<xcomplex<T> > &almC, 00102 int lmin, int lmax) 00103 { 00104 applyCosineWindow(almT,lmin,lmax); 00105 applyCosineWindow(almG,lmin,lmax); 00106 applyCosineWindow(almC,lmin,lmax); 00107 } 00108 00109 /*! Rotates \a alm through the Euler angles \a psi, \a theta and \a phi. 00110 The Euler angle convention is right handed, rotations are active. 00111 - \a psi is the first rotation about the z-axis (vertical) 00112 - then \a theta about the ORIGINAL (unrotated) y-axis 00113 - then \a phi about the ORIGINAL (unrotated) z-axis (vertical) 00114 \relates Alm */ 00115 template<typename T> void rotate_alm (Alm<xcomplex<T> > &alm, 00116 double psi, double theta, double phi); 00117 00118 /*! Rotates \a almT, \a almG and \a almC through the Euler angles 00119 \a psi, \a theta and \a phi. 00120 The Euler angle convention is right handed, rotations are active. 00121 - \a psi is the first rotation about the z-axis (vertical) 00122 - then \a theta about the ORIGINAL (unrotated) y-axis 00123 - then \a phi about the ORIGINAL (unrotated) z-axis (vertical) 00124 \relates Alm */ 00125 template<typename T> void rotate_alm (Alm<xcomplex<T> > &almT, 00126 Alm<xcomplex<T> > &almG, Alm<xcomplex<T> > &almC, 00127 double psi, double theta, double phi); 00128 00129 /*! Rotates \a alm through the rotation matrix \a mat. 00130 \relates Alm */ 00131 template<typename T> void rotate_alm (Alm<xcomplex<T> > &alm, 00132 const rotmatrix &mat); 00133 00134 /*! Rotates \a almT, \a almG and \a almC through the rotation matrix \a mat. 00135 \relates Alm */ 00136 template<typename T> void rotate_alm (Alm<xcomplex<T> > &almT, 00137 Alm<xcomplex<T> > &almG, Alm<xcomplex<T> > &almC, 00138 const rotmatrix &mat); 00139 00140 #endif