| [2615] | 1 | #include "sopnamsp.h" | 
|---|
| [585] | 2 | #include "machdefs.h" | 
|---|
|  | 3 | #include <stdlib.h> | 
|---|
| [594] | 4 | #include <math.h> | 
|---|
| [585] | 5 | #include <typeinfo> | 
|---|
| [2322] | 6 | #include <iostream> | 
|---|
| [585] | 7 | #include <string> | 
|---|
|  | 8 | #include <complex> | 
|---|
|  | 9 |  | 
|---|
| [1224] | 10 | #include "datatype.h" | 
|---|
|  | 11 |  | 
|---|
| [585] | 12 | #include "nomskymapadapter.h" | 
|---|
| [855] | 13 | #include "skymap.h" | 
|---|
| [594] | 14 | #include "pitvmaad.h" | 
|---|
|  | 15 | #include "complexios.h" | 
|---|
| [585] | 16 |  | 
|---|
| [2594] | 17 | // Valeur par defaut pour la projection MolleWeide, en dehors de la sphere | 
|---|
|  | 18 | static double _prjmol_defval = 0.; | 
|---|
|  | 19 | void Set_Project_Mol_DefVal(double def) | 
|---|
|  | 20 | { | 
|---|
|  | 21 | _prjmol_defval = def; | 
|---|
|  | 22 | return; | 
|---|
|  | 23 | } | 
|---|
| [1321] | 24 |  | 
|---|
| [594] | 25 | //  Classe array adapter pour localMap | 
|---|
|  | 26 | template <class T> | 
|---|
|  | 27 | class LocalMapArrAdapter : public P2DArrayAdapter { | 
|---|
|  | 28 | public: | 
|---|
|  | 29 | LocalMapArrAdapter(LocalMap<T>* lm, bool d=false) : | 
|---|
| [1164] | 30 | P2DArrayAdapter(lm->SizeX(), lm->SizeY()) | 
|---|
| [594] | 31 | { ad = d; map = lm; } | 
|---|
| [585] | 32 |  | 
|---|
| [594] | 33 | virtual       ~LocalMapArrAdapter() { if (ad) delete map; } | 
|---|
|  | 34 | virtual double  Value(int ix, int iy) { return((*map)(ix, iy)); } | 
|---|
| [3520] | 35 | virtual double  MeanVal(int ix1, int ix2, int jy1, int jy2) | 
|---|
|  | 36 | { | 
|---|
|  | 37 | int ec; | 
|---|
|  | 38 | if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; } | 
|---|
|  | 39 | if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; } | 
|---|
|  | 40 | double ss = 0.; | 
|---|
|  | 41 | for(int j=jy1; j<=jy2; j++) | 
|---|
|  | 42 | for(int i=ix1; i<=ix2; i++)  ss += (double)((*map)(i, j)); | 
|---|
|  | 43 | ss /= (double)((jy2-jy1+1)*(ix2-ix1+1)); | 
|---|
|  | 44 | return ss; | 
|---|
|  | 45 | } | 
|---|
| [594] | 46 |  | 
|---|
|  | 47 | protected : | 
|---|
|  | 48 | bool ad; | 
|---|
|  | 49 | LocalMap<T>* map; | 
|---|
|  | 50 | }; | 
|---|
|  | 51 |  | 
|---|
|  | 52 | /* --Methode-- */ | 
|---|
| [2343] | 53 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [594] | 54 | double LocalMapArrAdapter< complex<float> >::Value(int ix, int iy) | 
|---|
|  | 55 | { | 
|---|
|  | 56 | double re,im; | 
|---|
|  | 57 | re = (*map)(iy, ix).real(); | 
|---|
|  | 58 | im = (*map)(iy, ix).imag(); | 
|---|
|  | 59 | return(sqrt(re*re+im*im)); | 
|---|
|  | 60 | } | 
|---|
|  | 61 | /* --Methode-- */ | 
|---|
| [2343] | 62 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [594] | 63 | double LocalMapArrAdapter< complex<double> >::Value(int ix, int iy) | 
|---|
|  | 64 | { | 
|---|
|  | 65 | double re,im; | 
|---|
|  | 66 | re = (*map)(iy, ix).real(); | 
|---|
|  | 67 | im = (*map)(iy, ix).imag(); | 
|---|
|  | 68 | return(sqrt(re*re+im*im)); | 
|---|
|  | 69 | } | 
|---|
|  | 70 |  | 
|---|
| [3520] | 71 | /* --Methode-- */ | 
|---|
|  | 72 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
|  | 73 | double LocalMapArrAdapter< complex<float> >::MeanVal(int ix1, int ix2, int jy1, int jy2) | 
|---|
|  | 74 | { | 
|---|
|  | 75 | int ec; | 
|---|
|  | 76 | if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; } | 
|---|
|  | 77 | if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; } | 
|---|
|  | 78 | complex<float> ss = 0.; | 
|---|
|  | 79 | for(int j=jy1; j<=jy2; j++) | 
|---|
|  | 80 | for(int i=ix1; i<=ix2; i++)  ss += (*map)(i, j); | 
|---|
|  | 81 | ss /= (double)((jy2-jy1+1)*(ix2-ix1+1)); | 
|---|
|  | 82 | return sqrt(ss.real()*ss.real()+ss.imag()*ss.imag()); | 
|---|
|  | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | /* --Methode-- */ | 
|---|
|  | 86 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
|  | 87 | double LocalMapArrAdapter< complex<double> >::MeanVal(int ix1, int ix2, int jy1, int jy2) | 
|---|
|  | 88 | { | 
|---|
|  | 89 | int ec; | 
|---|
|  | 90 | if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; } | 
|---|
|  | 91 | if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; } | 
|---|
|  | 92 | complex<double> ss = 0.; | 
|---|
|  | 93 | for(int j=jy1; j<=jy2; j++) | 
|---|
|  | 94 | for(int i=ix1; i<=ix2; i++)  ss += (*map)(i, j); | 
|---|
|  | 95 | ss /= (double)((jy2-jy1+1)*(ix2-ix1+1)); | 
|---|
|  | 96 | return sqrt(ss.real()*ss.real()+ss.imag()*ss.imag()); | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
| [585] | 99 | //---------------------------------------------------------------- | 
|---|
|  | 100 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet PixelMap<T> | 
|---|
|  | 101 | //---------------------------------------------------------------- | 
|---|
|  | 102 |  | 
|---|
|  | 103 |  | 
|---|
|  | 104 | /* --Methode-- */ | 
|---|
|  | 105 | template <class T> | 
|---|
|  | 106 | NOMAdapter_PixelMap<T>::NOMAdapter_PixelMap(PixelMap<T> * o) | 
|---|
| [594] | 107 | : NObjMgrAdapter(o) | 
|---|
| [585] | 108 | { | 
|---|
|  | 109 | mMap = o; | 
|---|
|  | 110 | } | 
|---|
|  | 111 |  | 
|---|
|  | 112 | /* --Methode-- */ | 
|---|
|  | 113 | template <class T> | 
|---|
|  | 114 | NOMAdapter_PixelMap<T>::~NOMAdapter_PixelMap() | 
|---|
|  | 115 | { | 
|---|
|  | 116 | } | 
|---|
|  | 117 |  | 
|---|
|  | 118 | /* --Methode-- */ | 
|---|
|  | 119 | template <class T> | 
|---|
|  | 120 | NObjMgrAdapter* NOMAdapter_PixelMap<T>::Clone(AnyDataObj* o) | 
|---|
|  | 121 | { | 
|---|
|  | 122 | PixelMap<T>* m = dynamic_cast<PixelMap<T> *>(o); | 
|---|
|  | 123 | if (m) return ( new NOMAdapter_PixelMap<T>(m) ); | 
|---|
|  | 124 | return ( new NObjMgrAdapter(o) ); | 
|---|
|  | 125 | } | 
|---|
|  | 126 |  | 
|---|
|  | 127 | /* --Methode-- */ | 
|---|
|  | 128 | template <class T> | 
|---|
| [1165] | 129 | string NOMAdapter_PixelMap<T>::GetDataObjType() | 
|---|
| [585] | 130 | { | 
|---|
| [1165] | 131 | string type = "PixelMap< "; | 
|---|
| [585] | 132 | LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap); | 
|---|
| [1165] | 133 | if (lm != NULL) type = "LocalMap< "; | 
|---|
|  | 134 | SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap); | 
|---|
|  | 135 | if (st != NULL) type = "SphereThetaPhi< "; | 
|---|
|  | 136 | SphereHEALPix<T>* sg = dynamic_cast< SphereHEALPix<T> * >(mMap); | 
|---|
|  | 137 | if (sg != NULL) type = "SphereHEALPix< "; | 
|---|
| [2613] | 138 | SphereECP<T>* se = dynamic_cast< SphereECP<T> * >(mMap); | 
|---|
|  | 139 | if (se != NULL) type = "SphereECP< "; | 
|---|
| [1165] | 140 |  | 
|---|
| [1224] | 141 | // type +=  DecodeTypeIdName(typeid(T).name()); | 
|---|
| [1237] | 142 | type += DataTypeInfo<T>::getTypeName(); | 
|---|
| [1165] | 143 | type +=  " > "; | 
|---|
|  | 144 | return(type); | 
|---|
|  | 145 | } | 
|---|
|  | 146 |  | 
|---|
|  | 147 | /* --Methode-- */ | 
|---|
|  | 148 | template <class T> | 
|---|
| [1315] | 149 | AnyDataObj* NOMAdapter_PixelMap<T>::CloneDataObj(bool share) | 
|---|
| [1165] | 150 | { | 
|---|
|  | 151 | LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap); | 
|---|
| [1315] | 152 | if (lm != NULL) return( new LocalMap<T>(*lm, share) ); | 
|---|
| [585] | 153 | SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap); | 
|---|
| [1315] | 154 | if (st != NULL) return( new SphereThetaPhi<T>(*st, share) ); | 
|---|
| [855] | 155 | SphereHEALPix<T>* sg = dynamic_cast< SphereHEALPix<T> * >(mMap); | 
|---|
| [1315] | 156 | if (sg != NULL) return( new SphereHEALPix<T>(*sg, share) ); | 
|---|
| [2613] | 157 | SphereECP<T>* se = dynamic_cast< SphereECP<T> * >(mMap); | 
|---|
|  | 158 | if (se != NULL) return( new SphereECP<T>(*se, share) ); | 
|---|
| [585] | 159 | return(NULL); | 
|---|
|  | 160 | } | 
|---|
|  | 161 |  | 
|---|
| [1321] | 162 |  | 
|---|
|  | 163 | /* --Methode-- */ | 
|---|
|  | 164 | template <class T> | 
|---|
| [585] | 165 | void NOMAdapter_PixelMap<T>::SavePPF(POutPersist& pos, string const & nom) | 
|---|
|  | 166 | { | 
|---|
|  | 167 | LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap); | 
|---|
|  | 168 | if (lm != NULL) { | 
|---|
|  | 169 | FIO_LocalMap<T> fio(lm); | 
|---|
|  | 170 | fio.Write(pos, nom); | 
|---|
|  | 171 | return; | 
|---|
|  | 172 | } | 
|---|
|  | 173 | SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap); | 
|---|
|  | 174 | if (st != NULL) { | 
|---|
|  | 175 | FIO_SphereThetaPhi<T> fio(st); | 
|---|
|  | 176 | fio.Write(pos, nom); | 
|---|
|  | 177 | return; | 
|---|
|  | 178 | } | 
|---|
| [855] | 179 | SphereHEALPix<T>* sg = dynamic_cast< SphereHEALPix<T> * >(mMap); | 
|---|
| [585] | 180 | if (sg != NULL) { | 
|---|
| [855] | 181 | FIO_SphereHEALPix<T> fio(sg); | 
|---|
| [585] | 182 | fio.Write(pos, nom); | 
|---|
|  | 183 | return; | 
|---|
|  | 184 | } | 
|---|
| [2613] | 185 | SphereECP<T>* se = dynamic_cast< SphereECP<T> * >(mMap); | 
|---|
|  | 186 | if (se != NULL) { | 
|---|
|  | 187 | FIO_SphereECP<T> fio(se); | 
|---|
|  | 188 | fio.Write(pos, nom); | 
|---|
|  | 189 | return; | 
|---|
|  | 190 | } | 
|---|
| [585] | 191 | string s = typeid(*mMap).name(); | 
|---|
|  | 192 | cout << "NOMAdapter_PixelMap<T>::SavePPF() - Error : Not supported for " << s << endl; | 
|---|
|  | 193 | } | 
|---|
|  | 194 |  | 
|---|
|  | 195 | /* --Methode-- */ | 
|---|
|  | 196 | template <class T> | 
|---|
| [2975] | 197 | void NOMAdapter_PixelMap<T>::Print(ostream& os, int lev) | 
|---|
| [585] | 198 | { | 
|---|
| [2975] | 199 | mMap->Show(os); | 
|---|
|  | 200 | if (lev > 0) { | 
|---|
|  | 201 | T moy, sig; | 
|---|
|  | 202 | MeanSig(moy, sig); | 
|---|
|  | 203 | os << "PixelMap:  Mean= " << moy << "  Sig2= " << sig << endl; | 
|---|
| [585] | 204 | } | 
|---|
| [2975] | 205 | if (lev > 1) { | 
|---|
| [2992] | 206 | int_4 nprmx = 10*lev; | 
|---|
|  | 207 | if (nprmx > mMap->NbPixels()) nprmx = mMap->NbPixels(); | 
|---|
| [2975] | 208 | os << "[k]   (Theta,Phi) :  PixVal" << endl; | 
|---|
|  | 209 | double t, p; | 
|---|
| [2992] | 210 | for(int k=0; k<nprmx; k++) { | 
|---|
| [2975] | 211 | mMap->PixThetaPhi(k, t, p); | 
|---|
|  | 212 | os << "[" << k << "]  (" << t << "," << p << ") :  " << mMap->PixVal(k) << endl; | 
|---|
|  | 213 | } | 
|---|
|  | 214 | } | 
|---|
| [585] | 215 |  | 
|---|
| [2975] | 216 | } | 
|---|
|  | 217 |  | 
|---|
| [1553] | 218 | // -- Fonction pour convertir un X,Y en Theta-Phi sur projection MolleWeide -- | 
|---|
|  | 219 | char * _SphMollweideProj_XY2ThetaPhi(P2DArrayAdapter * aa, int ix, int iy); | 
|---|
| [585] | 220 |  | 
|---|
|  | 221 | /* --Methode-- */ | 
|---|
|  | 222 | template <class T> | 
|---|
| [2613] | 223 | P2DArrayAdapter* NOMAdapter_PixelMap<T>::Get2DArray(string & opt) | 
|---|
| [585] | 224 | { | 
|---|
| [594] | 225 | LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap); | 
|---|
|  | 226 | if (lm != NULL) return(new LocalMapArrAdapter<T>(lm, false)); | 
|---|
|  | 227 | int nr = 250; | 
|---|
|  | 228 | int nc = 500; | 
|---|
| [2613] | 229 | SphereECP<T>* se = dynamic_cast< SphereECP<T> * >(mMap); | 
|---|
|  | 230 | size_t olen = opt.length(); | 
|---|
|  | 231 | if ((se != NULL) && (opt.find("ecparray") < olen)) { | 
|---|
|  | 232 | // On veut la carte bi-dim complete de la sphere ECP | 
|---|
|  | 233 | TMatrix<T> * mtxecp = new TMatrix<T>(se->GetPixelArray(), true);  // on partage les donnees | 
|---|
|  | 234 | POTMatrixAdapter<T> * potmtxecp = new POTMatrixAdapter<T>(mtxecp, true); | 
|---|
|  | 235 | if (opt.find("ecpscaledeg") < olen)  // Echelle angulaire en degre | 
|---|
|  | 236 | potmtxecp->DefineXYCoordinates(se->MinPhi()*180./M_PI, se->MinTheta()*180./M_PI, | 
|---|
|  | 237 | se->DeltaPhi()*180./M_PI, se->DeltaTheta()*180./M_PI); | 
|---|
|  | 238 | else if (opt.find("ecpscalerad") < olen)  // Echelle angulaire en radian | 
|---|
|  | 239 | potmtxecp->DefineXYCoordinates(se->MinPhi(), se->MinTheta(), se->DeltaPhi(), se->DeltaTheta()); | 
|---|
|  | 240 |  | 
|---|
|  | 241 | return ( potmtxecp ); | 
|---|
|  | 242 | } | 
|---|
| [594] | 243 | SphericalMap<T>* sm = dynamic_cast< SphericalMap<T> *>(mMap); | 
|---|
|  | 244 | if (sm != NULL) { nr = sqrt(0.75*mMap->NbPixels());  nc = 2*nr; } | 
|---|
|  | 245 | TMatrix<T> * mtx = new TMatrix<T>(nr, nc); | 
|---|
| [2594] | 246 | Project_Mol(*mtx, (T)_prjmol_defval); | 
|---|
| [1553] | 247 | POTMatrixAdapter<T> * potma = new POTMatrixAdapter<T>(mtx, true); | 
|---|
| [3433] | 248 | potma->DefineXYCoordinates(0.,90.,360./(double)(mtx->NCols()),-180./(double)(mtx->NRows())); | 
|---|
| [1553] | 249 | potma->SetInfoStringFunction(_SphMollweideProj_XY2ThetaPhi); | 
|---|
|  | 250 | return ( potma ); | 
|---|
| [585] | 251 | } | 
|---|
|  | 252 |  | 
|---|
|  | 253 | /* --Methode-- */ | 
|---|
|  | 254 | template <class T> | 
|---|
|  | 255 | NTupleInterface* NOMAdapter_PixelMap<T>::GetNTupleInterface(bool& adel) | 
|---|
|  | 256 | { | 
|---|
|  | 257 | adel = true; | 
|---|
|  | 258 | return( new NTupInt_PixelMap<T>(mMap) ); | 
|---|
|  | 259 | } | 
|---|
|  | 260 |  | 
|---|
| [594] | 261 | /* --Methode-- */ | 
|---|
|  | 262 | template <class T> | 
|---|
|  | 263 | void NOMAdapter_PixelMap<T>::MeanSig(T& gmoy, T& gsig) | 
|---|
|  | 264 | { | 
|---|
|  | 265 | gmoy=0.; | 
|---|
|  | 266 | gsig = 0.; | 
|---|
|  | 267 | T valok; | 
|---|
|  | 268 | for(int k=0; k<mMap->NbPixels(); k++) { | 
|---|
|  | 269 | valok = (*mMap)(k); | 
|---|
|  | 270 | gmoy += valok;  gsig += valok*valok; | 
|---|
|  | 271 | } | 
|---|
|  | 272 | gmoy /= (T)mMap->NbPixels(); | 
|---|
|  | 273 | gsig = gsig/(T)mMap->NbPixels() - gmoy*gmoy; | 
|---|
| [585] | 274 |  | 
|---|
| [594] | 275 | } | 
|---|
| [585] | 276 |  | 
|---|
| [594] | 277 | /* --Methode-- */ | 
|---|
|  | 278 | template <class T> | 
|---|
|  | 279 | void NOMAdapter_PixelMap<T>::Project_Mol(TMatrix<T> & mtx, T defval) | 
|---|
|  | 280 | { | 
|---|
|  | 281 | r_8 xa, yd, teta,phi, facteur; | 
|---|
|  | 282 | int_4 l,c,k; | 
|---|
|  | 283 | int_4 nl = mtx.NRows(); | 
|---|
|  | 284 | int_4 nc = mtx.NCols(); | 
|---|
| [815] | 285 | mtx = defval;   // On met tout a defval | 
|---|
| [594] | 286 | //  cout << " NRows= " << nl << "  NCols= " << nc  << endl; | 
|---|
|  | 287 | for(l=0; l<nl; l++) { | 
|---|
|  | 288 | yd = (r_8)(l+0.5)/(r_8)nl-0.5; | 
|---|
|  | 289 | facteur=2.*M_PI/sin(acos((double)yd*2)); | 
|---|
|  | 290 | teta = (yd+0.5)*Pi; | 
|---|
|  | 291 | //    teta = (0.5-yd)*M_PI; | 
|---|
|  | 292 | for(c=0; c<nc; c++)  { | 
|---|
| [1553] | 293 | xa = (r_8)(c+0.5)/(r_8)nc-0.5; | 
|---|
| [594] | 294 | phi = xa*facteur+M_PI; | 
|---|
|  | 295 | if ( (phi <= 2*M_PI) && (phi >= 0.) ) { | 
|---|
|  | 296 | k = mMap->PixIndexSph(teta, phi); | 
|---|
|  | 297 | mtx(l,c) = (*mMap)(k); | 
|---|
|  | 298 | } | 
|---|
|  | 299 | } | 
|---|
|  | 300 | } | 
|---|
|  | 301 | } | 
|---|
|  | 302 |  | 
|---|
| [1553] | 303 | static char m_buff[128]; | 
|---|
|  | 304 | char * _SphMollweideProj_XY2ThetaPhi(P2DArrayAdapter * aa, int ix, int iy) | 
|---|
|  | 305 | { | 
|---|
|  | 306 | r_8 xa, yd, teta,phi, facteur; | 
|---|
|  | 307 | int_4 nl = aa->YSize(); | 
|---|
|  | 308 | int_4 nc = aa->XSize(); | 
|---|
|  | 309 | int l, c; | 
|---|
|  | 310 | aa->IJ2xy(ix, iy, c, l); | 
|---|
|  | 311 | yd = (r_8)(l+0.5)/(r_8)nl-0.5; | 
|---|
|  | 312 | facteur=2.*M_PI/sin(acos((double)yd*2)); | 
|---|
|  | 313 | teta = (yd+0.5)*Pi; | 
|---|
|  | 314 | xa = (r_8)(c+0.5)/(r_8)nc-0.5; | 
|---|
|  | 315 | phi = xa*facteur+M_PI; | 
|---|
|  | 316 | if ( (phi <= 2*M_PI) && (phi >= 0.) ) | 
|---|
| [1580] | 317 | sprintf(m_buff,"(l,b=%5.1f,%5.1f)", phi*180./M_PI, 90.-teta*180./M_PI); | 
|---|
| [1553] | 318 | else | 
|---|
| [1580] | 319 | sprintf(m_buff,"(l,b=?,?)"); | 
|---|
| [1553] | 320 |  | 
|---|
|  | 321 | return (m_buff); | 
|---|
|  | 322 | } | 
|---|
|  | 323 |  | 
|---|
| [585] | 324 | // ------------------------------------------------------------- | 
|---|
|  | 325 |  | 
|---|
|  | 326 | /* --Methode-- */ | 
|---|
|  | 327 | template <class T> | 
|---|
|  | 328 | NTupInt_PixelMap<T>::NTupInt_PixelMap(PixelMap<T>* m) | 
|---|
|  | 329 | { | 
|---|
|  | 330 | mMap = m; | 
|---|
|  | 331 | } | 
|---|
|  | 332 |  | 
|---|
|  | 333 | /* --Methode-- */ | 
|---|
|  | 334 | template <class T> | 
|---|
|  | 335 | NTupInt_PixelMap<T>::~NTupInt_PixelMap() | 
|---|
|  | 336 | { | 
|---|
|  | 337 | } | 
|---|
|  | 338 |  | 
|---|
|  | 339 | /* --Methode-- */ | 
|---|
|  | 340 | template <class T> | 
|---|
| [2683] | 341 | sa_size_t NTupInt_PixelMap<T>::NbLines() const | 
|---|
| [585] | 342 | { | 
|---|
|  | 343 | return( mMap->NbPixels() ); | 
|---|
|  | 344 | } | 
|---|
|  | 345 |  | 
|---|
|  | 346 | /* --Methode-- */ | 
|---|
|  | 347 | template <class T> | 
|---|
| [2683] | 348 | sa_size_t NTupInt_PixelMap<T>::NbColumns() const | 
|---|
| [585] | 349 | { | 
|---|
|  | 350 | return(8); | 
|---|
|  | 351 | } | 
|---|
|  | 352 |  | 
|---|
|  | 353 | /* --Methode-- */ | 
|---|
|  | 354 | template <class T> | 
|---|
| [2683] | 355 | r_8* NTupInt_PixelMap<T>::GetLineD(sa_size_t n) const | 
|---|
| [585] | 356 | { | 
|---|
|  | 357 | int i; | 
|---|
|  | 358 | if ((n < 0) || (n >= (int)(mMap->NbPixels()) )) | 
|---|
|  | 359 | for(i=0; i<8; i++)  mRet[i] = 0.; | 
|---|
|  | 360 | else { | 
|---|
|  | 361 | double teta,phi; | 
|---|
|  | 362 | mMap->PixThetaPhi(n, teta, phi); | 
|---|
|  | 363 | mRet[0] = n;  mRet[1] = mMap->PixVal(n); | 
|---|
|  | 364 | mRet[2] = mRet[1];  mRet[3] = 0.; | 
|---|
|  | 365 | mRet[4] = mRet[1];  mRet[5] = 0.; | 
|---|
|  | 366 | mRet[6] = teta;     mRet[7] = phi; | 
|---|
|  | 367 | } | 
|---|
|  | 368 | return(mRet); | 
|---|
|  | 369 | } | 
|---|
|  | 370 |  | 
|---|
|  | 371 | /* --Methode-- */ | 
|---|
|  | 372 | template <class T> | 
|---|
|  | 373 | string NTupInt_PixelMap<T>::VarList_C(const char* nx) const | 
|---|
|  | 374 | { | 
|---|
|  | 375 | string nomx; | 
|---|
|  | 376 | if (nx) nomx = nx; | 
|---|
|  | 377 | else nomx = "_xh_"; | 
|---|
|  | 378 | string vardec = "double i,k,val,real,imag,mod,phas,teta,phi; \n"; | 
|---|
|  | 379 | vardec += "i = " + nomx + "[0]; k = " + nomx + "[0];  val = " + nomx + "[1]; \n"; | 
|---|
|  | 380 | vardec += "real = " + nomx + "[2];  imag = " + nomx + "[3]; \n"; | 
|---|
|  | 381 | vardec += "mod  = " + nomx + "[4];  phas = " + nomx + "[5]; \n"; | 
|---|
|  | 382 | vardec += "teta = " + nomx + "[6];  phi  = " + nomx + "[7]; \n"; | 
|---|
|  | 383 | return(vardec); | 
|---|
|  | 384 | } | 
|---|
|  | 385 |  | 
|---|
| [2343] | 386 |  | 
|---|
|  | 387 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [2689] | 388 | r_8* NTupInt_PixelMap< complex<float> >::GetLineD(sa_size_t n) const | 
|---|
| [585] | 389 | { | 
|---|
|  | 390 | int i; | 
|---|
|  | 391 | if ((n < 0) || (n >= (int)(mMap->NbPixels()) )) | 
|---|
|  | 392 | for(i=0; i<8; i++)  mRet[i] = 0.; | 
|---|
|  | 393 | else { | 
|---|
|  | 394 | double teta,phi; | 
|---|
|  | 395 | mMap->PixThetaPhi(n, teta, phi); | 
|---|
|  | 396 | mRet[0] = n; | 
|---|
|  | 397 | mRet[2] = mMap->PixVal(n).real();  mRet[3] = mMap->PixVal(n).imag(); | 
|---|
|  | 398 | mRet[1] = mRet[4] = sqrt(mRet[2]*mRet[2]+mRet[3]*mRet[3]); | 
|---|
|  | 399 | mRet[5] = atan2(mRet[3], mRet[2]); | 
|---|
|  | 400 | mRet[6] = teta;     mRet[7] = phi; | 
|---|
|  | 401 | } | 
|---|
|  | 402 | return(mRet); | 
|---|
|  | 403 | } | 
|---|
|  | 404 |  | 
|---|
| [2343] | 405 | DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */ | 
|---|
| [2689] | 406 | r_8* NTupInt_PixelMap< complex<double> >::GetLineD(sa_size_t n) const | 
|---|
| [585] | 407 | { | 
|---|
|  | 408 | int i; | 
|---|
|  | 409 | if ((n < 0) || (n >= (int)(mMap->NbPixels()) )) | 
|---|
|  | 410 | for(i=0; i<8; i++)  mRet[i] = 0.; | 
|---|
|  | 411 | else { | 
|---|
|  | 412 | double teta,phi; | 
|---|
|  | 413 | mMap->PixThetaPhi(n, teta, phi); | 
|---|
|  | 414 | mRet[0] = n; | 
|---|
|  | 415 | mRet[2] = mMap->PixVal(n).real();  mRet[3] = mMap->PixVal(n).imag(); | 
|---|
|  | 416 | mRet[1] = mRet[4] = sqrt(mRet[2]*mRet[2]+mRet[3]*mRet[3]); | 
|---|
|  | 417 | mRet[5] = atan2(mRet[3], mRet[2]); | 
|---|
|  | 418 | mRet[6] = teta;     mRet[7] = phi; | 
|---|
|  | 419 | } | 
|---|
|  | 420 | return(mRet); | 
|---|
|  | 421 | } | 
|---|
|  | 422 |  | 
|---|
|  | 423 |  | 
|---|
|  | 424 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
| [2084] | 425 | #pragma define_template NOMAdapter_PixelMap<int_4> | 
|---|
| [585] | 426 | #pragma define_template NOMAdapter_PixelMap<r_4> | 
|---|
|  | 427 | #pragma define_template NOMAdapter_PixelMap<r_8> | 
|---|
|  | 428 | #pragma define_template NOMAdapter_PixelMap< complex<float> > | 
|---|
|  | 429 | #pragma define_template NOMAdapter_PixelMap< complex<double> > | 
|---|
| [2084] | 430 | #pragma define_template NTupInt_PixelMap<int_4> | 
|---|
| [585] | 431 | #pragma define_template NTupInt_PixelMap<r_4> | 
|---|
|  | 432 | #pragma define_template NTupInt_PixelMap<r_8> | 
|---|
|  | 433 | #pragma define_template NTupInt_PixelMap< complex<float> > | 
|---|
|  | 434 | #pragma define_template NTupInt_PixelMap< complex<double> > | 
|---|
|  | 435 | #endif | 
|---|
|  | 436 |  | 
|---|
|  | 437 | #if defined(ANSI_TEMPLATES) | 
|---|
| [2084] | 438 | template class NOMAdapter_PixelMap<int_4>; | 
|---|
| [585] | 439 | template class NOMAdapter_PixelMap<r_4>; | 
|---|
|  | 440 | template class NOMAdapter_PixelMap<r_8>; | 
|---|
|  | 441 | template class NOMAdapter_PixelMap< complex<float> >; | 
|---|
|  | 442 | template class NOMAdapter_PixelMap< complex<double> >; | 
|---|
| [2084] | 443 | template class NTupInt_PixelMap<int_4>; | 
|---|
| [585] | 444 | template class NTupInt_PixelMap<r_4>; | 
|---|
|  | 445 | template class NTupInt_PixelMap<r_8>; | 
|---|
|  | 446 | template class NTupInt_PixelMap< complex<float> >; | 
|---|
|  | 447 | template class NTupInt_PixelMap< complex<double> >; | 
|---|
|  | 448 | #endif | 
|---|