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