source: Sophya/trunk/ArchTOIPipe/ProcWSophya/map2toi.cc@ 2068

Last change on this file since 2068 was 2040, checked in by ansari, 23 years ago

Correction totnscount++ ds Map2TOI - Reza 30/5/2002

File size: 4.5 KB
Line 
1// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
2// Eric Aubourg
3// Christophe Magneville
4// Reza Ansari
5// $Id: map2toi.cc,v 1.12 2002-05-31 15:49:00 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////////////////////////////////////////////////////////////////////////
15Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
16: mSph(sph), totnscount(0)
17{
18 SetBad();
19 SetEquinox();
20 SetCoorIn();
21 SetCoorMap();
22}
23
24Map2TOI::~Map2TOI()
25{
26}
27
28////////////////////////////////////////////////////////////////////////
29void 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////////////////////////////////////////////////////////////////////////
38void 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////////////////////////////////////////////////////////////////////////
48void Map2TOI::run() {
49
50if(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
55long snb = getMinIn();
56long sne = getMaxIn();
57if(snb>sne) {
58 cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
59 throw ParmError("Map2TOI::run() - Bad sample interval");
60}
61if(!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}
65bool connected_Coord1Out = checkOutputTOIIndex(0);
66bool connected_Coord2Out = checkOutputTOIIndex(1);
67if(!checkOutputTOIIndex(2)) {
68 cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
69 throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
70}
71if( !(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}
75if( !(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//---------------------------------------------------------
81try {
82
83double mjd = MJDfrYear(mActualYear);
84cout<<"Map2TOI::run() - modified Julian day "<<mjd<<endl;
85
86uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
87
88for(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 totnscount++;
126}
127
128cout<<"TOI2Map::run: Samples Read "<<mSnRead
129 <<" Filled "<<mSnFilled
130 <<" BadCoorRange="<<BadCoorRange<<endl;
131
132//---------------------------------------------------------
133} catch (PException & exc) {
134 cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
135 <<"\n .... Msg= "<<exc.Msg()<<endl;
136}
137
138return;
139}
Note: See TracBrowser for help on using the repository browser.