1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
2 | // Eric Aubourg
|
---|
3 | // Christophe Magneville
|
---|
4 | // Reza Ansari
|
---|
5 | // $Id: map2toi.cc,v 1.11 2002-05-31 15:44:54 ansari Exp $
|
---|
6 |
|
---|
7 | #include "toimanager.h"
|
---|
8 | #include "pexceptions.h"
|
---|
9 | #include "ctimer.h"
|
---|
10 | #include "map2toi.h"
|
---|
11 | // La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
|
---|
12 | #include "smathconst.h"
|
---|
13 |
|
---|
14 | ////////////////////////////////////////////////////////////////////////
|
---|
15 | Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
|
---|
16 | : mSph(sph), totnscount(0)
|
---|
17 | {
|
---|
18 | SetBad();
|
---|
19 | SetEquinox();
|
---|
20 | SetCoorIn();
|
---|
21 | SetCoorMap();
|
---|
22 | }
|
---|
23 |
|
---|
24 | Map2TOI::~Map2TOI()
|
---|
25 | {
|
---|
26 | }
|
---|
27 |
|
---|
28 | ////////////////////////////////////////////////////////////////////////
|
---|
29 | void Map2TOI::Print(::ostream & os)
|
---|
30 | {
|
---|
31 | os<<"Map2TOI::Print -- Sphere NLat = "<<mSph.SizeIndex()<<endl
|
---|
32 | <<" - Equinoxe: "<<mActualYear<<" y"<<endl
|
---|
33 | <<" - TypCoorIn: "<<mTypCoorIn<<" = "<<DecodeTypAstro(mTypCoorIn)<<endl
|
---|
34 | <<" - TypCoorMap: "<<mTypCoorMap<<" = "<<DecodeTypAstro(mTypCoorMap)<<endl;
|
---|
35 | }
|
---|
36 |
|
---|
37 | ////////////////////////////////////////////////////////////////////////
|
---|
38 | void Map2TOI::init() {
|
---|
39 | cout << "Map2TOI::init" << endl;
|
---|
40 | declareInput("Coord1In"); // input index 0
|
---|
41 | declareInput("Coord2In"); // input index 1
|
---|
42 | declareOutput("Coord1Out"); // output index 0
|
---|
43 | declareOutput("Coord2Out"); // output index 1
|
---|
44 | declareOutput("BoloOut"); // output index 2
|
---|
45 | }
|
---|
46 |
|
---|
47 | ////////////////////////////////////////////////////////////////////////
|
---|
48 | void Map2TOI::run() {
|
---|
49 |
|
---|
50 | if(mSph.NbPixels()<1) {
|
---|
51 | cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
|
---|
52 | throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
|
---|
53 | }
|
---|
54 |
|
---|
55 | long snb = getMinIn();
|
---|
56 | long sne = getMaxIn();
|
---|
57 | if(snb>sne) {
|
---|
58 | cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
59 | throw ParmError("Map2TOI::run() - Bad sample interval");
|
---|
60 | }
|
---|
61 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
|
---|
62 | cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
|
---|
63 | throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
|
---|
64 | }
|
---|
65 | bool connected_Coord1Out = checkOutputTOIIndex(0);
|
---|
66 | bool connected_Coord2Out = checkOutputTOIIndex(1);
|
---|
67 | if(!checkOutputTOIIndex(2)) {
|
---|
68 | cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
|
---|
69 | throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
|
---|
70 | }
|
---|
71 | if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
|
---|
72 | cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
|
---|
73 | throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
|
---|
74 | }
|
---|
75 | if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
|
---|
76 | cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
|
---|
77 | throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
|
---|
78 | }
|
---|
79 |
|
---|
80 | //---------------------------------------------------------
|
---|
81 | try {
|
---|
82 |
|
---|
83 | double mjd = MJDfrYear(mActualYear);
|
---|
84 | cout<<"Map2TOI::run() - modified Julian day "<<mjd<<endl;
|
---|
85 |
|
---|
86 | uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
|
---|
87 |
|
---|
88 | for(int k=snb;k<=sne;k++) {
|
---|
89 |
|
---|
90 | uint_8 flg = 0;
|
---|
91 | double coord1 = getData(0,k);
|
---|
92 | double coord2 = getData(1,k);
|
---|
93 | double c1 = coord1, c2=coord2, bolo = -99999.;
|
---|
94 | mSnRead++;
|
---|
95 |
|
---|
96 | // Conversion de CoordIn to Standard
|
---|
97 | double phi=-1.;
|
---|
98 | CoordConvertToStd(mTypCoorIn,&c1,&c2);
|
---|
99 |
|
---|
100 | // Conversion dans le systeme astronomique approprie
|
---|
101 | if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq CMap=Gal
|
---|
102 | EqtoGal(mjd,c1,c2,&c1,&c2);
|
---|
103 | phi = c1 * Pi/180.;
|
---|
104 | } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
|
---|
105 | GaltoEq(mjd,c1,c2,&c1,&c2);
|
---|
106 | phi = c1 * Pi/12.;
|
---|
107 | } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
|
---|
108 | phi = c1 * Pi/180.;
|
---|
109 | } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
|
---|
110 | phi = c1 * Pi/12.;
|
---|
111 | }
|
---|
112 | ToCoLat(&c2,TypUniteD);
|
---|
113 | double theta = c2 * Pi/180.;
|
---|
114 | if(phi<0. || phi>=2*Pi || theta<0. || theta>Pi)
|
---|
115 | {BadCoorRange++; flg = mBadFlag; }
|
---|
116 |
|
---|
117 | if(!flg) {
|
---|
118 | bolo = mSph(theta,phi);
|
---|
119 | mSnFilled++;
|
---|
120 | }
|
---|
121 |
|
---|
122 | if(connected_Coord1Out) putData(0,k,coord1,flg);
|
---|
123 | if(connected_Coord2Out) putData(1,k,coord2,flg);
|
---|
124 | putData(2,k,bolo,flg);
|
---|
125 | }
|
---|
126 |
|
---|
127 | cout<<"TOI2Map::run: Samples Read "<<mSnRead
|
---|
128 | <<" Filled "<<mSnFilled
|
---|
129 | <<" BadCoorRange="<<BadCoorRange<<endl;
|
---|
130 |
|
---|
131 | //---------------------------------------------------------
|
---|
132 | } catch (PException & exc) {
|
---|
133 | cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
|
---|
134 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
135 | }
|
---|
136 |
|
---|
137 | return;
|
---|
138 | }
|
---|