source: Sophya/trunk/SophyaLib/Samba/localmap.h@ 508

Last change on this file since 508 was 473, checked in by ansari, 26 years ago

modifs francois : passage en double etc. 18-OCT-99

File size: 5.7 KB
Line 
1#ifndef LOCALMAP_SEEN
2#define LOCALMAP_SEEN
3
4#include "pixelmap.h"
5#include "sphericalmap.h"
6#include "ndatablock.h"
7
8#include "anydataobj.h"
9#include "ppersist.h"
10
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
19// la carte et (theta0, phi0) sur la sphere celeste. L extension de la
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
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
27// au meridien, dirige vers le pole nord.
28// De maniere interne a la classe une carte est definie dans ce plan de
29// reference et transportee jusqu au point (theta0, phi0) de sorte que les // axes restent paralleles aux meridiens et paralleles. L utilisateur peut
30// definir sa carte selon un repere en rotation par rapport au repere de
31// reference (par l angle entre le parallele et l axe Ox souhaite --
32// methode SetOrigin(...))
33
34
35// ***************** Class LocalMap *****************************
36
37template<class T>
38class LocalMap : public PixelMap<T>, public AnyDataObj
39{
40
41public:
42
43LocalMap();
44LocalMap(int nx, int ny);
45LocalMap(const LocalMap<T>& lm);
46virtual ~LocalMap();
47
48// ---------- Overloading of () to access pixel number k ----
49
50inline T& operator()(int k) {return(PixVal(k));}
51inline T const& operator()(int k) const {return(PixVal(k));}
52inline T& operator()(int ix, int iy) {return PixVal(iy*nSzX_+ix);};
53inline T const& operator()(int ix, int iy) const {return PixVal(iy*nSzX_+ix);};
54
55// ---------- Definition of PixelMap abstract methods -------
56
57/* return/set the number of pixels */
58virtual int NbPixels() const;
59inline void setNbPixels(int n) {nPix_= n;}
60
61/* return the value of pixel number k */
62virtual T& PixVal(int k);
63virtual T const& PixVal(int k) const;
64
65/* return the index of pixel at (theta,phi) */
66virtual int PixIndexSph(double theta,double phi) const;
67
68/* return the spherical coordinates of center of pixel number k */
69virtual void PixThetaPhi(int k,double& theta,double& phi) const;
70
71/* return the Pixel Solid angle (steradians) */
72virtual double PixSolAngle(int k) const;
73
74// ---------- Specific methods ------------------------------
75
76void ReSize(int nx, int ny);
77
78inline 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*/
81virtual void SetOrigin(double theta=90.,double phi=0.,double angle=0.);
82virtual void SetOrigin(double theta,double phi,int x0,int y0,double angle=0.);
83
84/* Pixel size (degres) */
85virtual void SetSize(double angleX,double angleY);
86
87/* Check to see if the local mapping is done */
88inline bool LocalMap_isDone() const {return(originFlag_ && extensFlag_);};
89
90/* Projection to/from spherical map */
91virtual void Project(SphericalMap<T>& sphere) const;
92
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) */
97inline virtual int SizeIndex() const {return(nPix_);}
98inline int Size_x() const {return nSzX_;}
99inline void setSize_x(int n) {nSzX_= n;}
100inline int Size_y() const {return nSzY_;}
101inline void setSize_y(int n) {nSzY_= n;}
102
103inline void Origin(double& theta,double& phi,int& x0,int& y0,double& angle) const {theta= theta0_; phi= phi0_; x0= x0_; y0= y0_;angle= angle_;}
104
105inline void Aperture(double& anglex,double& angley) const {anglex= angleX_; angley= angleY_;}
106
107/* retourne le pointeur vers/remplit le vecteur des contenus des pixels */
108inline const NDataBlock<T>* getDataBlock() const {return (&pixels_);}
109inline void setDataBlock(T* data, int n) {pixels_.FillFrom(n,data);}
110
111/* impression */
112void print(ostream& os) const;
113
114// ---------- Méthodes internes -----------------------------
115
116private :
117
118void InitNul();
119void Getij(int k,int& i,int& j) const;
120void ReferenceToUser(double& theta,double& phi) const;
121void UserToReference(double& theta,double& phi) const;
122void PixProjToAngle(double x,double y,double& theta,double& phi) const;
123void AngleProjToPix(double theta,double phi,double& x,double& y) const;
124
125// ---------- Variables internes ----------------------------
126
127int nSzX_;
128int nSzY_;
129int nPix_;
130bool originFlag_;
131bool extensFlag_;
132int x0_;
133int y0_;
134double theta0_;
135double phi0_;
136double angle_;
137double cos_angle_;
138double sin_angle_;
139double angleX_;
140double angleY_;
141double tgAngleX_;
142double tgAngleY_;
143NDataBlock<T> pixels_;
144};
145
146// ------------- Classe pour la gestion de persistance --
147template <class T>
148class FIO_LocalMap : public PPersist
149{
150
151public:
152
153FIO_LocalMap();
154FIO_LocalMap(string const & filename);
155FIO_LocalMap(const LocalMap<T>& obj);
156FIO_LocalMap(LocalMap<T>* obj);
157virtual ~FIO_LocalMap();
158virtual AnyDataObj* DataObj();
159inline operator LocalMap<T>() { return(*dobj); }
160inline LocalMap<T> getObj() { return(*dobj); }
161
162protected :
163
164virtual void ReadSelf(PInPersist&);
165virtual void WriteSelf(POutPersist&) const;
166LocalMap<T>* dobj;
167bool ownobj;
168};
169
170#endif
Note: See TracBrowser for help on using the repository browser.