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