[228] | 1 | #ifndef SPHERETHETAPHI_SEEN
|
---|
| 2 | #define SPHERETHETAPHI_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "sphericalmap.h"
|
---|
[470] | 5 | #include "ndatablock.h"
|
---|
| 6 | #include "tvector.h"
|
---|
[228] | 7 |
|
---|
[470] | 8 | #include "anydataobj.h"
|
---|
| 9 | #include "ppersist.h"
|
---|
[228] | 10 |
|
---|
[701] | 11 | template <class T>
|
---|
| 12 | class FIO_SphereThetaPhi;
|
---|
| 13 |
|
---|
| 14 |
|
---|
[470] | 15 | // ***************** Class SphereThetaPhi *****************************
|
---|
[565] | 16 | /*! sphere splitted with respect to theta, phi : each hemisphere is
|
---|
| 17 | splitted into (m-1) parallels (equator does not enter into account).
|
---|
| 18 | This operation defines m slices, each of which is splitted into
|
---|
| 19 | equidistant meridians. This splitting is realized in such a way that
|
---|
| 20 | all pixels have the same area and are as square as possible.
|
---|
[228] | 21 |
|
---|
[565] | 22 | One begins with the hemisphere with positive z, starting from the pole
|
---|
| 23 | toward the equator. The first pixel is the polar cap ; it is circular
|
---|
| 24 | and centered on theta=0.
|
---|
| 25 | */
|
---|
[470] | 26 | template <class T>
|
---|
[592] | 27 | class SphereThetaPhi : public SphericalMap<T>
|
---|
[470] | 28 | {
|
---|
| 29 |
|
---|
[701] | 30 | friend class FIO_SphereThetaPhi<T>;
|
---|
| 31 |
|
---|
[228] | 32 | public :
|
---|
| 33 |
|
---|
| 34 | SphereThetaPhi();
|
---|
[565] | 35 | /*! m is the number of slices in theta on an hemisphere (the polar cap
|
---|
| 36 | forms the first slice).
|
---|
| 37 | pet is a dummy parameter at the moment.
|
---|
| 38 | */
|
---|
[682] | 39 | SphereThetaPhi(int_4 m);
|
---|
[574] | 40 | SphereThetaPhi(const SphereThetaPhi<T>& s, bool share=false);
|
---|
[228] | 41 | virtual ~SphereThetaPhi();
|
---|
| 42 |
|
---|
[470] | 43 | // ------------ Definition of PixelMap abstract methods -
|
---|
[228] | 44 |
|
---|
[701] | 45 | /* retourne le nombre de pixels */
|
---|
[565] | 46 | /*! Return total number of pixels */
|
---|
[682] | 47 | virtual int_4 NbPixels() const;
|
---|
[228] | 48 |
|
---|
[470] | 49 | /* retourne la valeur du pixel d'indice k */
|
---|
[565] | 50 | /*! Return value of pixel with index k */
|
---|
[682] | 51 | virtual T& PixVal(int_4 k);
|
---|
| 52 | virtual T const& PixVal(int_4 k) const;
|
---|
[228] | 53 |
|
---|
[518] | 54 | /* Return true if teta,phi in map */
|
---|
| 55 | virtual bool ContainsSph(double theta, double phi) const;
|
---|
[470] | 56 | /* retourne l'indice du pixel a (theta,phi) */
|
---|
[565] | 57 | /* Return index of the pixel corresponding to direction (theta, phi). */
|
---|
[682] | 58 | virtual int_4 PixIndexSph(double theta, double phi) const;
|
---|
[228] | 59 |
|
---|
[470] | 60 | /* retourne les coordonnees Spheriques du centre du pixel d'indice k */
|
---|
[565] | 61 | /*! Return (theta,phi) coordinates of middle of pixel with index k */
|
---|
[682] | 62 | virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
|
---|
[228] | 63 |
|
---|
[574] | 64 | /*! Setting pixel values to a constant */
|
---|
| 65 | virtual T SetPixels(T v);
|
---|
| 66 |
|
---|
[470] | 67 | /* retourne/fixe l'angle Solide de Pixel (steradians) */
|
---|
[565] | 68 | /*! Pixel Solid angle (steradians)
|
---|
| 69 |
|
---|
| 70 | All the pixels have the same solid angle. The dummy argument is
|
---|
| 71 | for compatibility with eventual pixelizations which would not
|
---|
| 72 | fulfil this requirement.
|
---|
| 73 | */
|
---|
[701] | 74 | virtual double PixSolAngle(int_4 dummy=0) const;
|
---|
[470] | 75 |
|
---|
| 76 | /* retourne/fixe la valeur du parametre de decoupage m */
|
---|
[682] | 77 | inline virtual int_4 SizeIndex() const { return( NTheta_); }
|
---|
[228] | 78 |
|
---|
[470] | 79 | // ------------- Specific methods ----------------------
|
---|
[228] | 80 |
|
---|
[565] | 81 | /*! re-pixelize the sphere */
|
---|
[682] | 82 | virtual void Resize(int_4 m);
|
---|
[228] | 83 |
|
---|
[470] | 84 | inline virtual char* TypeOfMap() const {return "TETAFI";};
|
---|
[228] | 85 |
|
---|
[473] | 86 | /* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
|
---|
[565] | 87 | /* Return values of theta,phi which limit the pixel with index k */
|
---|
[682] | 88 | virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2);
|
---|
[228] | 89 |
|
---|
[470] | 90 | /* Nombre de tranches en theta */
|
---|
[565] | 91 | /*! Return number of theta-slices on the sphere */
|
---|
[682] | 92 | int_4 NbThetaSlices() const;
|
---|
[228] | 93 |
|
---|
[470] | 94 | /* Nombre de pixels en phi de la tranche d'indice kt */
|
---|
[682] | 95 | int_4 NPhi(int_4 kt) const;
|
---|
[228] | 96 |
|
---|
| 97 | /* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
|
---|
[470] | 98 | /* de la tranche d'indice kt */
|
---|
[565] | 99 | /*! Return theta values which limit the slice kt */
|
---|
[682] | 100 | void Theta(int_4 kt, double& t1, double& t2);
|
---|
[228] | 101 |
|
---|
| 102 | /* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
|
---|
[470] | 103 | /* dans la tranche d'indice kt */
|
---|
[565] | 104 | /*! Return values of phi which limit the jp-th pixel of the kt-th slice */
|
---|
[682] | 105 | void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
|
---|
[228] | 106 |
|
---|
| 107 | /* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
|
---|
[565] | 108 | /*! Return pixel index with sequence index jp in the slice kt */
|
---|
[682] | 109 | int_4 Index(int_4 kt, int_4 jp) const;
|
---|
[228] | 110 |
|
---|
[470] | 111 | /* Indice kt de la tranche et indice jp du pixel d'indice k */
|
---|
[565] | 112 | /*! Return indices kt (theta) and jp (phi) of pixel with index k */
|
---|
[682] | 113 | void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
|
---|
[228] | 114 |
|
---|
[565] | 115 | /*! achieve the splitting into pixels (m has the same signification
|
---|
| 116 | as for the constructor)
|
---|
| 117 |
|
---|
| 118 | Each theta-slice of the north hemisphere will be spitted starting f
|
---|
| 119 | from phi=0 ...
|
---|
| 120 |
|
---|
| 121 | South hemisphere is scanned in the same direction according to phi
|
---|
| 122 | and from equator to the pole (the pixel following the last one of
|
---|
| 123 | the slice closest to the equator with z>0, is the pixel with lowest
|
---|
| 124 | phi of the slice closest of the equator with z<0).
|
---|
| 125 | */
|
---|
[682] | 126 | void Pixelize(int_4);
|
---|
[228] | 127 |
|
---|
[565] | 128 | /*! For a theta-slice with index 'index', return :
|
---|
| 129 |
|
---|
| 130 | the corresponding "theta"
|
---|
| 131 |
|
---|
| 132 | a vector containing the phi's of the pixels of the slice
|
---|
| 133 |
|
---|
| 134 | a vector containing the corresponding values of pixels
|
---|
| 135 | */
|
---|
[682] | 136 | void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
[228] | 137 |
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 |
|
---|
[470] | 141 | /* impression */
|
---|
| 142 | void print(ostream& os) const;
|
---|
[228] | 143 |
|
---|
[470] | 144 | private :
|
---|
| 145 |
|
---|
| 146 | // ------------- méthodes internes ----------------------
|
---|
| 147 | void InitNul();
|
---|
| 148 | void Clear();
|
---|
[701] | 149 | inline void setParameters(int nbpix, double omega, int nbThetaIndex)
|
---|
| 150 | {
|
---|
| 151 | NPix_= nbpix;
|
---|
| 152 | Omega_= omega;
|
---|
| 153 | NTheta_= nbThetaIndex;
|
---|
| 154 | }
|
---|
| 155 | void setmNPhi(int* array, int m);
|
---|
| 156 | void setmTNphi(int* array, int m);
|
---|
| 157 | void setmTheta(double* array, int m);
|
---|
| 158 | /*retourne l'adresse du tableau contenant le nombre de pixels en phi de chacune des bandes en theta */
|
---|
| 159 | inline const int* getmNPhi() const { return(NPhi_); }
|
---|
[470] | 160 |
|
---|
[701] | 161 | /* retourne le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */
|
---|
| 162 | inline const int* getmTNphi() const { return(TNphi_); }
|
---|
| 163 |
|
---|
| 164 | /* retourne le tableau contenant les valeurs limites de theta */
|
---|
| 165 | inline const double* getmTheta() const { return(Theta_); }
|
---|
| 166 |
|
---|
| 167 | /* Acces to the DataBlock */
|
---|
| 168 | //inline NDataBlock<T>& DataBlock() {return pixels_;}
|
---|
| 169 | //inline const NDataBlock<T>& DataBlock() const {return pixels_;}
|
---|
| 170 |
|
---|
[470] | 171 | // ------------- variables internes ---------------------
|
---|
[701] | 172 | int_4 NTheta_; // nombre de tranches en theta, pour une demi-sphere
|
---|
| 173 | int_4 NPix_; // nombre total de pixels
|
---|
| 174 | double Omega_; // angle solide constant pour chaque pixel
|
---|
| 175 | int_4* NPhi_; // tableau donnant, pour chaque bande en theta, le nombre de
|
---|
| 176 | // pixels selon phi
|
---|
[682] | 177 | int_4* TNphi_;
|
---|
[473] | 178 | double* Theta_;
|
---|
[470] | 179 | NDataBlock<T> pixels_;
|
---|
[228] | 180 | };
|
---|
| 181 |
|
---|
[470] | 182 | // ------------- Classe pour la gestion de persistance --
|
---|
| 183 | template <class T>
|
---|
| 184 | class FIO_SphereThetaPhi : public PPersist
|
---|
| 185 | {
|
---|
| 186 | public:
|
---|
[228] | 187 |
|
---|
[470] | 188 | FIO_SphereThetaPhi();
|
---|
| 189 | FIO_SphereThetaPhi(string const & filename);
|
---|
| 190 | FIO_SphereThetaPhi(const SphereThetaPhi<T>& obj);
|
---|
| 191 | FIO_SphereThetaPhi(SphereThetaPhi<T>* obj);
|
---|
| 192 | virtual ~FIO_SphereThetaPhi();
|
---|
| 193 | virtual AnyDataObj* DataObj();
|
---|
| 194 | inline operator SphereThetaPhi<T>() { return(*dobj); }
|
---|
[228] | 195 |
|
---|
[470] | 196 | protected :
|
---|
| 197 |
|
---|
| 198 | virtual void ReadSelf(PInPersist&);
|
---|
| 199 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 200 | SphereThetaPhi<T>* dobj;
|
---|
| 201 | bool ownobj;
|
---|
| 202 | };
|
---|
| 203 |
|
---|
[228] | 204 | #endif
|
---|