Changeset 2621 in Sophya
- Timestamp:
- Sep 23, 2004, 10:38:41 AM (21 years ago)
- Location:
- trunk/SophyaLib/SkyMap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SkyMap/sphereecp.cc
r2620 r2621 15 15 _phi2 = 2*M_PI; 16 16 _outofmapidx = -99; 17 _outofmapnphi = 0; 18 _outofmapntet = 0; 17 19 _outofmappix = 0; 18 20 _outofmapval = 0; … … 31 33 _phi2 = 2*M_PI; 32 34 _outofmapidx = -99; 35 _outofmapnphi = 0; 36 _outofmapntet = 0; 33 37 _outofmappix = 0; 34 38 _outofmapval = 0; … … 46 50 _phi2 = 2*M_PI; 47 51 _outofmapidx = -99; 52 _outofmapnphi = 0; 53 _outofmapntet = 0; 48 54 _outofmappix = 0; 49 55 _outofmapval = 0; … … 67 73 _phi2 = phi2; 68 74 _outofmapidx = _pixels.Size()+659; 75 // Reza, 23 sep 2004 76 // pour des cartes partielles, et des pixels sur la sphere, mais 77 // en dehors de la couverture, on code le numero de tranche en theta, 78 // compte a partir de theta=0,phi=0 + _outofmapidx 79 // theta -> idx = _outofmapidx + theta/_dtheta*_outofmapnphi + _outofmapntet 80 _outofmapntet = 0; 69 81 _outofmappix = 0; 70 82 _outofmapval = 0; 71 83 _dtheta = (_theta2-_theta1)/ntet; 72 84 _dphi = (_phi2-_phi1)/nphi; 85 86 _outofmapntet = M_PI/_dtheta; 87 _outofmapnphi = 2*M_PI/_dphi; 73 88 } 74 89 … … 83 98 _phi2 = a._phi2; 84 99 _outofmapidx = a._outofmapidx; 100 _outofmapnphi = a._outofmapnphi; 101 _outofmapntet = a._outofmapntet; 85 102 _outofmappix = a._outofmappix; 86 103 _outofmapval = a._outofmapval; … … 99 116 _phi2 = a._phi2; 100 117 _outofmapidx = a._outofmapidx; 118 _outofmapnphi = a._outofmapnphi; 119 _outofmapntet = a._outofmapntet; 101 120 _outofmappix = a._outofmappix; 102 121 _outofmapval = a._outofmapval; … … 131 150 T& SphereECP<T>::PixVal(int_4 k) 132 151 { 133 if ((_partial) && (k==_outofmapidx)) return _outofmappix; 152 // On pourrait etre plus strict en demandant aussi k<_outofmapidx+_outofmapnphi*_outofmapntet (Reza 23/09/04) 153 if ((_partial) && (k>=_outofmapidx)) return _outofmappix; 134 154 if((k < 0) || (k >= _pixels.Size()) ) 135 155 throw RangeCheckError("SphereECP::PIxVal() Pixel index out of range"); … … 140 160 T const& SphereECP<T>::PixVal(int_4 k) const 141 161 { 142 if ((_partial) && (k==_outofmapidx)) return _outofmapval; 162 // On pourrait etre plus strict en demandant aussi k<_outofmapidx+_outofmapnphi*_outofmapntet (Reza 23/09/04) 163 if ((_partial) && (k>=_outofmapidx)) return _outofmapval; 143 164 if((k < 0) || (k >= _pixels.Size()) ) 144 165 throw RangeCheckError("SphereECP::PIxVal() Pixel index out of range"); … … 165 186 if (_partial) { 166 187 if ( (theta < _theta1) || (theta > _theta2) || 167 (phi < _phi1) || (phi > _phi2) ) return _outofmapidx ;188 (phi < _phi1) || (phi > _phi2) ) return _outofmapidx+theta/_dtheta*_outofmapnphi+phi/_dphi; 168 189 } 169 190 int_4 it = (theta-_theta1)/_dtheta; … … 175 196 void SphereECP<T>::PixThetaPhi(int_4 k, double& theta, double& phi) const 176 197 { 177 if ((_partial) && (k ==_outofmapidx)) {178 theta = M_PI;179 phi = 2*M_PI;198 if ((_partial) && (k>=_outofmapidx)) { 199 theta = (((k-_outofmapidx) / _outofmapnphi)+0.5)*_dtheta; 200 phi = (((k-_outofmapidx) % _outofmapnphi)+0.5)*_dphi;; 180 201 return; 181 202 } … … 185 206 int_4 it = k / _pixels.SizeX(); 186 207 int_4 jp = k % _pixels.SizeX(); 187 theta = _theta1+ it*_dtheta;188 phi = _phi1* jp*_dphi;208 theta = _theta1+(it+0.5)*_dtheta; 209 phi = _phi1*(jp+0.5)*_dphi; 189 210 return; 190 211 } … … 200 221 double SphereECP<T>::PixSolAngle(int_4 k) const 201 222 { 202 if ((k < 0) || (k >= _pixels.Size())) return (_dtheta*_dphi); 223 if ((_partial) && (k>=_outofmapidx)) { 224 double theta = (((k-_outofmapidx) / _outofmapnphi)+0.5)*_dtheta; 225 return (_dtheta*_dphi*sin(theta)); 226 } 227 if((k < 0) || (k >= _pixels.Size()) ) 228 throw RangeCheckError("SphereECP::PixSolAngle(int_4 k) Pixel index out of range"); 229 203 230 int_4 it = k / _pixels.SizeX(); 204 231 double theta = _theta1+it*_dtheta; … … 229 256 _dtheta = (_theta2-_theta1)/m; 230 257 _dphi = (_phi2-_phi1)/mphi; 258 259 _outofmapntet = M_PI/_dtheta; 260 _outofmapnphi = 2*M_PI/_dphi; 231 261 return; 232 262 } … … 245 275 throw RangeCheckError("SphereECP::GetThetaSlice() theta index out of range"); 246 276 247 theta = _theta1 + index*_dtheta;277 theta = _theta1 + (index+0.5)*_dtheta; 248 278 int_4 nphit = 2.*M_PI/_dphi; 249 279 phi.ReSize(nphit); … … 252 282 int_4 i; 253 283 for(i=0; i<ioff; i++) { 254 phi(i) = _phi1 + (i-ioff )*_dphi;284 phi(i) = _phi1 + (i-ioff+0.5)*_dphi; 255 285 value(i) = _outofmapval; 256 286 } 257 287 for(i=ioff; i<ioff+_pixels.SizeX(); i++) { 258 phi(i) = _phi1 + (i-ioff )*_dphi;288 phi(i) = _phi1 + (i-ioff+0.5)*_dphi; 259 289 value(i) = _pixels(i-ioff,index,0); 260 290 } 261 291 for(i=ioff+_pixels.SizeX(); i<nphit; i++) { 262 phi(i) = _phi1 + (i-ioff )*_dphi;292 phi(i) = _phi1 + (i-ioff+0.5)*_dphi; 263 293 value(i) = _outofmapval; 264 294 } … … 273 303 throw RangeCheckError("SphereECP::GetThetaSlice() theta index out of range"); 274 304 275 theta = _theta1 + index*_dtheta;305 theta = _theta1 + (index+0.5)*_dtheta; 276 306 int_4 ioff = _phi1/_dphi; 277 phi0 = _phi1 - ioff*_dphi;307 phi0 = _phi1 - (ioff-0.5)*_dphi; 278 308 279 309 int_4 nphit = 2.*M_PI/_dphi; … … 283 313 int_4 i; 284 314 for(i=0; i<ioff; i++) { 285 pixidx(i) = _outofmapidx;315 pixidx(i) = _outofmapidx+theta/_dtheta*_outofmapnphi+phi0/_dphi+i; 286 316 value(i) = _outofmapval; 287 317 } … … 291 321 } 292 322 for(i=ioff+_pixels.SizeX(); i<nphit; i++) { 293 pixidx(i) = _outofmapidx;323 pixidx(i) = _outofmapidx+theta/_dtheta*_outofmapnphi+phi0/_dphi+i; 294 324 value(i) = _outofmapval; 295 325 } … … 322 352 _phi2 = a._phi2; 323 353 _outofmapidx = a._outofmapidx; 354 _outofmapnphi = a._outofmapnphi; 355 _outofmapntet = a._outofmapntet; 324 356 _outofmappix = a._outofmappix; 325 357 _outofmapval = a._outofmapval; -
trunk/SophyaLib/SkyMap/sphereecp.h
r2610 r2621 132 132 TArray<T> _pixels; 133 133 int_4 _outofmapidx; 134 int_4 _outofmapnphi; 135 int_4 _outofmapntet; 134 136 T _outofmappix; 135 137 T _outofmapval;
Note:
See TracChangeset
for help on using the changeset viewer.