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