Changeset 470 in Sophya for trunk/SophyaLib/Samba/spheregorski.h
- Timestamp:
- Oct 15, 1999, 5:43:30 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/spheregorski.h
r228 r470 3 3 4 4 #include "sphericalmap.h" 5 #include "cvector.h" 5 #include "tvector.h" 6 #include "ndatablock.h" 7 8 #include "anydataobj.h" 9 #include "ppersist.h" 6 10 7 11 // les attributs de classe pix2x_ et pix2y_ sont relatifs a la traduction des 8 // indices RING en indices NESTED (ou l 'inverse). Ce sont des tableaux12 // indices RING en indices NESTED (ou l inverse). Ce sont des tableaux 9 13 // d'entiers initialises et remplis par le constructeur. Dans la version 10 14 // FORTRAN de healpix, il s'agissait de tableaux mis en COMMON. Ils etaient 11 // initialises au premier appel d'une conversion d 'indice. Je ne peux pas15 // initialises au premier appel d'une conversion d indice. Je ne peux pas 12 16 // garder cette procedure car, par exemple, la fonction PixValNest() const 13 17 // n'autorisera pas la constitution de ces tableaux (a cause du const). Ainsi, 14 // des la creation d 'un objet SphereGorski ces tableaux sont calcules, ce qui18 // des la creation d un objet SphereGorski ces tableaux sont calcules, ce qui 15 19 // est, certes, inutile si on ne se sert pas des indices NESTED. Ca ne me 16 // rejouit pas, mais c 'est le seul moyen que j'ai trouve pour temir compte de20 // rejouit pas, mais c est le seul moyen que j ai trouve pour temir compte de 17 21 // toutes les demandes et des options prises. 18 22 // 19 23 // G. Le Meur 20 24 21 class SphereGorski : public SphericalMap { 25 // ***************** CLASSE SphereGorski ***************************** 26 27 template<class T> 28 class SphereGorski : public SphericalMap<T>, public AnyDataObj 29 { 30 22 31 public : 23 24 32 25 33 SphereGorski(); 26 34 SphereGorski(int_4 m); 27 SphereGorski(c har* flnm);35 SphereGorski(const SphereGorski<T>& s); 28 36 virtual ~SphereGorski(); 29 30 // ------------ Persistence handling31 enum {classId = 0xF002 };32 33 int_4 ClassId() const { return classId; }34 35 virtual void WriteSelf(POutPersist&) const;36 virtual void ReadSelf(PInPersist&);37 38 // ----------- FITS IO (1D FITS ARRAY)39 void ReadFits(char flnm[] );40 void WriteFits(char flnm[]);41 37 42 38 // ------------------ Definition of PixelMap abstract methods 43 39 44 /* Nombre de pixels du decoupage */ 45 virtual int_4 NbPixels() const; 40 /* Nombre de pixels du decoupage */ 41 virtual int_4 NbPixels() const; 42 inline void setNbPixels(int_4 n) {nPix_= n;} 46 43 47 /* Valeur du contenu du pixel d'indice "RING" k 48 virtual r_8&PixVal(int_4 k);49 virtual r_8 const&PixVal(int_4 k) const;44 /* Valeur du contenu du pixel d'indice "RING" k */ 45 virtual T& PixVal(int_4 k); 46 virtual T const& PixVal(int_4 k) const; 50 47 48 /* Nombre de tranches en theta */ 51 49 int_4 NbThetaSlices() const; 52 void GetThetaSlice(int_4 index, r_4& theta, Vector& phi, Vector& value) const;50 void GetThetaSlice(int_4 index,r_4& theta,TVector<float>& phi,TVector<T>& value) const; 53 51 54 52 /* Indice "RING" du pixel vers lequel pointe une direction definie par 55 53 ses coordonnees spheriques */ 56 virtual int_4PixIndexSph(float theta, float phi) const;54 virtual int_4 PixIndexSph(float theta, float phi) const; 57 55 58 /* Coordonnees spheriques du milieu du pixel d'indice "RING" k 59 virtual voidPixThetaPhi(int_4 k, float& teta, float& phi) const;56 /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */ 57 virtual void PixThetaPhi(int_4 k, float& teta, float& phi) const; 60 58 61 / / Pixel Solid angle (steradians)62 virtual r_8 PixSolAngle(int_4 dummy) const;63 59 /* Pixel Solid angle (steradians) */ 60 virtual r_8 PixSolAngle(int_4 dummy) const; 61 inline void setPixSolAngle(r_8 x) {omeg_= x;} 64 62 65 63 // --------------- Specific methods 66 64 67 // NEST indexing 65 virtual void Resize(int_4 m); 66 67 inline virtual char* TypeOfMap() const {return "RING";}; 68 68 69 /* Valeur du contenu du pixel d'indice "NEST" k */ 69 virtual r_8&PixValNest(int_4 k);70 virtual r_8 const&PixValNest(int_4 k) const;70 virtual T& PixValNest(int_4 k); 71 virtual T const& PixValNest(int_4 k) const; 71 72 72 73 /* Indice "NEST" du pixel vers lequel pointe une direction definie par 73 74 ses coordonnees spheriques */ 74 virtual int_4PixIndexSphNest(float theta, float phi) const;75 virtual int_4 PixIndexSphNest(float theta, float phi) const; 75 76 76 77 /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */ 77 virtual voidPixThetaPhiNest(int_4 k, float& teta, float& phi) const;78 virtual void PixThetaPhiNest(int_4 k, float& teta, float& phi) const; 78 79 79 // algorithme de pixelisation 80 /* algorithme de pixelisation */ 80 81 void Pixelize(int_4); 81 82 82 83 83 /* convertit index nested en ring */ 84 int_4 NestToRing(int_4 ); 85 84 int_4 NestToRing(int_4 ) const; 86 85 87 86 /* convertit index ring en nested" */ 88 int_4 RingToNest(int_4 ); 89 87 int_4 RingToNest(int_4 ) const; 90 88 91 89 /* analyse en harmoniques spheriques des valeurs des pixels de la 92 90 sphere : appel du module anafast (Gorski-Hivon) */ 93 void anharm(int, float, float*);91 //void anharm(int, float, float*); 94 92 95 93 /*synthese des valeurs des pixels de la sphere par l'intermediaire 96 94 des coefficients en harmoniques spheriques reconstitues apartir d'un 97 95 spectre en puissance : appel du module synfast (Gorski-Hivon) */ 98 void synharm(int , int, float, float*);96 //void synharm(int, int, float, float*); 99 97 98 /* retourne/fixe la valeur du parametre Gorski */ 99 inline virtual int_4 SizeIndex() const {return(nSide_);} 100 inline void setSizeIndex(int_4 n) {nSide_= n;} 101 102 /* retourne les pointeurs /remplit les tableaux */ 103 inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); } 104 inline void setDataBlock(T* data, int_4 m) { pixels_.FillFrom(m,data); } 105 106 /* retourne/fixe les parametres des modules anafast et synfast */ 107 void getParafast(int_4& nlmax,int_4& nmmax,int_4& iseed,float& fwhm,float& quadr,float& cut) const; 108 void setParafast(int_4 nlmax,int_4 nmmax,int_4 iseed,float fwhm,float quadr,float cut,char* filename); 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 116 private : 100 117 101 118 // ------------- méthodes internes ---------------------- 102 103 private : 119 void InitNul(); 104 120 105 void InitNul(); 106 void Clear(); 107 int nest2ring(int nside, int ipnest) const; 108 void mk_pix2xy(int *pix2x,int *pix2y); 109 int ring2nest(int nside, int ipring) const; 110 void mk_xy2pix(int *x2pix, int *y2pix); 111 int ang2pix_ring(int nside, double theta, double phi) const; 112 int ang2pix_nest(int nside, double theta, double phi) const; 113 void pix2ang_ring(int nside, int ipix, double& theta, double& phi) const; 114 void pix2ang_nest(int nside, int ipix, double& theta, double& phi) const; 121 int nest2ring(int nside, int ipnest) const; 122 int ring2nest(int nside, int ipring) const; 123 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; 128 115 129 // ------------- variables internes ----------------------- 116 private : 117 class Pix2XY { 118 public : 119 Pix2XY() { 120 pix2x_=new int[1024]; 121 pix2y_=new int[1024]; 122 mk_pix2xy(pix2x_,pix2y_); 123 } 124 ~Pix2XY() { 125 if (pix2x_) delete[] pix2x_; 126 if (pix2y_) delete[] pix2y_; 127 } 128 void pix2ang_nest(int nside, int ipix, double& theta, double& phi) const; 130 int_4 nSide_; 131 int_4 nPix_; 132 r_8 omeg_; 129 133 130 private : 131 int *pix2x_; 132 int *pix2y_; 133 void mk_pix2xy(int *pix2x,int *pix2y); 134 135 }; 134 NDataBlock<T> pixels_; 136 135 137 136 int nlmax_; 138 137 int nmmax_; 139 138 int iseed_; 140 int nSide_;141 int_4 nPix_;142 int *pix2x_;143 int *pix2y_;144 int *x2pix_;145 int *y2pix_;146 139 float fwhm_; 147 140 float quadrupole_; 148 141 float sym_cut_deg_; 149 r_8 omeg_;150 r_8* mPix_;151 142 char powFile_[128]; 152 Pix2XY *pix2xy_; 143 }; 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(); 153 190 }; 154 191 #endif
Note:
See TracChangeset
for help on using the changeset viewer.