[228] | 1 | #ifndef LOCALMAP_SEEN
|
---|
| 2 | #define LOCALMAP_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "pixelmap.h"
|
---|
| 5 | #include "sphericalmap.h"
|
---|
[470] | 6 | #include "ndatablock.h"
|
---|
[228] | 7 |
|
---|
[470] | 8 | #include "anydataobj.h"
|
---|
| 9 | #include "ppersist.h"
|
---|
| 10 |
|
---|
[228] | 11 | // A local map of a region of the sky, in cartesian coordinates.
|
---|
| 12 | // It has an origin in (theta0, phi0), mapped to pixel(x0, y0)
|
---|
| 13 | // (x0, y0 might be outside of this local map)
|
---|
| 14 | // default value of (x0, y0) is middle of the map, center of pixel(nx/2, ny/2)
|
---|
| 15 | //
|
---|
| 16 | // la carte est consideree comme un tableau a deux indices i et j, i etant
|
---|
| 17 | // indice de colonne et j indice de ligne. La carte est supposee resider
|
---|
| 18 | // dans un plan tangent, dont le point de tangence est repere (x0,y0) dans
|
---|
[470] | 19 | // la carte et (theta0, phi0) sur la sphere celeste. L extension de la
|
---|
[228] | 20 | // carte est definie par les valeurs de deux angles couverts respectivement
|
---|
| 21 | // par la totalite des pixels en x de la carte et la totalite des pixels
|
---|
| 22 | // en y. (SetSize()).
|
---|
| 23 | // On considere un "plan de reference" : plan tangent a la sphere celeste
|
---|
[470] | 24 | // aux angles theta=Pi/2 et phi=0. Dans ce plan L origine des coordonnees
|
---|
| 25 | // est le point de tangence. L axe Ox est la tangente parallele a
|
---|
| 26 | // lequateur, dirige vers les phi croissants, l axe Oy est parallele
|
---|
[228] | 27 | // au meridien, dirige vers le pole nord.
|
---|
| 28 | // De maniere interne a la classe une carte est definie dans ce plan de
|
---|
[470] | 29 | // reference et transportee jusqu au point (theta0, phi0) de sorte que les // axes restent paralleles aux meridiens et paralleles. L utilisateur peut
|
---|
[228] | 30 | // definir sa carte selon un repere en rotation par rapport au repere de
|
---|
[470] | 31 | // reference (par l angle entre le parallele et l axe Ox souhaite --
|
---|
[228] | 32 | // methode SetOrigin(...))
|
---|
| 33 |
|
---|
| 34 |
|
---|
[470] | 35 | // ***************** Class LocalMap *****************************
|
---|
[228] | 36 |
|
---|
[470] | 37 | template<class T>
|
---|
| 38 | class LocalMap : public PixelMap<T>, public AnyDataObj
|
---|
| 39 | {
|
---|
[228] | 40 |
|
---|
[470] | 41 | public:
|
---|
[228] | 42 |
|
---|
[470] | 43 | LocalMap();
|
---|
| 44 | LocalMap(int_4 nx, int_4 ny);
|
---|
| 45 | LocalMap(const LocalMap<T>& lm);
|
---|
| 46 | virtual ~LocalMap();
|
---|
[228] | 47 |
|
---|
[470] | 48 | // ---------- Overloading of () to access pixel number k ----
|
---|
[228] | 49 |
|
---|
[470] | 50 | inline T& operator()(int_4 k) {return(PixVal(k));}
|
---|
| 51 | inline T const& operator()(int_4 k) const {return(PixVal(k));}
|
---|
| 52 | inline T& operator()(int ix, int iy) {return PixVal(iy*nSzX_+ix);};
|
---|
| 53 | inline T const& operator()(int ix, int iy) const {return PixVal(iy*nSzX_+ix);};
|
---|
[228] | 54 |
|
---|
[470] | 55 | // ---------- Definition of PixelMap abstract methods -------
|
---|
| 56 |
|
---|
| 57 | /* return/set the number of pixels */
|
---|
| 58 | virtual int_4 NbPixels() const;
|
---|
| 59 | inline void setNbPixels(int_4 n) {nPix_= n;}
|
---|
| 60 |
|
---|
| 61 | /* return the value of pixel number k */
|
---|
| 62 | virtual T& PixVal(int_4 k);
|
---|
| 63 | virtual T const& PixVal(int_4 k) const;
|
---|
| 64 |
|
---|
| 65 | /* return the index of pixel at (theta,phi) */
|
---|
| 66 | virtual int_4 PixIndexSph(float theta, float phi) const;
|
---|
[228] | 67 |
|
---|
[470] | 68 | /* return the spherical coordinates of center of pixel number k */
|
---|
| 69 | virtual void PixThetaPhi(int_4 k, float& theta, float& phi) const;
|
---|
[228] | 70 |
|
---|
[470] | 71 | /* return the Pixel Solid angle (steradians) */
|
---|
| 72 | virtual r_8 PixSolAngle(int_4 k) const;
|
---|
[228] | 73 |
|
---|
[470] | 74 | // ---------- Specific methods ------------------------------
|
---|
[228] | 75 |
|
---|
[470] | 76 | void ReSize(int_4 nx, int_4 ny);
|
---|
[228] | 77 |
|
---|
[470] | 78 | inline virtual char* TypeOfMap() const {return "LOCAL";};
|
---|
| 79 |
|
---|
| 80 | /* Origin (with angle between x axis and phi axis, in degrees) x0,y0 the default: middle of map*/
|
---|
| 81 | virtual void SetOrigin(float theta=90., float phi=0., float angle=0.);
|
---|
| 82 | virtual void SetOrigin(float theta,float phi,int_4 x0,int_4 y0,float angle=0.);
|
---|
[228] | 83 |
|
---|
[470] | 84 | /* Pixel size (degres) */
|
---|
| 85 | virtual void SetSize(float angleX, float angleY);
|
---|
[228] | 86 |
|
---|
[470] | 87 | /* Check to see if the local mapping is done */
|
---|
| 88 | inline bool LocalMap_isDone() const {return(originFlag_ && extensFlag_);};
|
---|
[228] | 89 |
|
---|
[470] | 90 | /* Projection to/from spherical map */
|
---|
| 91 | virtual void Project(SphericalMap<T>& sphere) const;
|
---|
[228] | 92 |
|
---|
[470] | 93 | /* There should be a more complex algorithm somewhere to combine *several* local maps to a full sphere.
|
---|
| 94 | -> static method, or separate class */
|
---|
| 95 |
|
---|
| 96 | /* provides a integer characterizing the pixelization refinement (here : number of pixels) */
|
---|
| 97 | inline virtual int_4 SizeIndex() const {return(nPix_);}
|
---|
| 98 | inline int_4 Size_x() const {return nSzX_;}
|
---|
| 99 | inline void setSize_x(int_4 n) {nSzX_= n;}
|
---|
| 100 | inline int_4 Size_y() const {return nSzY_;}
|
---|
| 101 | inline void setSize_y(int_4 n) {nSzY_= n;}
|
---|
[228] | 102 |
|
---|
[470] | 103 | inline void Origin(float& theta, float& phi,int& x0, int& y0, float& angle) const {theta= (float)theta0_; phi= (float)phi0_; x0= x0_; y0= y0_;angle= (float)angle_;}
|
---|
[228] | 104 |
|
---|
[470] | 105 | inline void Aperture(float& anglex, float& angley) const {anglex= (float)angleX_; angley= (float)angleY_;}
|
---|
| 106 |
|
---|
| 107 | /* retourne le pointeur vers/remplit le vecteur des contenus des pixels */
|
---|
| 108 | inline const NDataBlock<T>* getDataBlock() const {return (&pixels_);}
|
---|
| 109 | inline void setDataBlock(T* data, int_4 n) {pixels_.FillFrom(n,data);}
|
---|
| 110 |
|
---|
| 111 | /* impression */
|
---|
| 112 | void print(ostream& os) const;
|
---|
| 113 |
|
---|
| 114 | // ---------- Méthodes internes -----------------------------
|
---|
[228] | 115 |
|
---|
| 116 | private :
|
---|
| 117 |
|
---|
[470] | 118 | void InitNul();
|
---|
| 119 | void Getij(int k, int& i, int& j) const;
|
---|
| 120 | void ReferenceToUser(float &theta, float &phi) const;
|
---|
| 121 | void UserToReference(float &theta, float &phi) const;
|
---|
| 122 | void PixProjToAngle(float x, float y,float &theta, float &phi) const;
|
---|
| 123 | void AngleProjToPix(float theta, float phi, float& x, float& y) const;
|
---|
[228] | 124 |
|
---|
[470] | 125 | // ---------- Variables internes ----------------------------
|
---|
| 126 |
|
---|
| 127 | int_4 nSzX_;
|
---|
| 128 | int_4 nSzY_;
|
---|
| 129 | int_4 nPix_;
|
---|
| 130 | bool originFlag_;
|
---|
| 131 | bool extensFlag_;
|
---|
| 132 | int_4 x0_;
|
---|
| 133 | int_4 y0_;
|
---|
| 134 | r_8 theta0_;
|
---|
| 135 | r_8 phi0_;
|
---|
| 136 | r_8 angle_;
|
---|
| 137 | r_4 cos_angle_;
|
---|
| 138 | r_4 sin_angle_;
|
---|
| 139 | r_8 angleX_;
|
---|
| 140 | r_8 angleY_;
|
---|
| 141 | r_8 tgAngleX_;
|
---|
| 142 | r_8 tgAngleY_;
|
---|
| 143 | NDataBlock<T> pixels_;
|
---|
[228] | 144 | };
|
---|
| 145 |
|
---|
[470] | 146 | // ------------- Classe pour la gestion de persistance --
|
---|
| 147 | template <class T>
|
---|
| 148 | class FIO_LocalMap : public PPersist
|
---|
| 149 | {
|
---|
| 150 |
|
---|
| 151 | public:
|
---|
| 152 |
|
---|
| 153 | FIO_LocalMap();
|
---|
| 154 | FIO_LocalMap(string const & filename);
|
---|
| 155 | FIO_LocalMap(const LocalMap<T>& obj);
|
---|
| 156 | FIO_LocalMap(LocalMap<T>* obj);
|
---|
| 157 | virtual ~FIO_LocalMap();
|
---|
| 158 | virtual AnyDataObj* DataObj();
|
---|
| 159 | inline operator LocalMap<T>() { return(*dobj); }
|
---|
| 160 | inline LocalMap<T> getObj() { return(*dobj); }
|
---|
| 161 |
|
---|
| 162 | protected :
|
---|
| 163 |
|
---|
| 164 | virtual void ReadSelf(PInPersist&);
|
---|
| 165 | virtual void WriteSelf(POutPersist&) const;
|
---|
| 166 | LocalMap<T>* dobj;
|
---|
| 167 | bool ownobj;
|
---|
| 168 | };
|
---|
| 169 |
|
---|
[228] | 170 | #endif
|
---|