[228] | 1 | #ifndef SPHEREGORSKI_SEEN
|
---|
| 2 | #define SPHEREGORSKI_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "sphericalmap.h"
|
---|
[470] | 5 | #include "tvector.h"
|
---|
| 6 | #include "ndatablock.h"
|
---|
[228] | 7 |
|
---|
[470] | 8 | #include "anydataobj.h"
|
---|
| 9 | #include "ppersist.h"
|
---|
| 10 |
|
---|
[228] | 11 | // les attributs de classe pix2x_ et pix2y_ sont relatifs a la traduction des
|
---|
[470] | 12 | // indices RING en indices NESTED (ou l inverse). Ce sont des tableaux
|
---|
[228] | 13 | // d'entiers initialises et remplis par le constructeur. Dans la version
|
---|
| 14 | // FORTRAN de healpix, il s'agissait de tableaux mis en COMMON. Ils etaient
|
---|
[470] | 15 | // initialises au premier appel d'une conversion d indice. Je ne peux pas
|
---|
[228] | 16 | // garder cette procedure car, par exemple, la fonction PixValNest() const
|
---|
| 17 | // n'autorisera pas la constitution de ces tableaux (a cause du const). Ainsi,
|
---|
[470] | 18 | // des la creation d un objet SphereGorski ces tableaux sont calcules, ce qui
|
---|
[228] | 19 | // est, certes, inutile si on ne se sert pas des indices NESTED. Ca ne me
|
---|
[470] | 20 | // rejouit pas, mais c est le seul moyen que j ai trouve pour temir compte de
|
---|
[228] | 21 | // toutes les demandes et des options prises.
|
---|
| 22 | //
|
---|
| 23 | // G. Le Meur
|
---|
| 24 |
|
---|
[470] | 25 | // ***************** CLASSE SphereGorski *****************************
|
---|
| 26 |
|
---|
| 27 | template<class T>
|
---|
| 28 | class SphereGorski : public SphericalMap<T>, public AnyDataObj
|
---|
| 29 | {
|
---|
| 30 |
|
---|
[228] | 31 | public :
|
---|
| 32 |
|
---|
| 33 | SphereGorski();
|
---|
[473] | 34 | SphereGorski(int m);
|
---|
[470] | 35 | SphereGorski(const SphereGorski<T>& s);
|
---|
[228] | 36 | virtual ~SphereGorski();
|
---|
| 37 |
|
---|
| 38 | // ------------------ Definition of PixelMap abstract methods
|
---|
| 39 |
|
---|
[470] | 40 | /* Nombre de pixels du decoupage */
|
---|
[473] | 41 | virtual int NbPixels() const;
|
---|
| 42 | inline void setNbPixels(int n) {nPix_= n;}
|
---|
[228] | 43 |
|
---|
[470] | 44 | /* Valeur du contenu du pixel d'indice "RING" k */
|
---|
[473] | 45 | virtual T& PixVal(int k);
|
---|
| 46 | virtual T const& PixVal(int k) const;
|
---|
[228] | 47 |
|
---|
[470] | 48 | /* Nombre de tranches en theta */
|
---|
[473] | 49 | int NbThetaSlices() const;
|
---|
| 50 | void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const;
|
---|
[228] | 51 |
|
---|
| 52 | /* Indice "RING" du pixel vers lequel pointe une direction definie par
|
---|
| 53 | ses coordonnees spheriques */
|
---|
[473] | 54 | virtual int PixIndexSph(double theta,double phi) const;
|
---|
[228] | 55 |
|
---|
[470] | 56 | /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */
|
---|
[473] | 57 | virtual void PixThetaPhi(int k,double& theta,double& phi) const;
|
---|
[228] | 58 |
|
---|
[470] | 59 | /* Pixel Solid angle (steradians) */
|
---|
[473] | 60 | virtual double PixSolAngle(int dummy) const;
|
---|
| 61 | inline void setPixSolAngle(double x) {omeg_= x;}
|
---|
[228] | 62 |
|
---|
| 63 | // --------------- Specific methods
|
---|
| 64 |
|
---|
[473] | 65 | virtual void Resize(int m);
|
---|
[470] | 66 |
|
---|
| 67 | inline virtual char* TypeOfMap() const {return "RING";};
|
---|
| 68 |
|
---|
[473] | 69 | /* Valeur du contenu du pixel d'indice "NEST" k */
|
---|
| 70 | virtual T& PixValNest(int k);
|
---|
| 71 | virtual T const& PixValNest(int k) const;
|
---|
[228] | 72 |
|
---|
| 73 | /* Indice "NEST" du pixel vers lequel pointe une direction definie par
|
---|
| 74 | ses coordonnees spheriques */
|
---|
[473] | 75 | virtual int PixIndexSphNest(double theta,double phi) const;
|
---|
[228] | 76 |
|
---|
| 77 | /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */
|
---|
[473] | 78 | virtual void PixThetaPhiNest(int k,double& theta,double& phi) const;
|
---|
[228] | 79 |
|
---|
[470] | 80 | /* algorithme de pixelisation */
|
---|
[473] | 81 | void Pixelize(int);
|
---|
[228] | 82 |
|
---|
| 83 | /* convertit index nested en ring */
|
---|
[473] | 84 | int NestToRing(int) const;
|
---|
[228] | 85 |
|
---|
| 86 | /* convertit index ring en nested" */
|
---|
[473] | 87 | int RingToNest(int) const;
|
---|
[228] | 88 |
|
---|
[473] | 89 | /* analyse en harmoniques spheriques des valeurs des pixels de la
|
---|
[228] | 90 | sphere : appel du module anafast (Gorski-Hivon) */
|
---|
[470] | 91 | //void anharm(int, float, float*);
|
---|
[228] | 92 |
|
---|
| 93 | /*synthese des valeurs des pixels de la sphere par l'intermediaire
|
---|
| 94 | des coefficients en harmoniques spheriques reconstitues apartir d'un
|
---|
| 95 | spectre en puissance : appel du module synfast (Gorski-Hivon) */
|
---|
[470] | 96 | //void synharm(int, int, float, float*);
|
---|
[228] | 97 |
|
---|
[470] | 98 | /* retourne/fixe la valeur du parametre Gorski */
|
---|
[473] | 99 | inline virtual int SizeIndex() const {return(nSide_);}
|
---|
| 100 | inline void setSizeIndex(int n) {nSide_= n;}
|
---|
[228] | 101 |
|
---|
[470] | 102 | /* retourne les pointeurs /remplit les tableaux */
|
---|
| 103 | inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
|
---|
[473] | 104 | inline void setDataBlock(T* data,int m) { pixels_.FillFrom(m,data); }
|
---|
[470] | 105 |
|
---|
| 106 | /* retourne/fixe les parametres des modules anafast et synfast */
|
---|
[473] | 107 | void getParafast(int& nlmax,int& nmmax,int& iseed,float& fwhm,float& quadr,float& cut) const;
|
---|
| 108 | void setParafast(int nlmax,int nmmax,int iseed,float fwhm,float quadr,float cut,char* filename);
|
---|
[470] | 109 |
|
---|
| 110 | /* retourne/fixe le nom du fichier qui contient le spectre de puissance */
|
---|
| 111 | void powfile(char filename[]) const;
|
---|
| 112 |
|
---|
| 113 | /* impression */
|
---|
| 114 | void print(ostream& os) const;
|
---|
| 115 |
|
---|
[228] | 116 | private :
|
---|
| 117 |
|
---|
[470] | 118 | // ------------- méthodes internes ----------------------
|
---|
| 119 | void InitNul();
|
---|
| 120 |
|
---|
[473] | 121 | int nest2ring(int nside,int ipnest) const;
|
---|
| 122 | int ring2nest(int nside,int ipring) const;
|
---|
[470] | 123 |
|
---|
[473] | 124 | int ang2pix_ring(int nside,double theta,double phi) const;
|
---|
| 125 | int ang2pix_nest(int nside,double theta,double phi) const;
|
---|
| 126 | void pix2ang_ring(int nside,int ipix,double& theta,double& phi) const;
|
---|
| 127 | void pix2ang_nest(int nside,int ipix,double& theta,double& phi) const;
|
---|
[470] | 128 |
|
---|
[228] | 129 | // ------------- variables internes -----------------------
|
---|
[473] | 130 | int nSide_;
|
---|
| 131 | int nPix_;
|
---|
| 132 | double omeg_;
|
---|
[228] | 133 |
|
---|
[470] | 134 | NDataBlock<T> pixels_;
|
---|
[228] | 135 |
|
---|
| 136 | int nlmax_;
|
---|
| 137 | int nmmax_;
|
---|
| 138 | int iseed_;
|
---|
| 139 | float fwhm_;
|
---|
| 140 | float quadrupole_;
|
---|
| 141 | float sym_cut_deg_;
|
---|
| 142 | char powFile_[128];
|
---|
| 143 | };
|
---|
[470] | 144 |
|
---|
| 145 | //
|
---|
| 146 | // ------------- Classe pour la gestion de persistance --
|
---|
| 147 | //
|
---|
| 148 | template <class T>
|
---|
| 149 | class FIO_SphereGorski : public PPersist
|
---|
| 150 | {
|
---|
| 151 | public:
|
---|
| 152 |
|
---|
| 153 | FIO_SphereGorski();
|
---|
| 154 | FIO_SphereGorski(string const & filename);
|
---|
| 155 | FIO_SphereGorski(const SphereGorski<T>& obj);
|
---|
| 156 | FIO_SphereGorski(SphereGorski<T>* obj);
|
---|
| 157 | virtual ~FIO_SphereGorski();
|
---|
| 158 | virtual AnyDataObj* DataObj();
|
---|
| 159 | inline operator SphereGorski<T>() { return(*dobj); }
|
---|
| 160 | inline SphereGorski<T> getObj() { return(*dobj); }
|
---|
| 161 |
|
---|
| 162 | protected :
|
---|
| 163 |
|
---|
| 164 | virtual void ReadSelf(PInPersist&);
|
---|
| 165 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 166 | SphereGorski<T>* dobj;
|
---|
| 167 | bool ownobj;
|
---|
| 168 | };
|
---|
| 169 |
|
---|
| 170 | //
|
---|
| 171 | // ------------- Classe PIXELS_XY -----------------------
|
---|
| 172 | //
|
---|
| 173 | class PIXELS_XY
|
---|
| 174 | {
|
---|
| 175 |
|
---|
| 176 | public :
|
---|
| 177 |
|
---|
| 178 | static PIXELS_XY& instance();
|
---|
| 179 |
|
---|
| 180 | NDataBlock<int> pix2x_;
|
---|
| 181 | NDataBlock<int> pix2y_;
|
---|
| 182 | NDataBlock<int> x2pix_;
|
---|
| 183 | NDataBlock<int> y2pix_;
|
---|
| 184 |
|
---|
| 185 | private :
|
---|
| 186 |
|
---|
| 187 | PIXELS_XY();
|
---|
| 188 | void mk_pix2xy();
|
---|
| 189 | void mk_xy2pix();
|
---|
| 190 | };
|
---|
[228] | 191 | #endif
|
---|