[2615] | 1 | #include "sopnamsp.h"
|
---|
[764] | 2 | #include "localmap.h"
|
---|
| 3 | #include "smathconst.h"
|
---|
| 4 | #include <complex>
|
---|
[809] | 5 | #include "fiondblock.h"
|
---|
[764] | 6 |
|
---|
| 7 | #include <string.h>
|
---|
[2322] | 8 | #include <iostream>
|
---|
[2013] | 9 | #include "timing.h"
|
---|
[764] | 10 |
|
---|
| 11 |
|
---|
[1217] | 12 | /*!
|
---|
| 13 | \class SOPHYA::LocalMap
|
---|
[2290] | 14 | \ingroup SkyMap
|
---|
[2013] | 15 | A local map is a 2 dimensional matrix, with ny rows and nx columns.
|
---|
[2290] | 16 | The local map has a spatial origin with spherical coordinates (theta0, phi0), mapped to pixel(x0, y0). Default value of (x0, y0) is middle of the map, center of pixel(nx/2, ny/2).
|
---|
| 17 |
|
---|
[2013] | 18 | Each pixel(ip, it) is defined by its "phi-like" index ip (column
|
---|
| 19 | index in the matrix) and its "theta-like" index it (row index in
|
---|
| 20 | the matrix). Index ip is associated with x-axis in a map-coordinate
|
---|
| 21 | system ; index it is associated with y-axis in the same map-coordinate system.
|
---|
| 22 |
|
---|
[2290] | 23 | The map is supposed to lie in a plan tangent to the celestial sphere
|
---|
| 24 | at its origin, with spherical coordinates (theta0, phi0), whose pixel
|
---|
| 25 | numbers are (x0,y0) in the local map as indicated above. The aperture of the map is defined by two values of angles, angleX and angleY, covered respectively by all the pixels in x direction and all the pixels in y direction.
|
---|
[1217] | 26 |
|
---|
[2013] | 27 | Each pixel has angleX/nx and angleY/ny, as angle extensions. So, in
|
---|
| 28 | map-coordinate system the pixel (i,j) has following coordinates :
|
---|
| 29 |
|
---|
| 30 | x = (i-x0)*angleX/nx
|
---|
| 31 |
|
---|
| 32 | y = (j-y0)*angleY/ny
|
---|
[1217] | 33 |
|
---|
[2013] | 34 | (angles in radians)
|
---|
| 35 |
|
---|
[2290] | 36 | The projection (method : ProjectionToSphere() ) of the map onto a
|
---|
[2013] | 37 | sphere is made by the following procedure :
|
---|
| 38 |
|
---|
| 39 | the sphere is supposed to have radius=1. The map is
|
---|
[2290] | 40 | considered to be tangent to the sphere, at a point with (theta0, phi0)
|
---|
[2013] | 41 | spherical coodinates. A reference coordinate system (plane-coordinate
|
---|
[2290] | 42 | system) , is chosen with respect to the plane of the map with reference axes :
|
---|
[2013] | 43 |
|
---|
[2290] | 44 | x-axis : vector tangent to a parallel at (theta0, phi0) on the sphere
|
---|
[2013] | 45 | (components in "3-dim cartesian system : -sin(phi0) ; cos(phi0) ; 0)
|
---|
| 46 |
|
---|
| 47 | z-axis : vector-radius with 3-dim cartesian cordinates :
|
---|
| 48 | sin(theta0)*cos(phi0) ; sin(theta0*sin(phi0) ; cos(theta0)
|
---|
| 49 |
|
---|
[2290] | 50 | y-axis : z-axis^x-axis : tangent to the meridian at (theta0, phi0)
|
---|
[2013] | 51 |
|
---|
[2290] | 52 |
|
---|
[2013] | 53 | note that the map-coordinate system may be rotated with respect to
|
---|
| 54 | plane-coordinate system (parameter "angle" below).
|
---|
| 55 |
|
---|
| 56 | the projection of a map pixel is defined as the intersection of
|
---|
| 57 | the vector-radius, from sphere center to the pixel defined by
|
---|
| 58 | his coordinates in the plane-coordinate system (computed from x,y
|
---|
| 59 | above, with eventual rotation), with the sphere.
|
---|
[2290] | 60 |
|
---|
| 61 | In order to make an instance of this class available, the user must either use the standard constructor LocalMap() (as well as the "full" constructor LocalMap() ) or use the "partial" constructor LocalMap() followed by call to SetSize() and SetOrigin() (for fixing links between the map and the celestial sphere.
|
---|
| 62 |
|
---|
| 63 | Example :
|
---|
| 64 |
|
---|
| 65 | \verbatim
|
---|
| 66 | LocalMap<r_4> lcm(300, 600, 10.,20., 90.,0.); // full cstr.
|
---|
| 67 | \endverbatim
|
---|
| 68 |
|
---|
| 69 | defining a local map 300X600 pixels, representing a sphere portion of angular apertures 10 degres x 20 degres, with map center located on the equator, is equivalent to :
|
---|
| 70 |
|
---|
| 71 | \verbatim
|
---|
| 72 | LocalMap<r_4> lcm(300, 600); // partial cstr.
|
---|
| 73 | lcm.SetSize(10., 20.);
|
---|
| 74 | lcm.SetOrigin(90., 0.);
|
---|
| 75 | \endverbatim
|
---|
| 76 |
|
---|
| 77 | as well as :
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | \verbatim
|
---|
| 81 | LocalMap<r_4> lcm(300, 600, 10.,20., 90.,0., 0, 0); // full cstr.
|
---|
| 82 | \endverbatim
|
---|
| 83 |
|
---|
| 84 | (same map, but with origin of coordinates at pixel (0,0) instead of (150, 300) as it was implicit above)
|
---|
| 85 |
|
---|
| 86 | is equivalent to :
|
---|
| 87 |
|
---|
| 88 | \verbatim
|
---|
| 89 | LocalMap<r_4> lcm(300, 600);
|
---|
| 90 | lcm.SetSize(10., 20.);
|
---|
| 91 | lcm.SetOrigin(90., 0., 0,0);
|
---|
| 92 | \endverbatim
|
---|
| 93 |
|
---|
| 94 |
|
---|
[1217] | 95 | */
|
---|
[764] | 96 | template<class T>
|
---|
[979] | 97 | LocalMap<T>::LocalMap() : pixels_()
|
---|
[764] | 98 | {
|
---|
| 99 | InitNul();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
[2198] | 102 | //! partial constructor of the local map
|
---|
[2290] | 103 | /*! \fn void SOPHYA::LocalMap::LocalMap(int_4 nx, int_4 ny)
|
---|
[2198] | 104 | \param nx : number of pixels in x direction
|
---|
| 105 | \param ny : number of pixels in y direction
|
---|
| 106 |
|
---|
[2290] | 107 | must be followed by calls to the methods SetSize() and SetOrigin() in order the object become usable
|
---|
[2198] | 108 |
|
---|
| 109 | */
|
---|
| 110 | template<class T>
|
---|
| 111 | LocalMap<T>::LocalMap(int_4 nx, int_4 ny)
|
---|
| 112 | {
|
---|
| 113 | InitNul();
|
---|
| 114 | ReSize(nx, ny);
|
---|
| 115 | // nSzX_ = nx;
|
---|
| 116 | // nSzY_ = ny;
|
---|
| 117 | // nPix_= nx*ny;
|
---|
| 118 | // pixels_.ReSize(ny,nx);
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[2013] | 121 | //! full constructor of the local map
|
---|
[2290] | 122 | /*! \fn void SOPHYA::LocalMap:::LocalMap(int_4 nx, int_4 ny, double angleX,double angleY, double theta0,double phi0,int_4 x0,int_4 y0,double angle)
|
---|
[2013] | 123 | \param nx : number of pixels in x direction
|
---|
| 124 | \param ny : number of pixels in y direction
|
---|
| 125 | \param angleX : total angle aperture in x direction (degrees)
|
---|
| 126 | \param angleY : total angle aperture in y direction (degrees)
|
---|
| 127 | \param theta0,phi0 : spherical coordinates of reference point at which
|
---|
| 128 | the map is considered to be tangent to the sphere
|
---|
[2290] | 129 | \param x0, y0 : coordinates (in pixels) of the reference point just defined
|
---|
[2013] | 130 | \param angle : angle (degrees) of the rotation between x-axis of
|
---|
| 131 | map-coordinate system) and the tangent to parallel on
|
---|
| 132 | the sphere (default : 0.).
|
---|
| 133 | */
|
---|
[764] | 134 | template<class T>
|
---|
[2013] | 135 | LocalMap<T>::LocalMap(int_4 nx, int_4 ny, double angleX,double angleY, double theta0,double phi0,int_4 x0,int_4 y0,double angle)
|
---|
[764] | 136 | {
|
---|
| 137 | InitNul();
|
---|
[2198] | 138 | // nSzX_ = nx;
|
---|
| 139 | // nSzY_ = ny;
|
---|
| 140 | // nPix_= nx*ny;
|
---|
| 141 | // pixels_.ReSize(ny,nx);
|
---|
| 142 | ReSize(nx, ny);
|
---|
[2013] | 143 | SetSize(angleX, angleY);
|
---|
| 144 | SetOrigin(theta0, phi0, x0, y0, angle);
|
---|
[764] | 145 | }
|
---|
| 146 |
|
---|
[2290] | 147 | // void SOPHYA::LocalMap::LocalMap(int_4 nx, int_4 ny, double angleX,double angleY, double theta0,double phi0, double angle)
|
---|
[2013] | 148 |
|
---|
| 149 | //! standard constructor of the local map
|
---|
[2290] | 150 | /*! \fn void SOPHYA::LocalMap::LocalMap(int_4 nx, int_4 ny, double angleX,double angleY, double theta0,double phi0, double angle)
|
---|
[2013] | 151 | \param nx : number of pixels in x direction
|
---|
| 152 | \param ny : number of pixels in y direction
|
---|
| 153 | \param angleX : total angle aperture in x direction (degrees)
|
---|
| 154 | \param angleY : total angle aperture in y direction (degrees)
|
---|
| 155 | \param theta0,phi0 : spherical coordinates of reference point at which
|
---|
| 156 | the map is considered to be tangent to the sphere
|
---|
| 157 | \param angle : angle (degrees) of the rotation between x-axis of
|
---|
| 158 | map-coordinate system) and the tangent to parallel on
|
---|
| 159 | the sphere (default : 0.).
|
---|
| 160 | */
|
---|
[764] | 161 | template<class T>
|
---|
[2013] | 162 | LocalMap<T>::LocalMap(int_4 nx, int_4 ny, double angleX,double angleY, double theta0,double phi0, double angle)
|
---|
| 163 | {
|
---|
| 164 | InitNul();
|
---|
[2198] | 165 | // nSzX_ = nx;
|
---|
| 166 | // nSzY_ = ny;
|
---|
| 167 | // nPix_= nx*ny;
|
---|
| 168 | // pixels_.ReSize(ny,nx);
|
---|
| 169 | ReSize(nx, ny);
|
---|
[2013] | 170 | SetSize(angleX, angleY);
|
---|
| 171 | SetOrigin(theta0, phi0, angle);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | //! copy constructor
|
---|
[2290] | 175 | /*! \fn void SOPHYA::LocalMap::LocalMap(const LocalMap<T>& lm, bool share)
|
---|
[2013] | 176 | \param share : if true, share data. If false copy data
|
---|
| 177 | */
|
---|
| 178 | template<class T>
|
---|
[764] | 179 | LocalMap<T>::LocalMap(const LocalMap<T>& lm, bool share)
|
---|
| 180 | : pixels_(lm.pixels_, share)
|
---|
| 181 | {
|
---|
| 182 |
|
---|
| 183 | if(lm.mInfo_) mInfo_= new DVList(*lm.mInfo_);
|
---|
[908] | 184 | recopierVariablesSimples(lm);
|
---|
[764] | 185 | }
|
---|
| 186 |
|
---|
[2013] | 187 | //! copy constructor
|
---|
[2290] | 188 | /*! \fn void SOPHYA::LocalMap::LocalMap(const LocalMap<T>& lm)
|
---|
[2013] | 189 | \warning datas are \b SHARED with \b lm.
|
---|
| 190 | \sa TMatrix::TMatrix(const TMatrix<T>&)
|
---|
| 191 | */
|
---|
[908] | 192 | template<class T>
|
---|
| 193 | LocalMap<T>::LocalMap(const LocalMap<T>& lm)
|
---|
| 194 | : pixels_(lm.pixels_)
|
---|
| 195 |
|
---|
| 196 | {
|
---|
| 197 |
|
---|
| 198 | if(lm.mInfo_) mInfo_= new DVList(*lm.mInfo_);
|
---|
| 199 | recopierVariablesSimples(lm);
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[2290] | 202 | //! destructor
|
---|
| 203 | /*! \fn void SOPHYA::LocalMap::~LocalMap()
|
---|
| 204 |
|
---|
| 205 | */
|
---|
[764] | 206 | template<class T>
|
---|
[2013] | 207 | LocalMap<T>::~LocalMap() {;}
|
---|
[764] | 208 |
|
---|
| 209 |
|
---|
| 210 |
|
---|
[1217] | 211 | /*! \fn void SOPHYA::LocalMap::ReSize(int_4 nx, int_4 ny)
|
---|
[764] | 212 |
|
---|
[1217] | 213 | Resize storage area for pixels
|
---|
[2290] | 214 | \param nx
|
---|
| 215 | \param ny new pixel numbers
|
---|
[1217] | 216 | */
|
---|
[764] | 217 | template<class T>
|
---|
| 218 | void LocalMap<T>::ReSize(int_4 nx, int_4 ny)
|
---|
| 219 | {
|
---|
[2013] | 220 | // angles par pixel, en radians
|
---|
| 221 | deltaPhi_ *= nSzX_/nx;
|
---|
| 222 | deltaTheta_ *= nSzY_/ny;
|
---|
| 223 |
|
---|
[764] | 224 | nSzX_ = nx;
|
---|
| 225 | nSzY_ = ny;
|
---|
| 226 | nPix_= nx*ny;
|
---|
[2013] | 227 | pixels_.ReSize(ny,nx);
|
---|
[2198] | 228 | pixelSized_ = true;
|
---|
[764] | 229 | }
|
---|
| 230 |
|
---|
[979] | 231 | ////////////////////////// methodes de copie/share
|
---|
| 232 |
|
---|
[908] | 233 | template<class T>
|
---|
[979] | 234 | void LocalMap<T>::CloneOrShare(const LocalMap<T>& a)
|
---|
| 235 | {
|
---|
| 236 | recopierVariablesSimples(a);
|
---|
| 237 | pixels_.CloneOrShare(a.pixels_);
|
---|
[1419] | 238 | if (mInfo_) {delete mInfo_; mInfo_ = NULL;}
|
---|
| 239 | if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
|
---|
[979] | 240 | }
|
---|
[1419] | 241 | template<class T>
|
---|
| 242 | void LocalMap<T>::Share(const LocalMap<T>& a)
|
---|
| 243 | {
|
---|
| 244 | recopierVariablesSimples(a);
|
---|
| 245 | pixels_.Share(a.pixels_);
|
---|
| 246 | if (mInfo_) {delete mInfo_; mInfo_ = NULL;}
|
---|
| 247 | if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
|
---|
| 248 | }
|
---|
[979] | 249 |
|
---|
| 250 | template<class T>
|
---|
| 251 | LocalMap<T>& LocalMap<T>::CopyElt(const LocalMap<T>& a)
|
---|
| 252 | {
|
---|
| 253 | if (NbPixels() < 1)
|
---|
| 254 | throw RangeCheckError("LocalMap<T>::CopyElt(const LocalMap<T>& ) - Not Allocated Array ! ");
|
---|
| 255 | if (NbPixels() != a.NbPixels())
|
---|
| 256 | throw(SzMismatchError("LocalMap<T>::CopyElt(const LocalMap<T>&) SizeMismatch")) ;
|
---|
| 257 | recopierVariablesSimples(a);
|
---|
| 258 | int k;
|
---|
[2013] | 259 | pixels_ = a.pixels_;
|
---|
[979] | 260 | return(*this);
|
---|
| 261 |
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | template<class T>
|
---|
[908] | 265 | LocalMap<T>& LocalMap<T>::Set(const LocalMap<T>& a)
|
---|
| 266 | {
|
---|
| 267 | if (this != &a)
|
---|
| 268 | {
|
---|
[979] | 269 | if (a.NbPixels() < 1)
|
---|
| 270 | throw RangeCheckError("LocalMap<T>::Set(a ) - Array a not allocated ! ");
|
---|
| 271 | if (NbPixels() < 1) CloneOrShare(a);
|
---|
| 272 | else CopyElt(a);
|
---|
[908] | 273 | if (mInfo_) delete mInfo_;
|
---|
| 274 | mInfo_ = NULL;
|
---|
| 275 | if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
|
---|
| 276 | }
|
---|
| 277 | return(*this);
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 |
|
---|
[1217] | 281 | /*! \fn int_4 SOPHYA::LocalMap::NbPixels() const
|
---|
| 282 |
|
---|
| 283 | \return number of pixels
|
---|
| 284 | */
|
---|
[764] | 285 | template<class T>
|
---|
| 286 | int_4 LocalMap<T>::NbPixels() const
|
---|
| 287 | {
|
---|
| 288 | return(nPix_);
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[1217] | 291 | /*! \fn T& SOPHYA::LocalMap::PixVal(int_4 k)
|
---|
| 292 |
|
---|
| 293 | \return value of pixel with index k
|
---|
| 294 | */
|
---|
[764] | 295 | template<class T>
|
---|
| 296 | T& LocalMap<T>::PixVal(int_4 k)
|
---|
| 297 | {
|
---|
| 298 | if((k < 0) || (k >= nPix_))
|
---|
| 299 | {
|
---|
[2013] | 300 | throw RangeCheckError("LocalMap::PIxVal Pixel index out of range ");
|
---|
[764] | 301 | }
|
---|
[2013] | 302 | //
|
---|
| 303 | int_4 i,j;
|
---|
| 304 | Getij(k,i,j);
|
---|
| 305 | return(pixels_(j,i));
|
---|
| 306 |
|
---|
| 307 | //
|
---|
[764] | 308 | }
|
---|
| 309 |
|
---|
[1217] | 310 | /*! \fn T const& SOPHYA::LocalMap::PixVal(int_4 k) const
|
---|
| 311 | const version of previous method
|
---|
| 312 | */
|
---|
[764] | 313 | template<class T>
|
---|
| 314 | T const& LocalMap<T>::PixVal(int_4 k) const
|
---|
| 315 | {
|
---|
| 316 | if((k < 0) || (k >= nPix_))
|
---|
| 317 | {
|
---|
[2013] | 318 | throw RangeCheckError("LocalMap::PIxVal Pixel index out of range ");
|
---|
[764] | 319 | }
|
---|
[2013] | 320 | //
|
---|
| 321 | int_4 i,j;
|
---|
| 322 | Getij(k,i,j);
|
---|
| 323 | return(pixels_(j,i));
|
---|
[764] | 324 | }
|
---|
| 325 |
|
---|
[1217] | 326 | /*! \fn bool SOPHYA::LocalMap::ContainsSph(double theta, double phi) const
|
---|
| 327 | \return true if teta,phi in map
|
---|
[1431] | 328 | <b> Not yet implemented </b>
|
---|
[1217] | 329 | */
|
---|
[764] | 330 | template<class T>
|
---|
| 331 | bool LocalMap<T>::ContainsSph(double theta, double phi) const
|
---|
| 332 | {
|
---|
| 333 | // $CHECK$ Reza 11/11/99 - A modifier
|
---|
[1431] | 334 | throw NotAvailableOperation("LocalMap<T>::ContainsSph() - Not yet implemented !");
|
---|
| 335 | return(true);
|
---|
[764] | 336 | }
|
---|
| 337 |
|
---|
[1217] | 338 | /*! \fn int_4 SOPHYA::LocalMap::PixIndexSph(double theta,double phi) const
|
---|
| 339 |
|
---|
[2013] | 340 | angles in radians
|
---|
[1217] | 341 | \return index of the pixel with spherical coordinates (theta,phi)
|
---|
| 342 | */
|
---|
[764] | 343 | template<class T>
|
---|
| 344 | int_4 LocalMap<T>::PixIndexSph(double theta,double phi) const
|
---|
| 345 | {
|
---|
| 346 | int_4 i,j;
|
---|
[2013] | 347 |
|
---|
[2198] | 348 | if (! LocalMap_isDone()) initializationError();
|
---|
[2013] | 349 | double csTheta = cos(theta);
|
---|
| 350 | double snTheta = sin(theta);
|
---|
| 351 | double csPhi = cos(phi);
|
---|
| 352 | double snPhi = sin(phi);
|
---|
| 353 | double csPhiMPhiC = cos (phi - phiC_);
|
---|
| 354 | double snPhiMPhiC = sin (phi - phiC_);
|
---|
| 355 | // le point sur la sphere est note M.
|
---|
| 356 | // intersection P de OM avec le plan de la carte (tangent en C)
|
---|
| 357 | double denom = snTheta*snthC_*csPhiMPhiC + csTheta*csthC_;
|
---|
| 358 | if ( denom == 0.)
|
---|
[764] | 359 | {
|
---|
| 360 | }
|
---|
[2013] | 361 | double lambda = 1./denom;
|
---|
| 362 | // coordonnes du point d'intersection P dans le repere lie au plan
|
---|
[764] | 363 |
|
---|
[2013] | 364 | double XP = lambda*snTheta*snPhiMPhiC;
|
---|
| 365 | double YP = lambda*snTheta*csthC_*csPhiMPhiC;
|
---|
[764] | 366 |
|
---|
[2013] | 367 | // coordonnees dans le repere lie a la carte (eventuellement tourne par
|
---|
| 368 | // rapport au precedent.
|
---|
[764] | 369 |
|
---|
[2013] | 370 | double X = XP*cosAngle_ + YP*sinAngle_;
|
---|
| 371 | double Y = -XP*sinAngle_ + YP*cosAngle_;
|
---|
| 372 |
|
---|
| 373 | // en unites de pixels
|
---|
| 374 |
|
---|
| 375 | X /= deltaPhi_;
|
---|
| 376 | Y /= deltaTheta_;
|
---|
| 377 |
|
---|
| 378 |
|
---|
[764] | 379 | double xmin= -x0_-0.5;
|
---|
| 380 | double xmax= xmin+nSzX_;
|
---|
[2052] | 381 | if((X > xmax) || (X < xmin)) {
|
---|
| 382 | if (exc_outofmap_) throw RangeCheckError("LocalMap<T>::PixIndexSph() - Out of Map Theta/Phi (X) ");
|
---|
| 383 | else return(-1);
|
---|
| 384 | }
|
---|
[764] | 385 | double xcurrent= xmin;
|
---|
| 386 | for(i = 0; i < nSzX_; i++ )
|
---|
| 387 | {
|
---|
| 388 | xcurrent += 1.;
|
---|
[2013] | 389 | if( X < xcurrent ) break;
|
---|
[764] | 390 | }
|
---|
| 391 | double ymin= -y0_-0.5;
|
---|
| 392 | double ymax= ymin+nSzY_;
|
---|
[2052] | 393 | if((Y > ymax) || (Y < ymin)) {
|
---|
| 394 | if (exc_outofmap_) throw RangeCheckError("LocalMap<T>::PixIndexSph() - Out of Map Theta/Phi (Y) ");
|
---|
| 395 | else return(-1);
|
---|
| 396 | }
|
---|
[764] | 397 | double ycurrent= ymin;
|
---|
| 398 | for(j = 0; j < nSzY_; j++ )
|
---|
| 399 | {
|
---|
| 400 | ycurrent += 1.;
|
---|
[2013] | 401 | if( Y < ycurrent ) break;
|
---|
[764] | 402 | }
|
---|
| 403 | return (j*nSzX_+i);
|
---|
| 404 | }
|
---|
| 405 |
|
---|
[1217] | 406 | /*! \fn void SOPHYA::LocalMap::PixThetaPhi(int_4 k,double& theta,double& phi) const
|
---|
| 407 |
|
---|
| 408 | \return (theta, phi) coordinates of pixel with index k
|
---|
| 409 | */
|
---|
[2013] | 410 |
|
---|
| 411 |
|
---|
[764] | 412 | template<class T>
|
---|
| 413 | void LocalMap<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const
|
---|
| 414 | {
|
---|
| 415 |
|
---|
| 416 | int_4 i,j;
|
---|
| 417 | Getij(k,i,j);
|
---|
| 418 |
|
---|
[2013] | 419 | PixThetaPhi(i,j, theta, phi);
|
---|
| 420 |
|
---|
[764] | 421 | }
|
---|
| 422 |
|
---|
[2013] | 423 | /*! \fn void SOPHYA::LocalMap::PixThetaPhi(int_4 ip,int_4 it, double& theta,double& phi) const
|
---|
| 424 |
|
---|
| 425 |
|
---|
| 426 | \return (theta, phi) coordinates of pixel of map with indices (ip,it) corresponding to x and y directions
|
---|
| 427 |
|
---|
[2290] | 428 | \param ip phi-like index
|
---|
| 429 | \param it theta-like index
|
---|
[2013] | 430 | */
|
---|
| 431 |
|
---|
| 432 | template<class T>
|
---|
| 433 | void LocalMap<T>::PixThetaPhi(int_4 ip,int_4 it, double& theta,double& phi) const
|
---|
| 434 | {
|
---|
| 435 | double XP, YP, ZP;
|
---|
| 436 | PixToSphereC(ip,it,XP,YP,ZP);
|
---|
| 437 |
|
---|
| 438 | theta = acos(ZP);
|
---|
| 439 | phi = atan2(YP, XP);
|
---|
| 440 | while (phi < 0.) phi += 2.*Pi;
|
---|
| 441 |
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 |
|
---|
| 445 |
|
---|
| 446 |
|
---|
[1217] | 447 | /*! \fn T SOPHYA::LocalMap::SetPixels(T v)
|
---|
| 448 |
|
---|
| 449 | Set all pixels to value v
|
---|
| 450 | */
|
---|
[764] | 451 | template <class T>
|
---|
| 452 | T LocalMap<T>::SetPixels(T v)
|
---|
| 453 | {
|
---|
[2013] | 454 | pixels_ = v;
|
---|
[764] | 455 | return(v);
|
---|
| 456 | }
|
---|
| 457 |
|
---|
[1217] | 458 | /*! \fn double SOPHYA::LocalMap::PixSolAngle(int_4 k) const
|
---|
[2290] | 459 | Pixel Solid angle of pixel k (steradians).
|
---|
| 460 | For the moment, all the pixels are considered to have the same size in (theta, phi). So the parameter k is dummy.
|
---|
[2013] | 461 |
|
---|
[1217] | 462 | */
|
---|
[764] | 463 | template<class T>
|
---|
| 464 | double LocalMap<T>::PixSolAngle(int_4 k) const
|
---|
| 465 | {
|
---|
[2013] | 466 | double XP, YP, ZP;
|
---|
[764] | 467 | int_4 i,j;
|
---|
| 468 | Getij(k,i,j);
|
---|
[2013] | 469 | PixToSphereC(i,j,XP,YP,ZP);
|
---|
[764] | 470 |
|
---|
[2013] | 471 | double theta = acos(ZP);
|
---|
[764] | 472 |
|
---|
[2013] | 473 |
|
---|
[764] | 474 |
|
---|
| 475 | // angle solide
|
---|
[2013] | 476 |
|
---|
| 477 | double sol= 2.* deltaPhi_*sin(theta)*sin(0.5*deltaTheta_);
|
---|
[764] | 478 | return sol;
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[2290] | 481 | /*! \fn void SOPHYA::LocalMap::PixToSphereC(int_4 ip, int_4 it, double& XP, double& YP, double& ZP) const
|
---|
[2013] | 482 |
|
---|
| 483 | projection of a pixel of map, onto the unity sphere ; result in cartesian coordinates.
|
---|
| 484 | */
|
---|
| 485 |
|
---|
| 486 | template<class T>
|
---|
| 487 | void LocalMap<T>::PixToSphereC(int_4 ip, int_4 it, double& XP, double& YP, double& ZP) const
|
---|
| 488 | {
|
---|
[2198] | 489 | if (! LocalMap_isDone()) initializationError();
|
---|
[2013] | 490 | double X= double(ip-x0_)* deltaPhi_;
|
---|
| 491 | double Y= double(it-y0_)*deltaTheta_;
|
---|
| 492 |
|
---|
| 493 | // situation dans le plan de reference tangent
|
---|
| 494 | double dx= X*cosAngle_-Y*sinAngle_;
|
---|
| 495 | double dy= X*sinAngle_+Y*cosAngle_;
|
---|
| 496 |
|
---|
| 497 | XP = XC_ - dx*snphC_ - dy*csthC_*csphC_;
|
---|
| 498 | YP = YC_ + dx*csphC_ - dy*csthC_*snphC_;
|
---|
| 499 | ZP = ZC_ + dy*snthC_;
|
---|
| 500 |
|
---|
| 501 | // on renormalise pour eviter les probleme de precision lors
|
---|
| 502 | // de la prise ulterieure de lignes trigonometriques
|
---|
| 503 | double norme = sqrt(XP*XP + YP*YP + ZP*ZP);
|
---|
| 504 | XP /= norme;
|
---|
| 505 | YP /= norme;
|
---|
| 506 | ZP /= norme;
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[1217] | 509 | /*! \fn void SOPHYA::LocalMap::SetOrigin(double theta0,double phi0,double angle)
|
---|
| 510 | set the referential of the map (angles in degrees)
|
---|
| 511 |
|
---|
[2290] | 512 | \param theta0
|
---|
| 513 | \param phi0 celestial coordinates attributed to center pixel: x0=siz_x/2, y0=siz_y/2
|
---|
| 514 | \param angle angle between map referential and plane-coordinate system (see class description)
|
---|
[1217] | 515 | */
|
---|
[764] | 516 | template<class T>
|
---|
| 517 | void LocalMap<T>::SetOrigin(double theta0,double phi0,double angle)
|
---|
| 518 | {
|
---|
[2013] | 519 | SetOrigin(theta0, phi0, nSzX_/2, nSzY_/2, angle);
|
---|
[764] | 520 | }
|
---|
| 521 |
|
---|
[1217] | 522 | /*! \fn void SOPHYA::LocalMap::SetOrigin(double theta0,double phi0,int_4 x0,int_4 y0,double angle)
|
---|
[2290] | 523 | set the referential of the map (angles in degrees)
|
---|
[1217] | 524 |
|
---|
[2290] | 525 | \param theta0
|
---|
| 526 | \param phi0 celestial coordinates attributed to center pixel: (x0,y0)
|
---|
| 527 | \param angle angle between map referential and plane-coordinate system (see class description)
|
---|
| 528 |
|
---|
[1217] | 529 | */
|
---|
[764] | 530 | template<class T>
|
---|
| 531 | void LocalMap<T>::SetOrigin(double theta0,double phi0,int_4 x0,int_4 y0,double angle)
|
---|
| 532 | {
|
---|
[2013] | 533 |
|
---|
| 534 | if ( theta0 < 0. || theta0 > 180. || phi0 < 0. || phi0 > 360. || angle < -90. || angle > 90.)
|
---|
| 535 | {
|
---|
[2052] | 536 | throw ParmError("LocalMap::SetOrigin angle out of range");
|
---|
[2013] | 537 | }
|
---|
| 538 | SetCoorC(theta0,phi0);
|
---|
| 539 | angleDegres_ = angle;
|
---|
| 540 | // en radians
|
---|
| 541 | angle_ = angle*Pi/180.;
|
---|
[764] | 542 | x0_= x0;
|
---|
| 543 | y0_= y0;
|
---|
[2013] | 544 | cosAngle_= cos(angle_);
|
---|
| 545 | sinAngle_= sin(angle_);
|
---|
[2198] | 546 |
|
---|
| 547 | if (originSet_)
|
---|
| 548 | {
|
---|
| 549 | cout << " WARNING: LocalMap<T>::SetOrigin() : reset origine of a local map which had already an origin " << endl;
|
---|
| 550 | }
|
---|
| 551 | originSet_ = true;
|
---|
[764] | 552 | }
|
---|
| 553 |
|
---|
[2013] | 554 | template<class T>
|
---|
| 555 | void LocalMap<T>::SetCoorC(double theta0, double phi0)
|
---|
| 556 | {
|
---|
| 557 |
|
---|
| 558 | thetaDegresC_ = theta0;
|
---|
| 559 | phiDegresC_ = phi0;
|
---|
| 560 |
|
---|
| 561 | // passage en radians
|
---|
| 562 | thetaC_= theta0*Pi/180.;
|
---|
| 563 | phiC_ = phi0*Pi/180.;
|
---|
| 564 | csthC_ = cos(thetaC_);
|
---|
| 565 | snthC_ = sin(thetaC_);
|
---|
| 566 | csphC_ = cos(phiC_);
|
---|
| 567 | snphC_ = sin(phiC_);
|
---|
| 568 | XC_ = snthC_*csphC_;
|
---|
| 569 | YC_ = snthC_*snphC_;
|
---|
| 570 | ZC_ = csthC_;
|
---|
| 571 | }
|
---|
| 572 |
|
---|
| 573 |
|
---|
| 574 | // angles en RADIANS
|
---|
| 575 | template<class T>
|
---|
| 576 | TMatrix<double> LocalMap<T>::CalculMatricePassage()
|
---|
| 577 | {
|
---|
| 578 | cout << " calcul matrice de passage " << endl;
|
---|
[2198] | 579 | if (! LocalMap_isDone()) initializationError();
|
---|
[2013] | 580 | TMatrix<double> passage(3,3);
|
---|
| 581 | double cos_th_axeZ;
|
---|
| 582 | double sin_th_axeZ;
|
---|
| 583 | double cos_phi_axeZ;
|
---|
| 584 | double sin_phi_axeZ;
|
---|
| 585 |
|
---|
| 586 | double cth,sth, cdeltaPhi, phi, cphi, sphi;
|
---|
| 587 |
|
---|
| 588 | if ( snthC_ <= 0.) // carte centree au pole
|
---|
| 589 | {
|
---|
| 590 | cos_th_axeZ = 1.;
|
---|
| 591 | sin_th_axeZ = 0.;
|
---|
| 592 | cos_phi_axeZ = 1.;
|
---|
| 593 | sin_phi_axeZ = 0.;
|
---|
| 594 |
|
---|
| 595 | }
|
---|
| 596 | else
|
---|
| 597 | {
|
---|
| 598 | cth = cosAngle_*snthC_;
|
---|
| 599 | double arg = 1.-cth*cth;
|
---|
| 600 | if (arg <= 0. ) // carte centree sur l'equateur, sans rotation
|
---|
| 601 | {
|
---|
| 602 | cos_th_axeZ = 1.;
|
---|
| 603 | sin_th_axeZ = 0.;
|
---|
| 604 | cos_phi_axeZ = csphC_;
|
---|
| 605 | sin_phi_axeZ = snphC_;
|
---|
| 606 | }
|
---|
| 607 | else
|
---|
| 608 | {
|
---|
| 609 | sth = sqrt(arg);
|
---|
| 610 | cdeltaPhi = -csthC_*cth/(snthC_*sth);
|
---|
| 611 | if (cdeltaPhi < -1. ) cdeltaPhi = -1.;
|
---|
| 612 | if (cdeltaPhi > 1. ) cdeltaPhi = 1.;
|
---|
| 613 | phi = phiC_ + acos( cdeltaPhi );
|
---|
| 614 |
|
---|
| 615 | cos_th_axeZ = cth;
|
---|
| 616 | sin_th_axeZ = sth;
|
---|
| 617 | cos_phi_axeZ = cos(phi);
|
---|
| 618 | sin_phi_axeZ = sin(phi);
|
---|
| 619 | }
|
---|
| 620 | }
|
---|
| 621 | passage(0,0) = snthC_*csphC_;
|
---|
| 622 | passage(1,0) = snthC_*snphC_;
|
---|
| 623 | passage(2,0) = csthC_;
|
---|
| 624 |
|
---|
| 625 | passage(0,2) = sin_th_axeZ*cos_phi_axeZ;
|
---|
| 626 | passage(1,2) = sin_th_axeZ*sin_phi_axeZ;
|
---|
| 627 | passage(2,2) = cos_th_axeZ;
|
---|
| 628 |
|
---|
| 629 | passage(0,1) = passage(1,2)*passage(2,0) - passage(2,2)*passage(1,0);
|
---|
| 630 | passage(1,1) = passage(2,2)*passage(0,0) - passage(0,2)*passage(2,0);
|
---|
| 631 | passage(2,1) = passage(0,2)*passage(1,0) - passage(1,2)*passage(0,0);
|
---|
| 632 |
|
---|
| 633 | // passage.Print(cout);
|
---|
| 634 | // cout << " fin calcul passage " << endl;
|
---|
| 635 |
|
---|
| 636 | return passage;
|
---|
| 637 |
|
---|
| 638 |
|
---|
| 639 | }
|
---|
| 640 |
|
---|
[1217] | 641 | /*! \fn void SOPHYA::LocalMap::SetSize(double angleX,double angleY)
|
---|
| 642 |
|
---|
| 643 | angle range of tthe map (angles in degrees)
|
---|
[2290] | 644 | \param angleX phi-like angle
|
---|
| 645 | \param angleX theta-like angle
|
---|
[1217] | 646 | */
|
---|
[764] | 647 | template<class T>
|
---|
| 648 | void LocalMap<T>::SetSize(double angleX,double angleY)
|
---|
| 649 | {
|
---|
[2198] | 650 | if (!pixelSized_) initializationError();
|
---|
| 651 |
|
---|
[2013] | 652 | if ( angleX <= 0. || angleX > 180. || angleY <= 0. || angleY > 180.)
|
---|
| 653 | {
|
---|
[2052] | 654 | throw ParmError("LocalMap::SetSize extension angle out of range");
|
---|
[2013] | 655 | }
|
---|
[764] | 656 |
|
---|
[2013] | 657 | angleDegresX_ = angleX;
|
---|
| 658 | angleDegresY_ = angleY;
|
---|
| 659 | // angles par pixel, en radians
|
---|
| 660 | cout << " taille x " << nSzX_ <<" taille y " << nSzY_ << endl;
|
---|
| 661 | deltaPhi_ = angleX*Pi/(180.*nSzX_);
|
---|
| 662 | deltaTheta_ = angleY*Pi/(180.*nSzY_);
|
---|
[2198] | 663 |
|
---|
| 664 | if (angleSized_)
|
---|
| 665 | {
|
---|
| 666 | cout << " WARNING LocalMap::SetSize ; angle resizing of an already sized local map " << endl;
|
---|
| 667 | }
|
---|
| 668 | angleSized_ = true;
|
---|
[764] | 669 |
|
---|
| 670 | }
|
---|
| 671 |
|
---|
[1217] | 672 |
|
---|
[2013] | 673 |
|
---|
| 674 | /*! \fn void SOPHYA::LocalMap::ProjectionToSphere(SphericalMap<T>& sphere) const
|
---|
| 675 |
|
---|
[1217] | 676 | Projection to a spherical map
|
---|
| 677 | */
|
---|
[764] | 678 | template<class T>
|
---|
[2013] | 679 | void LocalMap<T>::ProjectionToSphere(SphericalMap<T>& sphere) const
|
---|
[764] | 680 | {
|
---|
[2013] | 681 | double theta, phi;
|
---|
| 682 | int it, ip;
|
---|
| 683 | for (it = 0; it < nSzY_; it++)
|
---|
[764] | 684 | {
|
---|
[2013] | 685 | for (ip = 0; ip < nSzX_; ip++)
|
---|
| 686 | {
|
---|
| 687 | PixThetaPhi(ip,it, theta, phi);
|
---|
| 688 | sphere(theta,phi)= pixels_(it, ip);
|
---|
| 689 | }
|
---|
[764] | 690 | }
|
---|
| 691 | }
|
---|
[2013] | 692 |
|
---|
| 693 |
|
---|
| 694 |
|
---|
[764] | 695 | // Titre Private Methods
|
---|
| 696 | //++
|
---|
| 697 | template<class T>
|
---|
| 698 | void LocalMap<T>::InitNul()
|
---|
| 699 | //
|
---|
[2013] | 700 | // set attributes to zero
|
---|
[764] | 701 | //--
|
---|
| 702 | {
|
---|
[2198] | 703 |
|
---|
| 704 | pixelSized_ = false;
|
---|
| 705 | angleSized_ = false;
|
---|
| 706 | originSet_ = false;
|
---|
| 707 |
|
---|
[2013] | 708 | nSzX_ = 0;
|
---|
| 709 | nSzY_ = 0;
|
---|
| 710 | angleDegresX_ = 0.;
|
---|
| 711 | angleDegresY_ = 0.;
|
---|
| 712 | thetaDegresC_ = 0.;
|
---|
| 713 | phiDegresC_ = 0.;
|
---|
| 714 | x0_ = 0;
|
---|
| 715 | y0_ = 0;
|
---|
| 716 | angleDegres_ = 0.;
|
---|
| 717 |
|
---|
| 718 |
|
---|
[2198] | 719 |
|
---|
[2013] | 720 | nPix_ = 0;
|
---|
| 721 |
|
---|
| 722 | thetaC_ = 0.;
|
---|
| 723 | phiC_ = 0.;
|
---|
| 724 | csthC_ = 1.;
|
---|
| 725 | snthC_ = 0.;
|
---|
| 726 | csphC_ = 1.;
|
---|
| 727 | snphC_ = 0.;
|
---|
| 728 | XC_ = 0.;
|
---|
| 729 | YC_ = 0.;
|
---|
| 730 | ZC_ = 1.;
|
---|
| 731 |
|
---|
| 732 | angle_ = 0.;
|
---|
| 733 | cosAngle_ = 1.;
|
---|
| 734 | sinAngle_ = 0.;
|
---|
| 735 | deltaPhi_ = 0.;
|
---|
| 736 | deltaTheta_ =0.;
|
---|
[2052] | 737 | SetThrowExceptionWhenOutofMapFlag(false); // Genere des exceptions si theta-phi out of range
|
---|
[764] | 738 | }
|
---|
| 739 |
|
---|
[1217] | 740 |
|
---|
| 741 | /*! \fn void SOPHYA::LocalMap::Getij(int_4 k,int_4& i,int_4& j) const
|
---|
| 742 |
|
---|
| 743 | \return 2 indices corresponding to the pixel number k
|
---|
| 744 | */
|
---|
[764] | 745 | template<class T>
|
---|
| 746 | void LocalMap<T>::Getij(int_4 k,int_4& i,int_4& j) const
|
---|
| 747 | {
|
---|
| 748 | i= (k+1)%nSzX_-1;
|
---|
| 749 | if(i == -1) i= nSzX_-1;
|
---|
| 750 | j= (k-i+2)/nSzX_;
|
---|
| 751 | }
|
---|
| 752 |
|
---|
[1217] | 753 |
|
---|
[764] | 754 |
|
---|
| 755 |
|
---|
| 756 |
|
---|
| 757 |
|
---|
| 758 | template<class T>
|
---|
| 759 | void LocalMap<T>::print(ostream& os) const
|
---|
| 760 | {
|
---|
| 761 | os<<" SzX= "<<nSzX_<<", SzY= "<<nSzY_<<", NPix= "<<nPix_<<endl;
|
---|
[2013] | 762 | os<<" theta0= "<<thetaC_*180./Pi <<", phi0= "<<phiC_*180./Pi <<", angle= "<<angle_*180./Pi<<endl;
|
---|
[764] | 763 | os<<" x0= "<<x0_<<", y0= "<<y0_<<endl;
|
---|
[2013] | 764 | os<<" cos= "<< cosAngle_ <<", & sin= "<<sinAngle_<<endl;
|
---|
| 765 | os<<" deltaPhi_= "<< deltaPhi_ <<", deltaTheta = "<< deltaTheta_ <<endl;
|
---|
| 766 | os <<endl;
|
---|
[764] | 767 |
|
---|
| 768 | os << " contenu de pixels : ";
|
---|
| 769 | for(int i=0; i < nPix_; i++)
|
---|
| 770 | {
|
---|
| 771 | if(i%5 == 0) os << endl;
|
---|
[2013] | 772 | int_4 ik,jk;
|
---|
| 773 | Getij(i,ik,jk);
|
---|
| 774 | os << pixels_(jk,ik) <<", ";
|
---|
[764] | 775 | }
|
---|
| 776 | os << endl;
|
---|
| 777 | }
|
---|
[908] | 778 |
|
---|
| 779 |
|
---|
| 780 | template<class T>
|
---|
| 781 | void LocalMap<T>::recopierVariablesSimples(const LocalMap<T>& lm)
|
---|
| 782 | {
|
---|
[2013] | 783 |
|
---|
[2198] | 784 | pixelSized_ = lm.pixelSized_;
|
---|
| 785 | angleSized_ = lm.angleSized_;
|
---|
| 786 | originSet_ = lm.originSet_ ;
|
---|
| 787 |
|
---|
| 788 |
|
---|
[2013] | 789 | nSzX_ = lm.nSzX_;
|
---|
| 790 | nSzY_ = lm.nSzY_;
|
---|
| 791 | nPix_ = lm.nPix_;
|
---|
| 792 | x0_ = lm.x0_;
|
---|
| 793 | y0_ = lm.y0_;
|
---|
| 794 |
|
---|
| 795 | thetaC_ = lm.thetaC_;
|
---|
| 796 | phiC_ = lm.phiC_;
|
---|
| 797 | csthC_ = lm.csthC_;
|
---|
| 798 | snthC_ = lm.snthC_;
|
---|
| 799 | csphC_ = lm.csphC_;
|
---|
| 800 | snphC_ = lm.snphC_;
|
---|
| 801 | XC_ = lm.XC_;
|
---|
| 802 | YC_ = lm.YC_;
|
---|
| 803 | ZC_ = lm.ZC_;
|
---|
| 804 |
|
---|
[908] | 805 | angle_= lm.angle_;
|
---|
[2013] | 806 | cosAngle_ = lm.cosAngle_;
|
---|
| 807 | sinAngle_ = lm.sinAngle_;
|
---|
| 808 | deltaPhi_ = lm. deltaPhi_;
|
---|
| 809 | deltaTheta_ = lm.deltaTheta_;
|
---|
[908] | 810 | }
|
---|
| 811 |
|
---|
[2198] | 812 | template<class T>
|
---|
| 813 | void LocalMap<T>::initializationError() const
|
---|
| 814 | {
|
---|
| 815 | cout << endl;
|
---|
| 816 | if (!pixelSized_) cout << " LocalMap::initializationError() ; pixel sizing is missing " << endl;
|
---|
| 817 | if (!angleSized_ ) cout << " LocalMap::initializationError() ; angle sizing is missing " << endl;
|
---|
| 818 | if (!originSet_ ) cout << " LocalMap::initializationError() ; origin of map is not set " << endl;
|
---|
| 819 | throw PException("LocalMap::initializationError() : bad initialization of the local map ");
|
---|
| 820 |
|
---|
| 821 |
|
---|
| 822 | }
|
---|
| 823 |
|
---|
| 824 |
|
---|
[1419] | 825 | // ...... Operations de calcul ......
|
---|
[908] | 826 |
|
---|
[1419] | 827 |
|
---|
[2290] | 828 | /*! \fn void SOPHYA::LocalMap::SetT(T a)
|
---|
| 829 | Fill a LocalMap with a constant value \b a
|
---|
| 830 | */
|
---|
[1419] | 831 | template <class T>
|
---|
| 832 | LocalMap<T>& LocalMap<T>::SetT(T a)
|
---|
| 833 | {
|
---|
| 834 | if (NbPixels() < 1)
|
---|
| 835 | throw RangeCheckError("LocalMap<T>::SetT(T ) - LocalMap not dimensionned ! ");
|
---|
| 836 | pixels_ = a;
|
---|
| 837 | return (*this);
|
---|
| 838 | }
|
---|
| 839 |
|
---|
[2290] | 840 | /*! \fn void SOPHYA::LocalMap::Add(T a)
|
---|
| 841 | Add a constant value \b x to a LocalMap
|
---|
| 842 | */
|
---|
[1419] | 843 | template <class T>
|
---|
| 844 | LocalMap<T>& LocalMap<T>::Add(T a)
|
---|
| 845 | {
|
---|
| 846 | if (NbPixels()< 1)
|
---|
| 847 | throw RangeCheckError("LocalMap<T>::Add(T ) - LocalMap not dimensionned ! ");
|
---|
| 848 | pixels_ += a;
|
---|
| 849 | return (*this);
|
---|
| 850 | }
|
---|
| 851 |
|
---|
[2290] | 852 | /*! \fn void SOPHYA::LocalMap::Sub(T a,bool fginv)
|
---|
| 853 |
|
---|
| 854 | Substract a constant value \b a to a LocalMap
|
---|
| 855 |
|
---|
| 856 | */
|
---|
[1419] | 857 | template <class T>
|
---|
[1624] | 858 | LocalMap<T>& LocalMap<T>::Sub(T a,bool fginv)
|
---|
[1419] | 859 | {
|
---|
| 860 | if (NbPixels()< 1)
|
---|
| 861 | throw RangeCheckError("LocalMap<T>::Sub(T ) - LocalMap not dimensionned ! ");
|
---|
[1624] | 862 | pixels_.Sub(a,fginv);
|
---|
[1419] | 863 | return (*this);
|
---|
| 864 | }
|
---|
| 865 |
|
---|
[2290] | 866 | /*! \fn void SOPHYA::LocalMap::Mul(T a)
|
---|
| 867 | mutiply a LocalMap by a constant value \b a
|
---|
| 868 | */
|
---|
[1419] | 869 | template <class T>
|
---|
| 870 | LocalMap<T>& LocalMap<T>::Mul(T a)
|
---|
| 871 | {
|
---|
| 872 | if (NbPixels()< 1)
|
---|
| 873 | throw RangeCheckError("LocalMap<T>::Mul(T ) - LocalMap not dimensionned ! ");
|
---|
| 874 | pixels_ *= a;
|
---|
| 875 | return (*this);
|
---|
| 876 | }
|
---|
| 877 |
|
---|
[2290] | 878 | /*! \fn void SOPHYA::LocalMap::Div(T a)
|
---|
| 879 | divide a LocalMap by a constant value \b a
|
---|
| 880 | */
|
---|
[1419] | 881 | template <class T>
|
---|
| 882 | LocalMap<T>& LocalMap<T>::Div(T a)
|
---|
| 883 | {
|
---|
| 884 | if (NbPixels()< 1)
|
---|
| 885 | throw RangeCheckError("LocalMap<T>::Div(T ) - LocalMap not dimensionned ! ");
|
---|
| 886 | pixels_ /= a;
|
---|
| 887 | return (*this);
|
---|
| 888 | }
|
---|
| 889 |
|
---|
| 890 | // >>>> Operations avec 2nd membre de type LocalMap
|
---|
[2290] | 891 | /*! \fn void SOPHYA::LocalMap::AddElt(const LocalMap<T>& a)
|
---|
| 892 | Add two LocalMap
|
---|
| 893 | */
|
---|
[1419] | 894 | template <class T>
|
---|
| 895 | LocalMap<T>& LocalMap<T>::AddElt(const LocalMap<T>& a)
|
---|
| 896 | {
|
---|
| 897 | if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
|
---|
| 898 | {
|
---|
| 899 | throw(SzMismatchError("LocalMap<T>::AddElt(const LocalMap<T>&) SizeMismatch")) ;
|
---|
| 900 | }
|
---|
| 901 | pixels_ += a.pixels_;
|
---|
| 902 | return (*this);
|
---|
| 903 | }
|
---|
| 904 |
|
---|
[2290] | 905 | /*! \fn void SOPHYA::LocalMap::SubElt(const LocalMap<T>& a)
|
---|
| 906 | Substract two LocalMap
|
---|
| 907 | */
|
---|
[1419] | 908 | template <class T>
|
---|
| 909 | LocalMap<T>& LocalMap<T>::SubElt(const LocalMap<T>& a)
|
---|
| 910 | {
|
---|
| 911 | if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
|
---|
| 912 | {
|
---|
[1551] | 913 | throw(SzMismatchError("LocalMap<T>::SubElt(const LocalMap<T>&) SizeMismatch")) ;
|
---|
[1419] | 914 | }
|
---|
| 915 | pixels_ -= a.pixels_;
|
---|
| 916 | return (*this);
|
---|
| 917 | }
|
---|
| 918 |
|
---|
[2290] | 919 | /*! \fn void SOPHYA::LocalMap::MulElt(const LocalMap<T>& a)
|
---|
| 920 | Multiply two LocalMap (elements by elements)
|
---|
| 921 | */
|
---|
[1419] | 922 | template <class T>
|
---|
| 923 | LocalMap<T>& LocalMap<T>::MulElt(const LocalMap<T>& a)
|
---|
| 924 | {
|
---|
| 925 | if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
|
---|
| 926 | {
|
---|
[1551] | 927 | throw(SzMismatchError("LocalMap<T>::MulElt(const LocalMap<T>&) SizeMismatch")) ;
|
---|
[1419] | 928 | }
|
---|
[2013] | 929 | // pixels_ *= a.pixels_;
|
---|
| 930 | pixels_.DataBlock() *= a.pixels_.DataBlock();
|
---|
[1419] | 931 | return (*this);
|
---|
| 932 | }
|
---|
| 933 |
|
---|
[2290] | 934 | /*! \fn void SOPHYA::LocalMap::DivElt(const LocalMap<T>& a)
|
---|
| 935 | Divide two LocalMaps (elements by elements) - No protection for divide by 0
|
---|
| 936 | */
|
---|
[1551] | 937 | template <class T>
|
---|
| 938 | LocalMap<T>& LocalMap<T>::DivElt(const LocalMap<T>& a)
|
---|
| 939 | {
|
---|
| 940 | if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
|
---|
| 941 | {
|
---|
| 942 | throw(SzMismatchError("LocalMap<T>::DivElt(const LocalMap<T>&) SizeMismatch")) ;
|
---|
| 943 | }
|
---|
[2013] | 944 | // pixels_ /= a.pixels_;
|
---|
| 945 | pixels_.DataBlock() /= a.pixels_.DataBlock();
|
---|
[1551] | 946 | return (*this);
|
---|
| 947 | }
|
---|
[1419] | 948 |
|
---|
| 949 |
|
---|
| 950 |
|
---|
| 951 |
|
---|
[1551] | 952 |
|
---|
[764] | 953 |
|
---|
| 954 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
[1308] | 955 | #pragma define_template LocalMap<int_4>
|
---|
[764] | 956 | #pragma define_template LocalMap<r_8>
|
---|
| 957 | #pragma define_template LocalMap<r_4>
|
---|
| 958 | #pragma define_template LocalMap< complex<r_8> >
|
---|
| 959 | #pragma define_template LocalMap< complex<r_4> >
|
---|
| 960 | #endif
|
---|
| 961 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
|
---|
[1308] | 962 | template class LocalMap<int_4>;
|
---|
[764] | 963 | template class LocalMap<r_8>;
|
---|
| 964 | template class LocalMap<r_4>;
|
---|
| 965 | template class LocalMap< complex<r_8> >;
|
---|
| 966 | template class LocalMap< complex<r_4> >;
|
---|
| 967 | #endif
|
---|