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

Last change on this file since 1744 was 1738, checked in by aubourg, 24 years ago

copyright

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.7 2001-11-08 15:47:45 aubourg Exp $
6
7#include "toimanager.h"
8#include "pexceptions.h"
9#include "ctimer.h"
10#include "map2toi.h"
11
12////////////////////////////////////////////////////////////////////////
13Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
14: mSph(sph)
15{
16 SetEquinox();
17 SetCoorIn();
18 SetCoorMap();
19}
20
21Map2TOI::~Map2TOI()
22{
23}
24
25////////////////////////////////////////////////////////////////////////
26void Map2TOI::Print(ostream & os)
27{
28 os<<"Map2TOI::Print -- Sphere NLat = "<<mSph.SizeIndex()<<endl
29
30 <<" - Equinoxe="<<mActualYear<<endl
31
32 <<" - TypCoorIn: Gal("<<((mTypCoorIn&TypCoordGal)?1:0)
33 <<") Eq("<<((mTypCoorIn&TypCoordEq)?1:0)
34 <<") Deg("<<((mTypCoorIn&TypCoordDD)?1:0)
35 <<") Hour("<<((mTypCoorIn&TypCoordHD)?1:0)
36 <<") Rad("<<((mTypCoorIn&TypCoordRR)?1:0)<<")"<<endl
37
38 <<" - TypCoorMap: Gal("<<((mTypCoorMap&TypCoordGal)?1:0)
39 <<") Eq("<<((mTypCoorMap&TypCoordEq)?1:0)
40 <<") Deg("<<((mTypCoorMap&TypCoordDD)?1:0)
41 <<") Hour("<<((mTypCoorMap&TypCoordHD)?1:0)
42 <<") Rad("<<((mTypCoorMap&TypCoordRR)?1:0)<<")"<<endl;
43}
44
45////////////////////////////////////////////////////////////////////////
46void Map2TOI::init() {
47 cout << "Map2TOI::init" << endl;
48 declareInput("Coord1In"); // input index 0
49 declareInput("Coord2In"); // input index 1
50 declareOutput("Coord1Out"); // output index 0
51 declareOutput("Coord2Out"); // output index 1
52 declareOutput("BoloOut"); // output index 2
53}
54
55////////////////////////////////////////////////////////////////////////
56void Map2TOI::run() {
57
58if(mSph.NbPixels()<1) {
59 cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
60 throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
61}
62
63long snb = getMinIn();
64long sne = getMaxIn();
65if(snb>sne) {
66 cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
67 throw ParmError("Map2TOI::run() - Bad sample interval");
68}
69if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
70 cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
71 throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
72}
73bool connected_Coord1Out = checkOutputTOIIndex(0);
74bool connected_Coord2Out = checkOutputTOIIndex(1);
75if(!checkOutputTOIIndex(2)) {
76 cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
77 throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
78}
79if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
80 cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
81 throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
82}
83if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
84 cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
85 throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
86}
87
88//---------------------------------------------------------
89try {
90
91uint_4 mSnRead=0, mSnFilled=0;
92double mjd = MJDfrYear(mActualYear);
93
94for(int k=snb;k<=sne;k++) {
95
96 uint_8 flg = 0;
97 double coord1 = getData(0,k);
98 double coord2 = getData(1,k);
99 double c1 = coord1, c2=coord2, bolo = -99999.;
100 mSnRead++;
101
102 // Convert CoordIn to Standard
103 double phi=-1.,theta;
104 CoordConvertToStd(mTypCoorIn,c1,c2);
105 if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq CMap=Gal
106 EqtoGal(mjd,c1,c2,&c1,&c2);
107 phi = c1 * M_PI/180.;
108 } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
109 GaltoEq(mjd,c1,c2,&c1,&c2);
110 phi = c1 * M_PI/12.;
111 } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
112 phi = c1 * M_PI/180.;
113 } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
114 phi = c1 * M_PI/12.;
115 }
116 theta = (90.-c2) * M_PI/180.;
117 if(phi<0. || phi>=2*M_PI) flg=FlgToiOut;
118 if(theta<0. || theta>=M_PI) flg=FlgToiOut;
119
120 if(!flg) {
121 bolo = mSph(theta,phi);
122 mSnFilled++;
123 }
124
125 if(connected_Coord1Out) putData(0,k,coord1,flg);
126 if(connected_Coord2Out) putData(1,k,coord2,flg);
127 putData(2,k,bolo,flg);
128}
129
130cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<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.