[729] | 1 | #ifndef SPHERICALTRANFORMSERVER_SEEN
|
---|
| 2 | #define SPHERICALTRANFORMSERVER_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "sphericalmap.h"
|
---|
| 5 | #include "fftservintf.h"
|
---|
| 6 | #include "fftpserver.h"
|
---|
| 7 | #include "alm.h"
|
---|
| 8 | #include "lambdaBuilder.h"
|
---|
| 9 |
|
---|
| 10 |
|
---|
[746] | 11 | namespace SOPHYA {
|
---|
[729] | 12 |
|
---|
| 13 | //
|
---|
| 14 | /*! Class for performing analysis and synthesis of sky maps using spin-0 or spin-2 spherical harmonics.
|
---|
[866] | 15 |
|
---|
| 16 | Maps must be SOPHYA SphericalMaps (SphereGorski or SphereThetaPhi).
|
---|
| 17 |
|
---|
| 18 | Temperature and polarization (Stokes parameters) can be developped on spherical harmonics :
|
---|
| 19 | \f[
|
---|
| 20 | \frac{\Delta T}{T}(\hat{n})=\sum_{lm}a_{lm}^TY_l^m(\hat{n})
|
---|
| 21 | \f]
|
---|
| 22 | \f[
|
---|
| 23 | Q(\hat{n})=\frac{1}{\sqrt{2}}\sum_{lm}N_l\left(a_{lm}^EW_{lm}(\hat{n})+a_{lm}^BX_{lm}(\hat{n})\right)
|
---|
| 24 | \f]
|
---|
| 25 | \f[
|
---|
| 26 | U(\hat{n})=-\frac{1}{\sqrt{2}}\sum_{lm}N_l\left(a_{lm}^EX_{lm}(\hat{n})-a_{lm}^BW_{lm}(\hat{n})\right)
|
---|
| 27 | \f]
|
---|
| 28 | \f[
|
---|
| 29 | \left(Q \pm iU\right)(\hat{n})=\sum_{lm}a_{\pm 2lm}\, _{\pm 2}Y_l^m(\hat{n})
|
---|
| 30 | \f]
|
---|
| 31 |
|
---|
| 32 | \f[
|
---|
| 33 | Y_l^m(\hat{n})=\lambda_l^m(\theta)e^{im\phi}
|
---|
| 34 | \f]
|
---|
| 35 | \f[
|
---|
| 36 | _{\pm}Y_l^m(\hat{n})=_{\pm}\lambda_l^m(\theta)e^{im\phi}
|
---|
| 37 | \f]
|
---|
| 38 | \f[
|
---|
| 39 | W_{lm}(\hat{n})=\frac{1}{N_l}\,_{w}\lambda_l^m(\theta)e^{im\phi}
|
---|
| 40 | \f]
|
---|
| 41 | \f[
|
---|
| 42 | X_{lm}(\hat{n})=\frac{-i}{N_l}\,_{x}\lambda_l^m(\theta)e^{im\phi}
|
---|
| 43 | \f]
|
---|
| 44 |
|
---|
| 45 | (see LambdaLMBuilder, LambdaPMBuilder, LambdaWXBuilder classes)
|
---|
| 46 |
|
---|
| 47 | power spectra :
|
---|
| 48 |
|
---|
| 49 | \f[
|
---|
| 50 | C_l^T=\frac{1}{2l+1}\sum_{m=0}^{+ \infty }\left|a_{lm}^T\right|^2=\langle\left|a_{lm}^T\right|^2\rangle
|
---|
| 51 | \f]
|
---|
| 52 | \f[
|
---|
| 53 | C_l^E=\frac{1}{2l+1}\sum_{m=0}^{+\infty}\left|a_{lm}^E\right|^2=\langle\left|a_{lm}^E\right|^2\rangle
|
---|
| 54 | \f]
|
---|
| 55 | \f[
|
---|
| 56 | C_l^B=\frac{1}{2l+1}\sum_{m=0}^{+\infty}\left|a_{lm}^B\right|^2=\langle\left|a_{lm}^B\right|^2\rangle
|
---|
| 57 | \f]
|
---|
| 58 |
|
---|
| 59 | \arg
|
---|
| 60 | \b Synthesis : Get temperature and polarization maps from \f$a_{lm}\f$ coefficients or from power spectra, (methods GenerateFrom...).
|
---|
| 61 |
|
---|
| 62 | \b Temperature:
|
---|
| 63 | \f[
|
---|
| 64 | \frac{\Delta T}{T}(\hat{n})=\sum_{lm}a_{lm}^TY_l^m(\hat{n}) = \sum_{-\infty}^{+\infty}b_m(\theta)e^{im\phi}
|
---|
| 65 | \f]
|
---|
| 66 |
|
---|
| 67 | with
|
---|
| 68 | \f[
|
---|
| 69 | b_m(\theta)=\sum_{l=\left|m\right|}^{+\infty}a_{lm}^T\lambda_l^m(\theta)
|
---|
| 70 | \f]
|
---|
| 71 |
|
---|
| 72 | \b Polarisation
|
---|
| 73 | \f[
|
---|
| 74 | Q \pm iU = \sum_{-\infty}^{+\infty}b_m^{\pm}(\theta)e^{im\phi}
|
---|
| 75 | \f]
|
---|
| 76 |
|
---|
| 77 | where :
|
---|
| 78 | \f[
|
---|
| 79 | b_m^{\pm}(\theta) = \sum_{l=\left|m\right|}^{+\infty}a_{\pm 2lm}\,_{\pm}\lambda_l^m(\theta)
|
---|
| 80 | \f]
|
---|
| 81 |
|
---|
| 82 | or :
|
---|
| 83 | \f[
|
---|
| 84 | Q = \sum_{-\infty}^{+\infty}b_m^{Q}(\theta)e^{im\phi}
|
---|
| 85 | \f]
|
---|
| 86 | \f[
|
---|
| 87 | U = \sum_{-\infty}^{+\infty}b_m^{U}(\theta)e^{im\phi}
|
---|
| 88 | \f]
|
---|
| 89 |
|
---|
| 90 | where:
|
---|
| 91 | \f[
|
---|
| 92 | b_m^{Q}(\theta) = \frac{1}{\sqrt{2}}\sum_{l=\left|m\right|}^{+\infty}\left(a_{lm}^E\,_{w}\lambda_l^m(\theta)-ia_{lm}^B\,_{x}\lambda_l^m(\theta)\right)
|
---|
| 93 | \f]
|
---|
| 94 | \f[
|
---|
| 95 | b_m^{U}(\theta) = \frac{1}{\sqrt{2}}\sum_{l=\left|m\right|}^{+\infty}\left(ia_{lm}^E\,_{x}\lambda_l^m(\theta)+a_{lm}^B\,_{w}\lambda_l^m(\theta)\right)
|
---|
| 96 | \f]
|
---|
| 97 |
|
---|
| 98 | Since the pixelization provides "slices" with constant \f$\theta\f$ and \f$\phi\f$ equally distributed on \f$2\pi\f$ \f$\frac{\Delta T}{T}\f$, \f$Q\f$,\f$U\f$ can be computed by FFT.
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | \arg
|
---|
| 102 | \b Analysis : Get \f$a_{lm}\f$ coefficients or power spectra from temperature and polarization maps (methods DecomposeTo...).
|
---|
| 103 |
|
---|
| 104 | \b Temperature:
|
---|
| 105 | \f[
|
---|
| 106 | a_{lm}^T=\int\frac{\Delta T}{T}(\hat{n})Y_l^{m*}(\hat{n})d\hat{n}
|
---|
| 107 | \f]
|
---|
| 108 |
|
---|
| 109 | approximated as :
|
---|
| 110 | \f[
|
---|
| 111 | a_{lm}^T=\sum_{\theta_k}\omega_kC_m(\theta_k)\lambda_l^m(\theta_k)
|
---|
| 112 | \f]
|
---|
| 113 | where :
|
---|
| 114 | \f[
|
---|
| 115 | C_m (\theta _k)=\sum_{\phi _{k\prime}}\frac{\Delta T}{T}(\theta _k,\phi_{k\prime})e^{-im\phi _{k\prime}}
|
---|
| 116 | \f]
|
---|
| 117 | Since the pixelization provides "slices" with constant \f$\theta\f$ and \f$\phi\f$ equally distributed on \f$2\pi\f$ (\f$\omega_k\f$ is the solid angle of each pixel of the slice \f$\theta_k\f$) \f$C_m\f$ can be computed by FFT.
|
---|
| 118 |
|
---|
| 119 | \b polarisation:
|
---|
| 120 |
|
---|
| 121 | \f[
|
---|
| 122 | a_{\pm 2lm}=\sum_{\theta_k}\omega_kC_m^{\pm}(\theta_k)\,_{\pm}\lambda_l^m(\theta_k)
|
---|
| 123 | \f]
|
---|
| 124 | where :
|
---|
| 125 | \f[
|
---|
| 126 | C_m^{\pm} (\theta _k)=\sum_{\phi _{k\prime}}\left(Q \pm iU\right)(\theta _k,\phi_{k\prime})e^{-im\phi _{k\prime}}
|
---|
| 127 | \f]
|
---|
| 128 | or :
|
---|
| 129 |
|
---|
| 130 | \f[
|
---|
| 131 | a_{lm}^E=\frac{1}{\sqrt{2}}\sum_{\theta_k}\omega_k\left(C_m^{Q}(\theta_k)\,_{w}\lambda_l^m(\theta_k)-iC_m^{U}(\theta_k)\,_{x}\lambda_l^m(\theta_k)\right)
|
---|
| 132 | \f]
|
---|
| 133 | \f[
|
---|
| 134 | a_{lm}^B=\frac{1}{\sqrt{2}}\sum_{\theta_k}\omega_k\left(iC_m^{Q}(\theta_k)\,_{x}\lambda_l^m(\theta_k)+C_m^{U}(\theta_k)\,_{w}\lambda_l^m(\theta_k)\right)
|
---|
| 135 | \f]
|
---|
| 136 |
|
---|
| 137 | where :
|
---|
| 138 | \f[
|
---|
| 139 | C_m^{Q} (\theta _k)=\sum_{\phi _{k\prime}}Q(\theta _k,\phi_{k\prime})e^{-im\phi _{k\prime}}
|
---|
| 140 | \f]
|
---|
| 141 | \f[
|
---|
| 142 | C_m^{U} (\theta _k)=\sum_{\phi _{k\prime}}U(\theta _k,\phi_{k\prime})e^{-im\phi _{k\prime}}
|
---|
| 143 | \f]
|
---|
| 144 |
|
---|
[729] | 145 | */
|
---|
| 146 | template <class T>
|
---|
| 147 | class SphericalTransformServer
|
---|
| 148 | {
|
---|
| 149 |
|
---|
| 150 | public:
|
---|
| 151 |
|
---|
| 152 | SphericalTransformServer()
|
---|
| 153 | {
|
---|
| 154 | fftIntfPtr_=new FFTPackServer;
|
---|
| 155 | fftIntfPtr_->setNormalize(false);
|
---|
| 156 | };
|
---|
| 157 | ~SphericalTransformServer(){ if (fftIntfPtr_!=NULL) delete fftIntfPtr_;};
|
---|
| 158 | /*!
|
---|
| 159 | Set a fft server. The constructor sets a default fft server (fft-pack). So it is not necessary to call this method for a standard use.
|
---|
| 160 | */
|
---|
| 161 | void SetFFTServer(FFTServerInterface* srv=NULL)
|
---|
| 162 | {
|
---|
| 163 | if (fftIntfPtr_!=NULL) delete fftIntfPtr_;
|
---|
| 164 | fftIntfPtr_=srv;
|
---|
| 165 | fftIntfPtr_->setNormalize(false);
|
---|
| 166 | }
|
---|
| 167 | /*! synthesis of a temperature map from Alm coefficients */
|
---|
| 168 | void GenerateFromAlm( SphericalMap<T>& map, int_4 pixelSizeIndex, const Alm<T>& alm) const;
|
---|
| 169 | /*! synthesis of a polarization map from Alm coefficients. The spheres mapq and mapu contain respectively the Stokes parameters. */
|
---|
| 170 | void GenerateFromAlm(SphericalMap<T>& mapq, SphericalMap<T>& mapu, int_4 pixelSizeIndex, const Alm<T>& alme, const Alm<T>& almb) const;
|
---|
| 171 |
|
---|
| 172 | /*! synthesis of a temperature map from power spectrum Cl (Alm's are generated randomly, following a gaussian distribution). */
|
---|
| 173 | void GenerateFromCl(SphericalMap<T>& sph, int_4 pixelSizeIndex,
|
---|
| 174 | const TVector<T>& Cl, const r_8 fwhm) const;
|
---|
| 175 | /*! synthesis of a polarization map from power spectra electric-Cl and magnetic-Cl (Alm's are generated randomly, following a gaussian distribution).
|
---|
| 176 | \param fwhm FWHM in arcmin for random generation of Alm's (eg. 5)
|
---|
| 177 |
|
---|
| 178 | */
|
---|
| 179 | void GenerateFromCl(SphericalMap<T>& sphq, SphericalMap<T>& sphu,
|
---|
| 180 | int_4 pixelSizeIndex,
|
---|
| 181 | const TVector<T>& Cle, const TVector<T>& Clb,
|
---|
| 182 | const r_8 fwhm) const;
|
---|
| 183 | /*!return the Alm coefficients from analysis of a temperature map.
|
---|
| 184 |
|
---|
[866] | 185 | \param<nlmax> : maximum value of the l index
|
---|
[729] | 186 |
|
---|
[866] | 187 | \param<cos_theta_cut> : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
|
---|
[729] | 188 | */
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | Alm<T> DecomposeToAlm(const SphericalMap<T>& map, int_4 nlmax, r_8 cos_theta_cut) const;
|
---|
[866] | 192 | /*!analysis of a polarization map into Alm coefficients.
|
---|
[729] | 193 |
|
---|
[866] | 194 | The spheres \c mapq and \c mapu contain respectively the Stokes parameters.
|
---|
[729] | 195 |
|
---|
[866] | 196 | \c a2lme and \c a2lmb will receive respectively electric and magnetic Alm's
|
---|
[729] | 197 | nlmax : maximum value of the l index
|
---|
| 198 |
|
---|
[866] | 199 | \c cos_theta_cut : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
|
---|
[729] | 200 | */
|
---|
| 201 |
|
---|
| 202 | void DecomposeToAlm(const SphericalMap<T>& mapq, const SphericalMap<T>& mapu,
|
---|
| 203 | Alm<T>& a2lme, Alm<T>& a2lmb,
|
---|
| 204 | int_4 nlmax, r_8 cos_theta_cut) const;
|
---|
| 205 |
|
---|
[866] | 206 | /*!return power spectrum from analysis of a temperature map.
|
---|
[729] | 207 |
|
---|
[866] | 208 | \param<nlmax> : maximum value of the l index
|
---|
[729] | 209 |
|
---|
[866] | 210 | \param<cos_theta_cut> : cosinus of the symmetric cut EULER angle theta : cos_theta_cut=0 means no cut ; cos_theta_cut=1 all the sphere is cut.
|
---|
| 211 | */
|
---|
[729] | 212 | TVector<T> DecomposeToCl(const SphericalMap<T>& sph,
|
---|
| 213 | int_4 nlmax, r_8 cos_theta_cut) const;
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | private:
|
---|
| 217 | /*! return a vector with nph elements which are sums :\f$\sum_{m=-mmax}^{mmax}b_m(\theta)e^{im\varphi}\f$ for nph values of \f$\varphi\f$ regularly distributed in \f$[0,\pi]\f$ ( calculated by FFT)
|
---|
| 218 |
|
---|
| 219 | The object b_m (\f$b_m\f$) of the class Bm is a special vector which index goes from -mmax to mmax.
|
---|
| 220 | */
|
---|
| 221 | TVector< complex<T> > fourierSynthesisFromB(const Bm<complex<T> >& b_m,
|
---|
| 222 | int_4 nph, r_8 phi0) const;
|
---|
| 223 | /*! same as fourierSynthesisFromB, but return a real vector, taking into account the fact that b(-m) is conjugate of b(m) */
|
---|
| 224 | TVector<T> RfourierSynthesisFromB(const Bm<complex<T> >& b_m,
|
---|
| 225 | int_4 nph, r_8 phi0) const;
|
---|
| 226 |
|
---|
| 227 | /*! return a vector with mmax elements which are sums :
|
---|
| 228 | \f$\sum_{k=0}^{nphi}datain(\theta,\varphi_k)e^{im\varphi_k}\f$ for (mmax+1) values of \f$m\f$ from 0 to mmax.
|
---|
| 229 | */
|
---|
[746] | 230 | TVector< complex<T> > CFromFourierAnalysis(int_4 mmax,
|
---|
[729] | 231 | const TVector<complex<T> > datain,
|
---|
| 232 | r_8 phi0) const;
|
---|
| 233 | /* same as previous one, but with a "datain" which is real (not complex) */
|
---|
[746] | 234 | TVector< complex<T> > CFromFourierAnalysis(int_4 mmax,
|
---|
[729] | 235 | const TVector<T> datain,
|
---|
| 236 | r_8 phi0) const;
|
---|
| 237 |
|
---|
| 238 | /*!
|
---|
| 239 | Compute polarized Alm's as :
|
---|
| 240 | \f[
|
---|
[866] | 241 | a_{lm}^E=\frac{1}{\sqrt{2}}\sum_{slices}{\omega_{pix}\left(\,_{w}\lambda_l^m\tilde{Q}-i\,_{x}\lambda_l^m\tilde{U}\right)}
|
---|
[729] | 242 | \f]
|
---|
| 243 | \f[
|
---|
[866] | 244 | a_{lm}^B=\frac{1}{\sqrt{2}}\sum_{slices}{\omega_{pix}\left(i\,_{x}\lambda_l^m\tilde{Q}+\,_{w}\lambda_l^m\tilde{U}\right)}
|
---|
[729] | 245 | \f]
|
---|
| 246 |
|
---|
| 247 | where \f$\tilde{Q}\f$ and \f$\tilde{U}\f$ are C-coefficients computed by FFT (method CFromFourierAnalysis, called by present method) from the Stokes parameters.
|
---|
| 248 |
|
---|
| 249 | \f$\omega_{pix}\f$ are solid angle of each pixel.
|
---|
| 250 |
|
---|
| 251 | dataq, datau : Stokes parameters.
|
---|
| 252 |
|
---|
| 253 | */
|
---|
[746] | 254 | void almFromWX(int_4 nlmax, int_4 nmmax, r_8 phi0,
|
---|
[729] | 255 | r_8 domega, r_8 theta,
|
---|
| 256 | const TVector<T>& dataq, const TVector<T>& datau,
|
---|
| 257 | Alm<T>& alme, Alm<T>& almb) const;
|
---|
| 258 | /*!
|
---|
| 259 | Compute polarized Alm's as :
|
---|
| 260 | \f[
|
---|
[866] | 261 | a_{lm}^E=-\frac{1}{2}\sum_{slices}{\omega_{pix}\left(\,_{+}\lambda_l^m\tilde{P^+}+\,_{-}\lambda_l^m\tilde{P^-}\right)}
|
---|
[729] | 262 | \f]
|
---|
| 263 | \f[
|
---|
[866] | 264 | a_{lm}^B=\frac{i}{2}\sum_{slices}{\omega_{pix}\left(\,_{+}\lambda_l^m\tilde{P^+}-\,_{-}\lambda_l^m\tilde{P^-}\right)}
|
---|
[729] | 265 | \f]
|
---|
| 266 |
|
---|
| 267 | where \f$\tilde{P^{\pm}}=\tilde{Q}\pm\tilde{U}\f$ computed by FFT (method CFromFourierAnalysis, called by present method) from the Stokes parameters,\f$Q\f$ and \f$U\f$ .
|
---|
| 268 |
|
---|
| 269 | \f$\omega_{pix}\f$ are solid angle of each pixel.
|
---|
| 270 |
|
---|
| 271 | dataq, datau : Stokes parameters.
|
---|
| 272 |
|
---|
| 273 | */
|
---|
| 274 | void almFromPM(int_4 nph, int_4 nlmax, int_4 nmmax,
|
---|
| 275 | r_8 phi0, r_8 domega, r_8 theta,
|
---|
| 276 | const TVector<T>& dataq, const TVector<T>& datau,
|
---|
| 277 | Alm<T>& alme, Alm<T>& almb) const;
|
---|
| 278 |
|
---|
| 279 | /*! synthesis of Stokes parameters following formulae :
|
---|
| 280 |
|
---|
| 281 | \f[
|
---|
| 282 | Q=\sum_{m=-mmax}^{mmax}b_m^qe^{im\varphi}
|
---|
| 283 | \f]
|
---|
| 284 | \f[
|
---|
| 285 | U=\sum_{m=-mmax}^{mmax}b_m^ue^{im\varphi}
|
---|
| 286 | \f]
|
---|
| 287 |
|
---|
| 288 | computed by FFT (method fourierSynthesisFromB called by the present one)
|
---|
| 289 |
|
---|
| 290 | with :
|
---|
| 291 |
|
---|
| 292 | \f[
|
---|
[866] | 293 | b_m^q=-\frac{1}{\sqrt{2}}\sum_{l=|m|}^{lmax}{\left(\,_{w}\lambda_l^ma_{lm}^E-i\,_{x}\lambda_l^ma_{lm}^B\right) }
|
---|
[729] | 294 | \f]
|
---|
| 295 | \f[
|
---|
[866] | 296 | b_m^u=\frac{1}{\sqrt{2}}\sum_{l=|m|}^{lmax}{\left(i\,_{x}\lambda_l^ma_{lm}^E+\,_{w}\lambda_l^ma_{lm}^B\right) }
|
---|
[729] | 297 | \f]
|
---|
| 298 | */
|
---|
| 299 | void mapFromWX(int_4 nlmax, int_4 nmmax,
|
---|
| 300 | SphericalMap<T>& mapq, SphericalMap<T>& mapu,
|
---|
| 301 | const Alm<T>& alme, const Alm<T>& almb) const;
|
---|
| 302 |
|
---|
| 303 | /*! synthesis of polarizations following formulae :
|
---|
| 304 |
|
---|
| 305 | \f[
|
---|
| 306 | P^+ = \sum_{m=-mmax}^{mmax} {b_m^+e^{im\varphi} }
|
---|
| 307 | \f]
|
---|
| 308 | \f[
|
---|
| 309 | P^- = \sum_{m=-mmax}^{mmax} {b_m^-e^{im\varphi} }
|
---|
| 310 | \f]
|
---|
| 311 |
|
---|
| 312 | computed by FFT (method fourierSynthesisFromB called by the present one)
|
---|
| 313 |
|
---|
| 314 | with :
|
---|
| 315 |
|
---|
| 316 | \f[
|
---|
[866] | 317 | b_m^+=-\sum_{l=|m|}^{lmax}{\,_{+}\lambda_l^m \left( a_{lm}^E+ia_{lm}^B \right) }
|
---|
[729] | 318 | \f]
|
---|
| 319 | \f[
|
---|
[866] | 320 | b_m^-=-\sum_{l=|m|}^{lmax}{\,_{+}\lambda_l^m \left( a_{lm}^E-ia_{lm}^B \right) }
|
---|
[729] | 321 | \f]
|
---|
| 322 | */
|
---|
| 323 |
|
---|
| 324 | void mapFromPM(int_4 nlmax, int_4 nmmax,
|
---|
| 325 | SphericalMap<T>& mapq, SphericalMap<T>& mapu,
|
---|
| 326 | const Alm<T>& alme, const Alm<T>& almb) const;
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 |
|
---|
| 330 | FFTServerInterface* fftIntfPtr_;
|
---|
| 331 | };
|
---|
[746] | 332 | } // Fin du namespace
|
---|
[729] | 333 |
|
---|
| 334 |
|
---|
| 335 | #endif
|
---|