| 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 | /* |
| 28 | * Copyright (C) 2003-2014 Max-Planck-Society |
| 29 | * Author: Martin Reinecke |
| 30 | */ |
| 31 | |
| 32 | #include "xcomplex.h"cxx . . $ `<file>/cxxsupport/xcomplex.h`/ |
| 33 | #include "paramfile.h"cxx . . $ `<file>/cxxsupport/paramfile.h`/ |
| 34 | #include "healpix_data_io.h"cxx . . $ `<file>/Healpix_cxx/healpix_data_io.h`/ |
| 35 | #include "alm.h"cxx . . $ `<file>/Healpix_cxx/alm.h`/ |
| 36 | #include "alm_fitsio.h"cxx . . $ `<file>/Healpix_cxx/alm_fitsio.h`/ |
| 37 | #include "healpix_map.h"cxx . . $ `<file>/Healpix_cxx/healpix_map.h`/ |
| 38 | #include "healpix_map_fitsio.h"cxx . . $ `<file>/Healpix_cxx/healpix_map_fitsio.h`/ |
| 39 | #include "alm_healpix_tools.h"cxx . . $ `<file>/Healpix_cxx/alm_healpix_tools.h`/ |
| 40 | #include "alm_powspec_tools.h"cxx . . $ `<file>/Healpix_cxx/alm_powspec_tools.h`/ |
| 41 | #include "fitshandle.h"cxx . . $ `<file>/cxxsupport/fitshandle.h`/ |
| 42 | #include "levels_facilities.h"cxx . . $ `<file>/cxxsupport/levels_facilities.h`/ |
| 43 | #include "lsconstants.h"cxx . . $ `<file>/cxxsupport/lsconstants.h`/ |
| 44 | #include "announce.h"cxx . . $ `<file>/cxxsupport/announce.h`/ |
| 45 | #include "planck_rng.h"cxx . . $ `<file>/cxxsupport/planck_rng.h`/ |
| 46 | |
| 47 | using namespace std; |
| 48 | |
| 49 | namespacecxx . . $ `$anonymous_namespace_Healpix_cxx/alm2map_cxx_module.cc`/ { |
| 50 | |
| 51 | template<typename T> void alm2map_cxxcxx . . $ `$anonymous_namespace_Healpix_cxx/alm2map_cxx_module.cc`/alm2map_cxx(d97daf492650e0bd). (paramfilecxx . . $ paramfile# ¶ms) |
| 52 | { |
| 53 | int nlmax = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<int>("nlmax"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 54 | int nmmax = params.template findcxx . . $ paramfile#find(937824ee5449f477).<int>("nmmax"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,nlmax); |
| 55 | planck_assertcxx . . $ `cxxsupport/error_handling.h:79:9`!(nmmax<=nlmax,"nmmax must not be larger than nlmax"); |
| 56 | stringcxx . . $ std/string# infile = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<stringcxx . . $ std/string#>("infile"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 57 | stringcxx . . $ std/string# outfile = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<stringcxx . . $ std/string#>("outfile"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 58 | int nside = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<int>("nside"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 59 | double fwhm = arcmin2radcxx . . $ arcmin2rad.*params.template findcxx . . $ paramfile#find(937824ee5449f477).<double>("fwhm_arcmin"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,0); |
| 60 | int cw_lmin=-1, cw_lmax=-1; |
| 61 | if (params.param_presentcxx . . $ paramfile#param_present(13a55b95a0133754).("cw_lmin"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)) |
| 62 | { |
| 63 | cw_lmin = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<int>("cw_lmin"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 64 | cw_lmax = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<int>("cw_lmax"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 65 | } |
| 66 | |
| 67 | arrcxx . . $ arr#<double> tempcxx . . $ arr#arr(49f6e7a06ebc5aa8)., polcxx . . $ arr#arr(49f6e7a06ebc5aa8).; |
| 68 | get_pixwincxx . . $ get_pixwin(7d81cd41b95d8a2c). (params,nlmax,temp,pol); |
| 69 | |
| 70 | bool deriv = params.template findcxx . . $ paramfile#find(937824ee5449f477).<bool>("derivatives"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,false); |
| 71 | if (deriv) |
| 72 | { |
| 73 | Almcxx . . $ Alm#<xcomplexcxx . . $ `cxxsupport/xcomplex.h:37:9`!<T> > alm; |
| 74 | read_Alm_from_fitscxx . . $ read_Alm_from_fits(f41e94ebb4c11c94).(infile,alm,nlmax,nmmax,2); |
| 75 | if (fwhm>0) smoothWithGausscxx . . $ smoothWithGauss(dcc3bb2faaa59317). (alm, fwhm); |
| 76 | if (cw_lmin>=0) applyCosineWindowcxx . . $ applyCosineWindow(497c821abf3251e9).(alm, cw_lmin, cw_lmax); |
| 77 | Healpix_Mapcxx . . $ Healpix_Map#<T> map(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.), |
| 78 | mapdth(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.), |
| 79 | mapdph(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.); |
| 80 | alm.ScaleLcxx . . $ Alm#ScaleL(6dd3fe9019a0682).(temp); |
| 81 | |
| 82 | double offset = alm(0,0).real()/cxx . . $ std/`operator/`(804c2413f71972e2).sqrt(fourpicxx . . $ fourpi.); |
| 83 | alm(0,0) = 0; |
| 84 | alm2map_der1cxx . . $ alm2map_der1(29449e204cc2cfd7).(alm,map,mapdth,mapdph); |
| 85 | map.Addcxx . . $ Healpix_Map#Add(9b289cee16747614).(T(offset)); |
| 86 | write_Healpix_map_to_fitscxx . . $ write_Healpix_map_to_fits(a14cf66223b0076b). (outfile,map,mapdth,mapdph,planckTypecxx . . $ planckType(6c96f92a229c7261).<T>()); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | bool polarisation = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<bool>("polarisation"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 91 | bool do_regnoise = params.param_presentcxx . . $ paramfile#param_present(13a55b95a0133754).("regnoiseT"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 92 | if (!polarisation) |
| 93 | { |
| 94 | Almcxx . . $ Alm#<xcomplexcxx . . $ `cxxsupport/xcomplex.h:37:9`!<T> > alm; |
| 95 | read_Alm_from_fitscxx . . $ read_Alm_from_fits(f41e94ebb4c11c94).(infile,alm,nlmax,nmmax,2); |
| 96 | if (fwhm>0) smoothWithGausscxx . . $ smoothWithGauss(dcc3bb2faaa59317). (alm, fwhm); |
| 97 | if (cw_lmin>=0) applyCosineWindowcxx . . $ applyCosineWindow(497c821abf3251e9).(alm, cw_lmin, cw_lmax); |
| 98 | Healpix_Mapcxx . . $ Healpix_Map#<T> map(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.); |
| 99 | alm.ScaleLcxx . . $ Alm#ScaleL(6dd3fe9019a0682).(temp); |
| 100 | |
| 101 | double offset = alm(0,0).real()/cxx . . $ std/`operator/`(804c2413f71972e2).sqrt(fourpicxx . . $ fourpi.); |
| 102 | alm(0,0) = 0; |
| 103 | alm2mapcxx . . $ alm2map(2408b94ef4a290fa).(alm,map); |
| 104 | map.Addcxx . . $ Healpix_Map#Add(9b289cee16747614).(T(offset)); |
| 105 | if (do_regnoise) |
| 106 | { |
| 107 | planck_rngcxx . . $ planck_rng# rngcxx . . $ planck_rng#planck_rng(eda338842932bf2b).(params.template findcxx . . $ paramfile#find(937824ee5449f477).<int>("rand_seed"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,42)); |
| 108 | double rms = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<double>("regnoiseT"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 109 | for (int i=0; i<cxx . . $ std/`operator<`(9c5f1f2306f1a4b2).map.Npixcxx . . $ T_Healpix_Base#Npix(8f5363d873dd4781).(); ++i) |
| 110 | map[i] += rms*rng.rand_gausscxx . . $ planck_rng#rand_gauss(31fa7155c10fdd13).(); |
| 111 | } |
| 112 | write_Healpix_map_to_fitscxx . . $ write_Healpix_map_to_fits(a14cf66223b0076b). (outfile,map,planckTypecxx . . $ planckType(6c96f92a229c7261).<T>()); |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | Almcxx . . $ Alm#<xcomplexcxx . . $ `cxxsupport/xcomplex.h:37:9`!<T> > almT, almG, almC; |
| 117 | read_Alm_from_fitscxx . . $ read_Alm_from_fits(f41e94ebb4c11c94).(infile,almT,almG,almC,nlmax,nmmax,2); |
| 118 | if (fwhm>0) smoothWithGausscxx . . $ smoothWithGauss(dcc3bb2faaa59317). (almT, almG, almC, fwhm); |
| 119 | if (cw_lmin>=0) applyCosineWindowcxx . . $ applyCosineWindow(497c821abf3251e9).(almT, almG, almC, cw_lmin, cw_lmax); |
| 120 | Healpix_Mapcxx . . $ Healpix_Map#<T> mapT(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.), mapQ(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.), |
| 121 | mapU(nside,RINGcxx . . $ RING.,SET_NSIDEcxx . . $ SET_NSIDE.); |
| 122 | almT.ScaleLcxx . . $ Alm#ScaleL(6dd3fe9019a0682).(temp); |
| 123 | almG.ScaleLcxx . . $ Alm#ScaleL(6dd3fe9019a0682).(pol); almC.ScaleLcxx . . $ Alm#ScaleL(6dd3fe9019a0682).(pol); |
| 124 | |
| 125 | double offset = almT(0,0).real()/cxx . . $ std/`operator/`(804c2413f71972e2).sqrt(fourpicxx . . $ fourpi.); |
| 126 | almT(0,0) = 0; |
| 127 | alm2map_polcxx . . $ alm2map_pol(f5b2cc01d4bb6b44).(almT,almG,almC,mapT,mapQ,mapU); |
| 128 | mapT.Addcxx . . $ Healpix_Map#Add(9b289cee16747614).(T(offset)); |
| 129 | if (do_regnoise) |
| 130 | { |
| 131 | planck_rngcxx . . $ planck_rng# rngcxx . . $ planck_rng#planck_rng(eda338842932bf2b).(params.template findcxx . . $ paramfile#find(937824ee5449f477).<int>("rand_seed"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,42)); |
| 132 | double rmsT = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<double>("regnoiseT"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).), |
| 133 | rmsQU = params.template findcxx . . $ paramfile#find(3d3f043628062f9c).<double>("regnoiseQU"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 134 | for (int i=0; i<cxx . . $ std/`operator<`(9c5f1f2306f1a4b2).mapT.Npixcxx . . $ T_Healpix_Base#Npix(8f5363d873dd4781).(); ++i) |
| 135 | { |
| 136 | mapT[i] += rmsT *rng.rand_gausscxx . . $ planck_rng#rand_gauss(31fa7155c10fdd13).(); |
| 137 | mapQ[i] += rmsQU*rng.rand_gausscxx . . $ planck_rng#rand_gauss(31fa7155c10fdd13).(); |
| 138 | mapU[i] += rmsQU*rng.rand_gausscxx . . $ planck_rng#rand_gauss(31fa7155c10fdd13).(); |
| 139 | } |
| 140 | } |
| 141 | write_Healpix_map_to_fitscxx . . $ write_Healpix_map_to_fits(a14cf66223b0076b). (outfile,mapT,mapQ,mapU,planckTypecxx . . $ planckType(6c96f92a229c7261).<T>()); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | } // unnamed namespace |
| 146 | |
| 147 | int alm2map_cxx_modulecxx . . $ alm2map_cxx_module(d8e43b79a186046c). (int argc, const char **argv) |
| 148 | { |
| 149 | module_startupcxx . . $ module_startup(6016d3cfa636e927). ("alm2map_cxx"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., argc, argv); |
| 150 | paramfilecxx . . $ paramfile# params (getParamsFromCmdlinecxx . . $ getParamsFromCmdline(7c6213c0f3b007ff).(argc,argv)); |
| 151 | |
| 152 | bool dp = params.findcxx . . $ paramfile#find(937824ee5449f477).<bool> ("double_precision"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,false); |
| 153 | dp ? alm2map_cxxcxx . . $ `$anonymous_namespace_Healpix_cxx/alm2map_cxx_module.cc`/alm2map_cxx(d97daf492650e0bd).<double>(params) : alm2map_cxxcxx . . $ `$anonymous_namespace_Healpix_cxx/alm2map_cxx_module.cc`/alm2map_cxx(d97daf492650e0bd).<float>(params); |
| 154 | return 0; |
| 155 | } |