1 | #ifndef SPHEREGORSKI_SEEN
|
---|
2 | #define SPHEREGORSKI_SEEN
|
---|
3 |
|
---|
4 | #include "sphericalmap.h"
|
---|
5 | #include "tvector.h"
|
---|
6 | #include "ndatablock.h"
|
---|
7 |
|
---|
8 | #include "anydataobj.h"
|
---|
9 | #include "ppersist.h"
|
---|
10 |
|
---|
11 | // les attributs de classe pix2x_ et pix2y_ sont relatifs a la traduction des
|
---|
12 | // indices RING en indices NESTED (ou l inverse). Ce sont des tableaux
|
---|
13 | // d'entiers initialises et remplis par le constructeur. Dans la version
|
---|
14 | // FORTRAN de healpix, il s'agissait de tableaux mis en COMMON. Ils etaient
|
---|
15 | // initialises au premier appel d'une conversion d indice. Je ne peux pas
|
---|
16 | // garder cette procedure car, par exemple, la fonction PixValNest() const
|
---|
17 | // n'autorisera pas la constitution de ces tableaux (a cause du const). Ainsi,
|
---|
18 | // des la creation d un objet SphereGorski ces tableaux sont calcules, ce qui
|
---|
19 | // est, certes, inutile si on ne se sert pas des indices NESTED. Ca ne me
|
---|
20 | // rejouit pas, mais c est le seul moyen que j ai trouve pour temir compte de
|
---|
21 | // toutes les demandes et des options prises.
|
---|
22 | //
|
---|
23 | // G. Le Meur
|
---|
24 |
|
---|
25 | // ***************** CLASSE SphereGorski *****************************
|
---|
26 |
|
---|
27 | template<class T>
|
---|
28 | class SphereGorski : public SphericalMap<T>, public AnyDataObj
|
---|
29 | {
|
---|
30 |
|
---|
31 | public :
|
---|
32 |
|
---|
33 | SphereGorski();
|
---|
34 | SphereGorski(int m);
|
---|
35 | SphereGorski(const SphereGorski<T>& s);
|
---|
36 | virtual ~SphereGorski();
|
---|
37 |
|
---|
38 | // ------------------ Definition of PixelMap abstract methods
|
---|
39 |
|
---|
40 | /* Nombre de pixels du decoupage */
|
---|
41 | virtual int NbPixels() const;
|
---|
42 | inline void setNbPixels(int n) {nPix_= n;}
|
---|
43 |
|
---|
44 | /* Valeur du contenu du pixel d'indice "RING" k */
|
---|
45 | virtual T& PixVal(int k);
|
---|
46 | virtual T const& PixVal(int k) const;
|
---|
47 |
|
---|
48 | /* Nombre de tranches en theta */
|
---|
49 | int NbThetaSlices() const;
|
---|
50 | void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
51 |
|
---|
52 | /* Indice "RING" du pixel vers lequel pointe une direction definie par
|
---|
53 | ses coordonnees spheriques */
|
---|
54 | virtual int PixIndexSph(double theta,double phi) const;
|
---|
55 |
|
---|
56 | /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
|
---|
57 | virtual void PixThetaPhi(int k,double& theta,double& phi) const;
|
---|
58 |
|
---|
59 | /* Pixel Solid angle (steradians) */
|
---|
60 | virtual double PixSolAngle(int dummy) const;
|
---|
61 | inline void setPixSolAngle(double x) {omeg_= x;}
|
---|
62 |
|
---|
63 | // --------------- Specific methods
|
---|
64 |
|
---|
65 | virtual void Resize(int m);
|
---|
66 |
|
---|
67 | inline virtual char* TypeOfMap() const {return "RING";};
|
---|
68 |
|
---|
69 | /* Valeur du contenu du pixel d'indice "NEST" k */
|
---|
70 | virtual T& PixValNest(int k);
|
---|
71 | virtual T const& PixValNest(int k) const;
|
---|
72 |
|
---|
73 | /* Indice "NEST" du pixel vers lequel pointe une direction definie par
|
---|
74 | ses coordonnees spheriques */
|
---|
75 | virtual int PixIndexSphNest(double theta,double phi) const;
|
---|
76 |
|
---|
77 | /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
|
---|
78 | virtual void PixThetaPhiNest(int k,double& theta,double& phi) const;
|
---|
79 |
|
---|
80 | /* algorithme de pixelisation */
|
---|
81 | void Pixelize(int);
|
---|
82 |
|
---|
83 | /* convertit index nested en ring */
|
---|
84 | int NestToRing(int) const;
|
---|
85 |
|
---|
86 | /* convertit index ring en nested" */
|
---|
87 | int RingToNest(int) const;
|
---|
88 |
|
---|
89 | /* analyse en harmoniques spheriques des valeurs des pixels de la
|
---|
90 | sphere : appel du module anafast (Gorski-Hivon) */
|
---|
91 | //void anharm(int, float, float*);
|
---|
92 |
|
---|
93 | /*synthese des valeurs des pixels de la sphere par l'intermediaire
|
---|
94 | des coefficients en harmoniques spheriques reconstitues apartir d'un
|
---|
95 | spectre en puissance : appel du module synfast (Gorski-Hivon) */
|
---|
96 | //void synharm(int, int, float, float*);
|
---|
97 |
|
---|
98 | /* retourne/fixe la valeur du parametre Gorski */
|
---|
99 | inline virtual int SizeIndex() const {return(nSide_);}
|
---|
100 | inline void setSizeIndex(int n) {nSide_= n;}
|
---|
101 |
|
---|
102 | /* retourne les pointeurs /remplit les tableaux */
|
---|
103 | inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
|
---|
104 | inline void setDataBlock(T* data,int m) { pixels_.FillFrom(m,data); }
|
---|
105 |
|
---|
106 | /* retourne/fixe les parametres des modules anafast et synfast */
|
---|
107 | void getParafast(int& nlmax,int& nmmax,int& iseed,float& fwhm,float& quadr,float& cut) const;
|
---|
108 | void setParafast(int nlmax,int nmmax,int iseed,float fwhm,float quadr,float cut,char* filename);
|
---|
109 |
|
---|
110 | /* retourne/fixe le nom du fichier qui contient le spectre de puissance */
|
---|
111 | void powfile(char filename[]) const;
|
---|
112 |
|
---|
113 | /* impression */
|
---|
114 | void print(ostream& os) const;
|
---|
115 |
|
---|
116 | private :
|
---|
117 |
|
---|
118 | // ------------- méthodes internes ----------------------
|
---|
119 | void InitNul();
|
---|
120 |
|
---|
121 | int nest2ring(int nside,int ipnest) const;
|
---|
122 | int ring2nest(int nside,int ipring) const;
|
---|
123 |
|
---|
124 | int ang2pix_ring(int nside,double theta,double phi) const;
|
---|
125 | int ang2pix_nest(int nside,double theta,double phi) const;
|
---|
126 | void pix2ang_ring(int nside,int ipix,double& theta,double& phi) const;
|
---|
127 | void pix2ang_nest(int nside,int ipix,double& theta,double& phi) const;
|
---|
128 |
|
---|
129 | // ------------- variables internes -----------------------
|
---|
130 | int nSide_;
|
---|
131 | int nPix_;
|
---|
132 | double omeg_;
|
---|
133 |
|
---|
134 | NDataBlock<T> pixels_;
|
---|
135 |
|
---|
136 | int nlmax_;
|
---|
137 | int nmmax_;
|
---|
138 | int iseed_;
|
---|
139 | float fwhm_;
|
---|
140 | float quadrupole_;
|
---|
141 | float sym_cut_deg_;
|
---|
142 | char powFile_[128];
|
---|
143 | };
|
---|
144 |
|
---|
145 | //
|
---|
146 | // ------------- Classe pour la gestion de persistance --
|
---|
147 | //
|
---|
148 | template <class T>
|
---|
149 | class FIO_SphereGorski : public PPersist
|
---|
150 | {
|
---|
151 | public:
|
---|
152 |
|
---|
153 | FIO_SphereGorski();
|
---|
154 | FIO_SphereGorski(string const & filename);
|
---|
155 | FIO_SphereGorski(const SphereGorski<T>& obj);
|
---|
156 | FIO_SphereGorski(SphereGorski<T>* obj);
|
---|
157 | virtual ~FIO_SphereGorski();
|
---|
158 | virtual AnyDataObj* DataObj();
|
---|
159 | inline operator SphereGorski<T>() { return(*dobj); }
|
---|
160 | inline SphereGorski<T> getObj() { return(*dobj); }
|
---|
161 |
|
---|
162 | protected :
|
---|
163 |
|
---|
164 | virtual void ReadSelf(PInPersist&);
|
---|
165 | virtual void WriteSelf(POutPersist&) const;
|
---|
166 | SphereGorski<T>* dobj;
|
---|
167 | bool ownobj;
|
---|
168 | };
|
---|
169 |
|
---|
170 | //
|
---|
171 | // ------------- Classe PIXELS_XY -----------------------
|
---|
172 | //
|
---|
173 | class PIXELS_XY
|
---|
174 | {
|
---|
175 |
|
---|
176 | public :
|
---|
177 |
|
---|
178 | static PIXELS_XY& instance();
|
---|
179 |
|
---|
180 | NDataBlock<int> pix2x_;
|
---|
181 | NDataBlock<int> pix2y_;
|
---|
182 | NDataBlock<int> x2pix_;
|
---|
183 | NDataBlock<int> y2pix_;
|
---|
184 |
|
---|
185 | private :
|
---|
186 |
|
---|
187 | PIXELS_XY();
|
---|
188 | void mk_pix2xy();
|
---|
189 | void mk_xy2pix();
|
---|
190 | };
|
---|
191 | #endif
|
---|