[585] | 1 | #include "machdefs.h"
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <typeinfo>
|
---|
| 4 | #include <iostream.h>
|
---|
| 5 | #include <string>
|
---|
| 6 | #include <complex>
|
---|
| 7 |
|
---|
| 8 | #include "nomskymapadapter.h"
|
---|
| 9 | #include "spherethetaphi.h"
|
---|
| 10 | #include "spheregorski.h"
|
---|
| 11 | #include "localmap.h"
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | //----------------------------------------------------------------
|
---|
| 15 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet PixelMap<T>
|
---|
| 16 | //----------------------------------------------------------------
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | /* --Methode-- */
|
---|
| 20 | template <class T>
|
---|
| 21 | NOMAdapter_PixelMap<T>::NOMAdapter_PixelMap(PixelMap<T> * o)
|
---|
| 22 | : NObjMgrAdapter((AnyDataObj *)o)
|
---|
| 23 | {
|
---|
| 24 | mMap = o;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | /* --Methode-- */
|
---|
| 28 | template <class T>
|
---|
| 29 | NOMAdapter_PixelMap<T>::~NOMAdapter_PixelMap()
|
---|
| 30 | {
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | /* --Methode-- */
|
---|
| 34 | template <class T>
|
---|
| 35 | NObjMgrAdapter* NOMAdapter_PixelMap<T>::Clone(AnyDataObj* o)
|
---|
| 36 | {
|
---|
| 37 | PixelMap<T>* m = dynamic_cast<PixelMap<T> *>(o);
|
---|
| 38 | if (m) return ( new NOMAdapter_PixelMap<T>(m) );
|
---|
| 39 | return ( new NObjMgrAdapter(o) );
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | /* --Methode-- */
|
---|
| 43 | template <class T>
|
---|
| 44 | AnyDataObj* NOMAdapter_PixelMap<T>::GetCopyObj()
|
---|
| 45 | {
|
---|
| 46 | LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap);
|
---|
| 47 | if (lm != NULL) return( new LocalMap<T>(*lm) );
|
---|
| 48 | SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap);
|
---|
| 49 | if (st != NULL) return( new SphereThetaPhi<T>(*st) );
|
---|
| 50 | SphereGorski<T>* sg = dynamic_cast< SphereGorski<T> * >(mMap);
|
---|
| 51 | if (sg != NULL) return( new SphereGorski<T>(*sg) );
|
---|
| 52 | return(NULL);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /* --Methode-- */
|
---|
| 56 | template <class T>
|
---|
| 57 | void NOMAdapter_PixelMap<T>::SavePPF(POutPersist& pos, string const & nom)
|
---|
| 58 | {
|
---|
| 59 | LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap);
|
---|
| 60 | if (lm != NULL) {
|
---|
| 61 | FIO_LocalMap<T> fio(lm);
|
---|
| 62 | fio.Write(pos, nom);
|
---|
| 63 | return;
|
---|
| 64 | }
|
---|
| 65 | SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap);
|
---|
| 66 | if (st != NULL) {
|
---|
| 67 | FIO_SphereThetaPhi<T> fio(st);
|
---|
| 68 | fio.Write(pos, nom);
|
---|
| 69 | return;
|
---|
| 70 | }
|
---|
| 71 | SphereGorski<T>* sg = dynamic_cast< SphereGorski<T> * >(mMap);
|
---|
| 72 | if (sg != NULL) {
|
---|
| 73 | FIO_SphereGorski<T> fio(sg);
|
---|
| 74 | fio.Write(pos, nom);
|
---|
| 75 | return;
|
---|
| 76 | }
|
---|
| 77 | string s = typeid(*mMap).name();
|
---|
| 78 | cout << "NOMAdapter_PixelMap<T>::SavePPF() - Error : Not supported for " << s << endl;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | /* --Methode-- */
|
---|
| 82 | template <class T>
|
---|
| 83 | void NOMAdapter_PixelMap<T>::Print(ostream& os)
|
---|
| 84 | {
|
---|
| 85 | string s = typeid(*mMap).name();
|
---|
| 86 | cout << "SkyMap Type: " << s << " NbPixels= " << mMap->NbPixels() << endl;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | /* --Methode-- */
|
---|
| 91 | template <class T>
|
---|
| 92 | P2DArrayAdapter* NOMAdapter_PixelMap<T>::Get2DArray(string &)
|
---|
| 93 | {
|
---|
| 94 | return(NULL);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /* --Methode-- */
|
---|
| 98 | template <class T>
|
---|
| 99 | NTupleInterface* NOMAdapter_PixelMap<T>::GetNTupleInterface(bool& adel)
|
---|
| 100 | {
|
---|
| 101 | adel = true;
|
---|
| 102 | return( new NTupInt_PixelMap<T>(mMap) );
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | // -------------------------------------------------------------
|
---|
| 108 |
|
---|
| 109 | /* --Methode-- */
|
---|
| 110 | template <class T>
|
---|
| 111 | NTupInt_PixelMap<T>::NTupInt_PixelMap(PixelMap<T>* m)
|
---|
| 112 | {
|
---|
| 113 | mMap = m;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | /* --Methode-- */
|
---|
| 117 | template <class T>
|
---|
| 118 | NTupInt_PixelMap<T>::~NTupInt_PixelMap()
|
---|
| 119 | {
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | /* --Methode-- */
|
---|
| 123 | template <class T>
|
---|
| 124 | uint_4 NTupInt_PixelMap<T>::NbLines() const
|
---|
| 125 | {
|
---|
| 126 | return( mMap->NbPixels() );
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | /* --Methode-- */
|
---|
| 130 | template <class T>
|
---|
| 131 | uint_4 NTupInt_PixelMap<T>::NbColumns() const
|
---|
| 132 | {
|
---|
| 133 | return(8);
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | /* --Methode-- */
|
---|
| 137 | template <class T>
|
---|
| 138 | r_8* NTupInt_PixelMap<T>::GetLineD(int n) const
|
---|
| 139 | {
|
---|
| 140 | int i;
|
---|
| 141 | if ((n < 0) || (n >= (int)(mMap->NbPixels()) ))
|
---|
| 142 | for(i=0; i<8; i++) mRet[i] = 0.;
|
---|
| 143 | else {
|
---|
| 144 | double teta,phi;
|
---|
| 145 | mMap->PixThetaPhi(n, teta, phi);
|
---|
| 146 | mRet[0] = n; mRet[1] = mMap->PixVal(n);
|
---|
| 147 | mRet[2] = mRet[1]; mRet[3] = 0.;
|
---|
| 148 | mRet[4] = mRet[1]; mRet[5] = 0.;
|
---|
| 149 | mRet[6] = teta; mRet[7] = phi;
|
---|
| 150 | }
|
---|
| 151 | return(mRet);
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /* --Methode-- */
|
---|
| 155 | template <class T>
|
---|
| 156 | string NTupInt_PixelMap<T>::VarList_C(const char* nx) const
|
---|
| 157 | {
|
---|
| 158 | string nomx;
|
---|
| 159 | if (nx) nomx = nx;
|
---|
| 160 | else nomx = "_xh_";
|
---|
| 161 | string vardec = "double i,k,val,real,imag,mod,phas,teta,phi; \n";
|
---|
| 162 | vardec += "i = " + nomx + "[0]; k = " + nomx + "[0]; val = " + nomx + "[1]; \n";
|
---|
| 163 | vardec += "real = " + nomx + "[2]; imag = " + nomx + "[3]; \n";
|
---|
| 164 | vardec += "mod = " + nomx + "[4]; phas = " + nomx + "[5]; \n";
|
---|
| 165 | vardec += "teta = " + nomx + "[6]; phi = " + nomx + "[7]; \n";
|
---|
| 166 | return(vardec);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | r_8* NTupInt_PixelMap< complex<float> >::GetLineD(int n) const
|
---|
| 170 | {
|
---|
| 171 | int i;
|
---|
| 172 | if ((n < 0) || (n >= (int)(mMap->NbPixels()) ))
|
---|
| 173 | for(i=0; i<8; i++) mRet[i] = 0.;
|
---|
| 174 | else {
|
---|
| 175 | double teta,phi;
|
---|
| 176 | mMap->PixThetaPhi(n, teta, phi);
|
---|
| 177 | mRet[0] = n;
|
---|
| 178 | mRet[2] = mMap->PixVal(n).real(); mRet[3] = mMap->PixVal(n).imag();
|
---|
| 179 | mRet[1] = mRet[4] = sqrt(mRet[2]*mRet[2]+mRet[3]*mRet[3]);
|
---|
| 180 | mRet[5] = atan2(mRet[3], mRet[2]);
|
---|
| 181 | mRet[6] = teta; mRet[7] = phi;
|
---|
| 182 | }
|
---|
| 183 | return(mRet);
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | r_8* NTupInt_PixelMap< complex<double> >::GetLineD(int n) const
|
---|
| 187 | {
|
---|
| 188 | int i;
|
---|
| 189 | if ((n < 0) || (n >= (int)(mMap->NbPixels()) ))
|
---|
| 190 | for(i=0; i<8; i++) mRet[i] = 0.;
|
---|
| 191 | else {
|
---|
| 192 | double teta,phi;
|
---|
| 193 | mMap->PixThetaPhi(n, teta, phi);
|
---|
| 194 | mRet[0] = n;
|
---|
| 195 | mRet[2] = mMap->PixVal(n).real(); mRet[3] = mMap->PixVal(n).imag();
|
---|
| 196 | mRet[1] = mRet[4] = sqrt(mRet[2]*mRet[2]+mRet[3]*mRet[3]);
|
---|
| 197 | mRet[5] = atan2(mRet[3], mRet[2]);
|
---|
| 198 | mRet[6] = teta; mRet[7] = phi;
|
---|
| 199 | }
|
---|
| 200 | return(mRet);
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
| 205 | #pragma define_template NOMAdapter_PixelMap<r_4>
|
---|
| 206 | #pragma define_template NOMAdapter_PixelMap<r_8>
|
---|
| 207 | #pragma define_template NOMAdapter_PixelMap< complex<float> >
|
---|
| 208 | #pragma define_template NOMAdapter_PixelMap< complex<double> >
|
---|
| 209 | #pragma define_template NTupInt_PixelMap<r_4>
|
---|
| 210 | #pragma define_template NTupInt_PixelMap<r_8>
|
---|
| 211 | #pragma define_template NTupInt_PixelMap< complex<float> >
|
---|
| 212 | #pragma define_template NTupInt_PixelMap< complex<double> >
|
---|
| 213 | #endif
|
---|
| 214 |
|
---|
| 215 | #if defined(ANSI_TEMPLATES)
|
---|
| 216 | template class NOMAdapter_PixelMap<r_4>;
|
---|
| 217 | template class NOMAdapter_PixelMap<r_8>;
|
---|
| 218 | template class NOMAdapter_PixelMap< complex<float> >;
|
---|
| 219 | template class NOMAdapter_PixelMap< complex<double> >;
|
---|
| 220 | template class NTupInt_PixelMap<r_4>;
|
---|
| 221 | template class NTupInt_PixelMap<r_8>;
|
---|
| 222 | template class NTupInt_PixelMap< complex<float> >;
|
---|
| 223 | template class NTupInt_PixelMap< complex<double> >;
|
---|
| 224 | #endif
|
---|