Changeset 594 in Sophya for trunk/SophyaPI/PIext/nomskymapadapter.cc
- Timestamp:
- Nov 17, 1999, 7:49:32 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nomskymapadapter.cc
r585 r594 1 1 #include "machdefs.h" 2 2 #include <stdlib.h> 3 #include <math.h> 3 4 #include <typeinfo> 4 5 #include <iostream.h> … … 10 11 #include "spheregorski.h" 11 12 #include "localmap.h" 12 13 #include "pitvmaad.h" 14 #include "complexios.h" 15 16 // Classe array adapter pour localMap 17 template <class T> 18 class LocalMapArrAdapter : public P2DArrayAdapter { 19 public: 20 LocalMapArrAdapter(LocalMap<T>* lm, bool d=false) : 21 P2DArrayAdapter(lm->XSize(), lm->YSize()) 22 { ad = d; map = lm; } 23 24 virtual ~LocalMapArrAdapter() { if (ad) delete map; } 25 virtual double Value(int ix, int iy) { return((*map)(ix, iy)); } 26 27 protected : 28 bool ad; 29 LocalMap<T>* map; 30 }; 31 32 /* --Methode-- */ 33 double LocalMapArrAdapter< complex<float> >::Value(int ix, int iy) 34 { 35 double re,im; 36 re = (*map)(iy, ix).real(); 37 im = (*map)(iy, ix).imag(); 38 return(sqrt(re*re+im*im)); 39 } 40 /* --Methode-- */ 41 double LocalMapArrAdapter< complex<double> >::Value(int ix, int iy) 42 { 43 double re,im; 44 re = (*map)(iy, ix).real(); 45 im = (*map)(iy, ix).imag(); 46 return(sqrt(re*re+im*im)); 47 } 13 48 14 49 //---------------------------------------------------------------- … … 20 55 template <class T> 21 56 NOMAdapter_PixelMap<T>::NOMAdapter_PixelMap(PixelMap<T> * o) 22 : NObjMgrAdapter( (AnyDataObj *)o)57 : NObjMgrAdapter(o) 23 58 { 24 59 mMap = o; … … 84 119 { 85 120 string s = typeid(*mMap).name(); 121 T moy, sig; 122 MeanSig(moy, sig); 86 123 cout << "SkyMap Type: " << s << " NbPixels= " << mMap->NbPixels() << endl; 124 cout << " Mean= " << moy << " Sig2= " << sig << endl; 87 125 } 88 126 … … 92 130 P2DArrayAdapter* NOMAdapter_PixelMap<T>::Get2DArray(string &) 93 131 { 94 return(NULL); 132 LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap); 133 if (lm != NULL) return(new LocalMapArrAdapter<T>(lm, false)); 134 int nr = 250; 135 int nc = 500; 136 SphericalMap<T>* sm = dynamic_cast< SphericalMap<T> *>(mMap); 137 if (sm != NULL) { nr = sqrt(0.75*mMap->NbPixels()); nc = 2*nr; } 138 TMatrix<T> * mtx = new TMatrix<T>(nr, nc); 139 Project_Mol(*mtx); 140 return (new POTMatrixAdapter<T>(mtx, true) ); 95 141 } 96 142 … … 103 149 } 104 150 105 151 /* --Methode-- */ 152 template <class T> 153 void NOMAdapter_PixelMap<T>::MeanSig(T& gmoy, T& gsig) 154 { 155 gmoy=0.; 156 gsig = 0.; 157 T valok; 158 for(int k=0; k<mMap->NbPixels(); k++) { 159 valok = (*mMap)(k); 160 gmoy += valok; gsig += valok*valok; 161 } 162 gmoy /= (T)mMap->NbPixels(); 163 gsig = gsig/(T)mMap->NbPixels() - gmoy*gmoy; 164 165 } 166 167 /* --Methode-- */ 168 template <class T> 169 void NOMAdapter_PixelMap<T>::Project_Mol(TMatrix<T> & mtx, T defval) 170 { 171 r_8 xa, yd, teta,phi, facteur; 172 int_4 l,c,k; 173 int_4 nl = mtx.NRows(); 174 int_4 nc = mtx.NCols(); 175 mtx.Reset(defval); // On met tout a defval 176 // cout << " NRows= " << nl << " NCols= " << nc << endl; 177 for(l=0; l<nl; l++) { 178 yd = (r_8)(l+0.5)/(r_8)nl-0.5; 179 facteur=2.*M_PI/sin(acos((double)yd*2)); 180 teta = (yd+0.5)*Pi; 181 // teta = (0.5-yd)*M_PI; 182 for(c=0; c<nc; c++) { 183 xa = (r_8)(c+0.5)/(r_8)nc-0.5; 184 phi = xa*facteur+M_PI; 185 if ( (phi <= 2*M_PI) && (phi >= 0.) ) { 186 k = mMap->PixIndexSph(teta, phi); 187 mtx(l,c) = (*mMap)(k); 188 } 189 } 190 } 191 } 106 192 107 193 // -------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.