1 | #ifndef SPHEREECP_SEEN
|
---|
2 | #define SPHEREECP_SEEN
|
---|
3 |
|
---|
4 | #include "sphericalmap.h"
|
---|
5 | #include "ndatablock.h"
|
---|
6 | #include "tvector.h"
|
---|
7 |
|
---|
8 |
|
---|
9 | /* Classe de carte spherique avec decoupage theta-phi
|
---|
10 | (projection cylindique: Equatorial Cylindrical Projection)
|
---|
11 | avec couverture posiibilite de couverture partielle,
|
---|
12 | limites en theta,phi
|
---|
13 | R. Ansari - Septembre 2004
|
---|
14 | */
|
---|
15 |
|
---|
16 | namespace SOPHYA {
|
---|
17 | template <class T>
|
---|
18 | class FIO_SphereECP;
|
---|
19 |
|
---|
20 | template <class T>
|
---|
21 | class SphereECP : public SphericalMap<T>
|
---|
22 | {
|
---|
23 | public :
|
---|
24 | // Constructeur par defaut
|
---|
25 | SphereECP();
|
---|
26 | // Constructeur , couverture complete, m tranches en theta (delta theta = M_PI), 2m en phi (delta phi = 2Pi)
|
---|
27 | SphereECP(int m);
|
---|
28 | // Constructeur , couverture complete, ntet tranches en theta (delta theta = M_PI), nphi en phi (delta phi = 2Pi)
|
---|
29 | SphereECP(int ntet, int nphi);
|
---|
30 | // Constructeur , couverture partielle, ntet tranches en theta , nphi en phi
|
---|
31 | SphereECP(r_8 tet1, r_8 tet2, int ntet, r_8 phi1, r_8 phi2, int nphi);
|
---|
32 | // Constructeur de copie, share=true -> partage des pixels
|
---|
33 | SphereECP(const SphereECP<T>& a, bool share);
|
---|
34 | // Constructeur de copie, partage des pixels
|
---|
35 | SphereECP(const SphereECP<T>& a);
|
---|
36 | virtual ~SphereECP();
|
---|
37 |
|
---|
38 | // Renvoie TETAPHI comme les SphereThetaPhi pour le moment
|
---|
39 | virtual string TypeOfMap() const;
|
---|
40 | virtual void SetTemp(bool temp=false) const; // A supprimer
|
---|
41 |
|
---|
42 | // Informations sur carte partielle/complete + zone de couverture
|
---|
43 | inline bool IsPartial() const { return _partial; }
|
---|
44 | inline double MinTheta() const { return _theta1; }
|
---|
45 | inline double MaxTheta() const { return _theta2; }
|
---|
46 | inline double DeltaTheta() const { return _dtheta; }
|
---|
47 | inline double MinPhi() const { return _phi1; }
|
---|
48 | inline double MaxPhi() const { return _phi2; }
|
---|
49 | inline double DeltaPhi() const { return _dphi; }
|
---|
50 |
|
---|
51 | // Interface de Pixelmap
|
---|
52 | /*! Return total number of pixels */
|
---|
53 | virtual int_4 NbPixels() const;
|
---|
54 |
|
---|
55 | /* retourne la valeur du pixel d'indice k */
|
---|
56 | /*! Return value of pixel with index k */
|
---|
57 | virtual T& PixVal(int_4 k);
|
---|
58 | virtual T const& PixVal(int_4 k) const;
|
---|
59 |
|
---|
60 | /* Return true if teta,phi in map */
|
---|
61 | virtual bool ContainsSph(double theta, double phi) const;
|
---|
62 | /* retourne l'indice du pixel a (theta,phi) */
|
---|
63 | /* Return index of the pixel corresponding to direction (theta, phi). */
|
---|
64 | virtual int_4 PixIndexSph(double theta, double phi) const;
|
---|
65 |
|
---|
66 | /* retourne les coordonnees Spheriques du centre du pixel d'indice k */
|
---|
67 | /*! Return (theta,phi) coordinates of middle of pixel with index k */
|
---|
68 | virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
|
---|
69 |
|
---|
70 | /*! Setting pixel values to a constant */
|
---|
71 | virtual T SetPixels(T v);
|
---|
72 |
|
---|
73 | /* retourne/fixe l'angle Solide de Pixel (steradians) */
|
---|
74 | /*! Pixel Solid angle (steradians)
|
---|
75 |
|
---|
76 | All the pixels have the same solid angle. The dummy argument is
|
---|
77 | for compatibility with eventual pixelizations which would not
|
---|
78 | fulfil this requirement.
|
---|
79 | */
|
---|
80 | virtual double PixSolAngle(int_4 dummy=0) const;
|
---|
81 |
|
---|
82 | /* retourne/fixe l'angle Solide couvert par la carte (steradians) */
|
---|
83 | virtual double TotSolAngle(void) const
|
---|
84 | {return fabs((_phi2-_phi1)*(cos(_theta2)-cos(_theta1)));}
|
---|
85 |
|
---|
86 | /* retourne/fixe la valeur du parametre de decoupage m */
|
---|
87 | virtual int_4 SizeIndex() const ;
|
---|
88 |
|
---|
89 | // Interface de SphericalMap
|
---|
90 | // index characterizing the size pixelization : m for SphereThetaPhi
|
---|
91 | // nside for Gorski sphere...
|
---|
92 | virtual void Resize(int_4 m);
|
---|
93 | virtual uint_4 NbThetaSlices() const;
|
---|
94 |
|
---|
95 | // Nb de tranches en Phi
|
---|
96 | inline uint_4 NbPhiSlices() const { return _pixels.SizeX(); }
|
---|
97 |
|
---|
98 | virtual void GetThetaSlice(int_4 index,r_8& theta,
|
---|
99 | TVector<r_8>& phi, TVector<T>& value) const ;
|
---|
100 | virtual void GetThetaSlice(int_4 sliceIndex, r_8& theta, r_8& phi0,
|
---|
101 | TVector<int_4>& pixelIndices,TVector<T>& value) const ;
|
---|
102 |
|
---|
103 | // Valeur de pixel hors carte
|
---|
104 | inline void SetOutOfMapValue(T v) { _outofmappix = _outofmapval = v; }
|
---|
105 | inline T GetOutOfMapValue(T v) { return _outofmapval; }
|
---|
106 |
|
---|
107 | // Impression
|
---|
108 | virtual void Print(ostream& os) const;
|
---|
109 | inline void print(ostream& os) const { Print(os); }
|
---|
110 |
|
---|
111 | // ---- les operations =, +, - , *
|
---|
112 | // operation = (remplissage avec une valeur ou carte)
|
---|
113 | virtual SphereECP<T>& Set(const SphereECP<T>& a);
|
---|
114 | inline SphereECP<T>& operator = (const SphereECP<T>& a) { return Set(a); }
|
---|
115 | virtual SphereECP<T>& SetCst(T x);
|
---|
116 | inline SphereECP<T>& operator = (T x) { return SetCst(x); }
|
---|
117 | // Operation + , * avec des Constantes
|
---|
118 | virtual SphereECP<T>& AddCst(T x) ;
|
---|
119 | virtual SphereECP<T>& MulCst(T x) ;
|
---|
120 |
|
---|
121 | inline SphereECP<T>& operator += (T x) { return AddCst(x); }
|
---|
122 | inline SphereECP<T>& operator -= (T x) { return AddCst(-x); }
|
---|
123 | inline SphereECP<T>& operator *= (T x) { return MulCst(x); }
|
---|
124 |
|
---|
125 | // Acces au tableau des pixels
|
---|
126 | inline TArray<T>& GetPixelArray() { return _pixels; }
|
---|
127 | inline TArray<T> GetPixelArray() const { return _pixels; }
|
---|
128 |
|
---|
129 | friend class FIO_SphereECP<T>; // Gestion de persistance PPF
|
---|
130 |
|
---|
131 | protected:
|
---|
132 | bool _partial;
|
---|
133 | r_8 _theta1,_theta2;
|
---|
134 | r_8 _phi1, _phi2;
|
---|
135 | r_8 _dtheta, _dphi;
|
---|
136 | TArray<T> _pixels;
|
---|
137 | int_4 _outofmapidx;
|
---|
138 | int_4 _outofmapnphi;
|
---|
139 | int_4 _outofmapntet;
|
---|
140 | T _outofmappix;
|
---|
141 | T _outofmapval;
|
---|
142 | };
|
---|
143 |
|
---|
144 | template <class T>
|
---|
145 | inline ostream& operator << (ostream& os, const SphereECP<T>& a)
|
---|
146 | { a.Print(os); return(os); }
|
---|
147 |
|
---|
148 | }// Fin du namespace
|
---|
149 |
|
---|
150 | #endif
|
---|