[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 |
|
---|
[470] | 11 | // ***************** Class SphereThetaPhi *****************************
|
---|
[565] | 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.
|
---|
[228] | 17 |
|
---|
[565] | 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 | */
|
---|
[470] | 22 | template <class T>
|
---|
[592] | 23 | class SphereThetaPhi : public SphericalMap<T>
|
---|
[470] | 24 | {
|
---|
| 25 |
|
---|
[228] | 26 | public :
|
---|
| 27 |
|
---|
| 28 | SphereThetaPhi();
|
---|
[565] | 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 | */
|
---|
[682] | 33 | SphereThetaPhi(int_4 m);
|
---|
[574] | 34 | SphereThetaPhi(const SphereThetaPhi<T>& s, bool share=false);
|
---|
[228] | 35 | virtual ~SphereThetaPhi();
|
---|
| 36 |
|
---|
[470] | 37 | // ------------ Definition of PixelMap abstract methods -
|
---|
[228] | 38 |
|
---|
[470] | 39 | /* retourne/fixe le nombre de pixels */
|
---|
[565] | 40 | /*! Return total number of pixels */
|
---|
[682] | 41 | virtual int_4 NbPixels() const;
|
---|
| 42 | inline void setNbPixels(int_4 nbpix) { NPix_= nbpix; }
|
---|
[228] | 43 |
|
---|
[470] | 44 | /* retourne la valeur du pixel d'indice k */
|
---|
[565] | 45 | /*! Return value of pixel with index k */
|
---|
[682] | 46 | virtual T& PixVal(int_4 k);
|
---|
| 47 | virtual T const& PixVal(int_4 k) const;
|
---|
[228] | 48 |
|
---|
[518] | 49 | /* Return true if teta,phi in map */
|
---|
| 50 | virtual bool ContainsSph(double theta, double phi) const;
|
---|
[470] | 51 | /* retourne l'indice du pixel a (theta,phi) */
|
---|
[565] | 52 | /* Return index of the pixel corresponding to direction (theta, phi). */
|
---|
[682] | 53 | virtual int_4 PixIndexSph(double theta, double phi) const;
|
---|
[228] | 54 |
|
---|
[470] | 55 | /* retourne les coordonnees Spheriques du centre du pixel d'indice k */
|
---|
[565] | 56 | /*! Return (theta,phi) coordinates of middle of pixel with index k */
|
---|
[682] | 57 | virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
|
---|
[228] | 58 |
|
---|
[574] | 59 | /*! Setting pixel values to a constant */
|
---|
| 60 | virtual T SetPixels(T v);
|
---|
| 61 |
|
---|
[470] | 62 | /* retourne/fixe l'angle Solide de Pixel (steradians) */
|
---|
[565] | 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 | */
|
---|
[682] | 69 | virtual double PixSolAngle(int_4 dummy) const;
|
---|
[473] | 70 | inline void setPixSolAngle(double omega) { Omega_= omega; }
|
---|
[470] | 71 |
|
---|
| 72 | /* retourne/fixe la valeur du parametre de decoupage m */
|
---|
[682] | 73 | inline virtual int_4 SizeIndex() const { return( NTheta_); }
|
---|
| 74 | inline void setSizeIndex(int_4 nbindex) { NTheta_= nbindex; }
|
---|
[228] | 75 |
|
---|
[470] | 76 | // ------------- Specific methods ----------------------
|
---|
[228] | 77 |
|
---|
[565] | 78 | /*! re-pixelize the sphere */
|
---|
[682] | 79 | virtual void Resize(int_4 m);
|
---|
[228] | 80 |
|
---|
[470] | 81 | inline virtual char* TypeOfMap() const {return "TETAFI";};
|
---|
[228] | 82 |
|
---|
[473] | 83 | /* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
|
---|
[565] | 84 | /* Return values of theta,phi which limit the pixel with index k */
|
---|
[682] | 85 | virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2);
|
---|
[228] | 86 |
|
---|
[470] | 87 | /* Nombre de tranches en theta */
|
---|
[565] | 88 | /*! Return number of theta-slices on the sphere */
|
---|
[682] | 89 | int_4 NbThetaSlices() const;
|
---|
[228] | 90 |
|
---|
[470] | 91 | /* Nombre de pixels en phi de la tranche d'indice kt */
|
---|
[682] | 92 | int_4 NPhi(int_4 kt) const;
|
---|
[228] | 93 |
|
---|
| 94 | /* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
|
---|
[470] | 95 | /* de la tranche d'indice kt */
|
---|
[565] | 96 | /*! Return theta values which limit the slice kt */
|
---|
[682] | 97 | void Theta(int_4 kt, double& t1, double& t2);
|
---|
[228] | 98 |
|
---|
| 99 | /* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
|
---|
[470] | 100 | /* dans la tranche d'indice kt */
|
---|
[565] | 101 | /*! Return values of phi which limit the jp-th pixel of the kt-th slice */
|
---|
[682] | 102 | void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
|
---|
[228] | 103 |
|
---|
| 104 | /* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
|
---|
[565] | 105 | /*! Return pixel index with sequence index jp in the slice kt */
|
---|
[682] | 106 | int_4 Index(int_4 kt, int_4 jp) const;
|
---|
[228] | 107 |
|
---|
[470] | 108 | /* Indice kt de la tranche et indice jp du pixel d'indice k */
|
---|
[565] | 109 | /*! Return indices kt (theta) and jp (phi) of pixel with index k */
|
---|
[682] | 110 | void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
|
---|
[228] | 111 |
|
---|
[565] | 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 | */
|
---|
[682] | 123 | void Pixelize(int_4);
|
---|
[228] | 124 |
|
---|
[565] | 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 | */
|
---|
[682] | 133 | void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
[228] | 134 |
|
---|
[470] | 135 | /*retourne le tableau contenant le nombre de pixels en phi de chacune des bandes en theta */
|
---|
[682] | 136 | inline const int_4* getmNPhi() const { return(NPhi_); }
|
---|
| 137 | void setmNPhi(int_4* array, int_4 m);
|
---|
[228] | 138 |
|
---|
[470] | 139 | /* retourne/remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */
|
---|
[682] | 140 | inline const int_4* getmTNphi() const { return(TNphi_); }
|
---|
| 141 | void setmTNphi(int_4* array, int_4 m);
|
---|
[228] | 142 |
|
---|
[470] | 143 | /* retourne/remplit le tableau contenant les valeurs limites de theta */
|
---|
[473] | 144 | inline const double* getmTheta() const { return(Theta_); }
|
---|
[682] | 145 | void setmTheta(double* array, int_4 m);
|
---|
[228] | 146 |
|
---|
[470] | 147 | /* retourne le pointeur vers/remplit le vecteur des contenus des pixels */
|
---|
| 148 | inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
|
---|
[682] | 149 | void setDataBlock(T* data, int_4 m);
|
---|
[228] | 150 |
|
---|
[604] | 151 | /* Acces to the DataBlock */
|
---|
| 152 | inline NDataBlock<T>& DataBlock() {return pixels_;}
|
---|
| 153 | inline const NDataBlock<T>& DataBlock() const {return pixels_;}
|
---|
| 154 |
|
---|
[470] | 155 | /* impression */
|
---|
| 156 | void print(ostream& os) const;
|
---|
[228] | 157 |
|
---|
[470] | 158 | private :
|
---|
| 159 |
|
---|
| 160 | // ------------- méthodes internes ----------------------
|
---|
| 161 | void InitNul();
|
---|
| 162 | void Clear();
|
---|
| 163 |
|
---|
| 164 | // ------------- variables internes ---------------------
|
---|
[682] | 165 | int_4 NTheta_;
|
---|
| 166 | int_4 NPix_;
|
---|
[473] | 167 | double Omega_;
|
---|
[682] | 168 | int_4* NPhi_;
|
---|
| 169 | int_4* TNphi_;
|
---|
[473] | 170 | double* Theta_;
|
---|
[470] | 171 | NDataBlock<T> pixels_;
|
---|
[228] | 172 | };
|
---|
| 173 |
|
---|
[470] | 174 | // ------------- Classe pour la gestion de persistance --
|
---|
| 175 | template <class T>
|
---|
| 176 | class FIO_SphereThetaPhi : public PPersist
|
---|
| 177 | {
|
---|
| 178 | public:
|
---|
[228] | 179 |
|
---|
[470] | 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); }
|
---|
[565] | 187 | //inline SphereThetaPhi<T> getObj() { return(*dobj); }
|
---|
[228] | 188 |
|
---|
[470] | 189 | protected :
|
---|
| 190 |
|
---|
| 191 | virtual void ReadSelf(PInPersist&);
|
---|
| 192 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 193 | SphereThetaPhi<T>* dobj;
|
---|
| 194 | bool ownobj;
|
---|
| 195 | };
|
---|
| 196 |
|
---|
[228] | 197 | #endif
|
---|