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

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

Introduction de SpherePosition and SphereCoordSys, and Initiator for module Samba - Reza+I. Grivell 26/10/99

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