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 |
|
---|
12 | // ***************** CLASSE SphereGorski *****************************
|
---|
13 |
|
---|
14 | template<class T>
|
---|
15 | class SphereGorski : public SphericalMap<T>, public AnyDataObj
|
---|
16 | {
|
---|
17 |
|
---|
18 | public :
|
---|
19 |
|
---|
20 | SphereGorski();
|
---|
21 | SphereGorski(int m);
|
---|
22 | SphereGorski(const SphereGorski<T>& s);
|
---|
23 | virtual ~SphereGorski();
|
---|
24 |
|
---|
25 | // ------------------ Definition of PixelMap abstract methods
|
---|
26 |
|
---|
27 | /* Nombre de pixels du decoupage */
|
---|
28 | virtual int NbPixels() const;
|
---|
29 | inline void setNbPixels(int n) {nPix_= n;}
|
---|
30 |
|
---|
31 | /* Valeur du contenu du pixel d'indice "RING" k */
|
---|
32 | virtual T& PixVal(int k);
|
---|
33 | virtual T const& PixVal(int k) const;
|
---|
34 |
|
---|
35 | /* Nombre de tranches en theta */
|
---|
36 | int NbThetaSlices() const;
|
---|
37 | void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
38 |
|
---|
39 | /* Indice "RING" du pixel vers lequel pointe une direction definie par
|
---|
40 | ses coordonnees spheriques */
|
---|
41 | virtual int PixIndexSph(double theta,double phi) const;
|
---|
42 |
|
---|
43 | /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
|
---|
44 | virtual void PixThetaPhi(int k,double& theta,double& phi) const;
|
---|
45 |
|
---|
46 | /* Pixel Solid angle (steradians) */
|
---|
47 | virtual double PixSolAngle(int dummy) const;
|
---|
48 | inline void setPixSolAngle(double x) {omeg_= x;}
|
---|
49 |
|
---|
50 | // --------------- Specific methods
|
---|
51 |
|
---|
52 | virtual void Resize(int m);
|
---|
53 |
|
---|
54 | inline virtual char* TypeOfMap() const {return "RING";};
|
---|
55 |
|
---|
56 | /* Valeur du contenu du pixel d'indice "NEST" k */
|
---|
57 | virtual T& PixValNest(int k);
|
---|
58 | virtual T const& PixValNest(int k) const;
|
---|
59 |
|
---|
60 | /* Indice "NEST" du pixel vers lequel pointe une direction definie par
|
---|
61 | ses coordonnees spheriques */
|
---|
62 | virtual int PixIndexSphNest(double theta,double phi) const;
|
---|
63 |
|
---|
64 | /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
|
---|
65 | virtual void PixThetaPhiNest(int k,double& theta,double& phi) const;
|
---|
66 |
|
---|
67 | /* algorithme de pixelisation */
|
---|
68 | void Pixelize(int);
|
---|
69 |
|
---|
70 | /* convertit index nested en ring */
|
---|
71 | int NestToRing(int) const;
|
---|
72 |
|
---|
73 | /* convertit index ring en nested" */
|
---|
74 | int RingToNest(int) const;
|
---|
75 |
|
---|
76 |
|
---|
77 | /* retourne/fixe la valeur du parametre Gorski */
|
---|
78 | inline virtual int SizeIndex() const {return(nSide_);}
|
---|
79 | inline void setSizeIndex(int n) {nSide_= n;}
|
---|
80 |
|
---|
81 | /* retourne les pointeurs /remplit les tableaux */
|
---|
82 | inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
|
---|
83 | inline void setDataBlock(T* data,int m) { pixels_.FillFrom(m,data); }
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 | /* impression */
|
---|
88 | void print(ostream& os) const;
|
---|
89 |
|
---|
90 | private :
|
---|
91 |
|
---|
92 | // ------------- méthodes internes ----------------------
|
---|
93 | void InitNul();
|
---|
94 |
|
---|
95 | int nest2ring(int nside,int ipnest) const;
|
---|
96 | int ring2nest(int nside,int ipring) const;
|
---|
97 |
|
---|
98 | int ang2pix_ring(int nside,double theta,double phi) const;
|
---|
99 | int ang2pix_nest(int nside,double theta,double phi) const;
|
---|
100 | void pix2ang_ring(int nside,int ipix,double& theta,double& phi) const;
|
---|
101 | void pix2ang_nest(int nside,int ipix,double& theta,double& phi) const;
|
---|
102 |
|
---|
103 | // ------------- variables internes -----------------------
|
---|
104 | int nSide_;
|
---|
105 | int nPix_;
|
---|
106 | double omeg_;
|
---|
107 |
|
---|
108 | NDataBlock<T> pixels_;
|
---|
109 |
|
---|
110 | };
|
---|
111 |
|
---|
112 | //
|
---|
113 | // ------------- Classe pour la gestion de persistance --
|
---|
114 | //
|
---|
115 | template <class T>
|
---|
116 | class FIO_SphereGorski : public PPersist
|
---|
117 | {
|
---|
118 | public:
|
---|
119 |
|
---|
120 | FIO_SphereGorski();
|
---|
121 | FIO_SphereGorski(string const & filename);
|
---|
122 | FIO_SphereGorski(const SphereGorski<T>& obj);
|
---|
123 | FIO_SphereGorski(SphereGorski<T>* obj);
|
---|
124 | virtual ~FIO_SphereGorski();
|
---|
125 | virtual AnyDataObj* DataObj();
|
---|
126 | inline operator SphereGorski<T>() { return(*dobj); }
|
---|
127 | inline SphereGorski<T> getObj() { return(*dobj); }
|
---|
128 |
|
---|
129 | protected :
|
---|
130 |
|
---|
131 | virtual void ReadSelf(PInPersist&);
|
---|
132 | virtual void WriteSelf(POutPersist&) const;
|
---|
133 | SphereGorski<T>* dobj;
|
---|
134 | bool ownobj;
|
---|
135 | };
|
---|
136 |
|
---|
137 | //
|
---|
138 | // ------------- Classe PIXELS_XY -----------------------
|
---|
139 | //
|
---|
140 | class PIXELS_XY
|
---|
141 | {
|
---|
142 |
|
---|
143 | public :
|
---|
144 |
|
---|
145 | static PIXELS_XY& instance();
|
---|
146 |
|
---|
147 | NDataBlock<int> pix2x_;
|
---|
148 | NDataBlock<int> pix2y_;
|
---|
149 | NDataBlock<int> x2pix_;
|
---|
150 | NDataBlock<int> y2pix_;
|
---|
151 |
|
---|
152 | private :
|
---|
153 |
|
---|
154 | PIXELS_XY();
|
---|
155 | void mk_pix2xy();
|
---|
156 | void mk_xy2pix();
|
---|
157 | };
|
---|
158 | #endif
|
---|