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

Last change on this file since 1520 was 1520, checked in by cmv, 24 years ago

Re-shape de map2toi cmv 12/6/01

File size: 3.5 KB
Line 
1#include "toimanager.h"
2#include "pexceptions.h"
3#include "ctimer.h"
4#include "map2toi.h"
5
6////////////////////////////////////////////////////////////////////////
7Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
8: mSph(sph)
9{
10 SetEquinox();
11 SetCoorIn();
12 SetCoorMap();
13}
14
15Map2TOI::~Map2TOI()
16{
17}
18
19////////////////////////////////////////////////////////////////////////
20void Map2TOI::init() {
21 cout << "Map2TOI::init" << endl;
22 declareInput("Coord1In"); // input index 0
23 declareInput("Coord2In"); // input index 1
24 declareOutput("Coord1Out"); // output index 0
25 declareOutput("Coord2Out"); // output index 1
26 declareOutput("BoloOut"); // output index 2
27}
28
29////////////////////////////////////////////////////////////////////////
30void Map2TOI::run() {
31
32if(mSph.NbPixels()<1) {
33 cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
34 throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
35}
36
37long snb = getMinIn();
38long sne = getMaxIn();
39if(snb>sne) {
40 cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
41 throw ParmError("Map2TOI::run() - Bad sample interval");
42}
43if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
44 cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
45 throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
46}
47bool connected_Coord1Out = checkOutputTOIIndex(0);
48bool connected_Coord2Out = checkOutputTOIIndex(1);
49if(!checkOutputTOIIndex(2)) {
50 cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
51 throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
52}
53if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
54 cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
55 throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
56}
57if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
58 cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
59 throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
60}
61
62//---------------------------------------------------------
63try {
64
65uint_4 mSnRead=0, mSnFilled=0;
66double mjd = MJDfrYear(mActualYear);
67
68for(int k=snb;k<=sne;k++) {
69
70 int_8 flg = 0;
71 double coord1 = getData(0,k);
72 double coord2 = getData(1,k);
73 double c1 = coord1, c2=coord2, bolo = -99999.;
74 mSnRead++;
75
76 // Convert CoordIn to Standard
77 double phi=-1.,theta;
78 CoordConvertToStd(mTypCoorIn,c1,c2);
79 if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq CMap=Gal
80 EqtoGal(mjd,c1,c2,&c1,&c2);
81 phi = c1 * M_PI/180.;
82 } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
83 GaltoEq(mjd,c1,c2,&c1,&c2);
84 phi = c1 * M_PI/12.;
85 } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
86 phi = c1 * M_PI/180.;
87 } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
88 phi = c1 * M_PI/12.;
89 }
90 theta = (90.-c2) * M_PI/180.;
91 if(phi<0. || phi>=2*M_PI) flg=FlgToiOut;
92 if(theta<0. || theta>=M_PI) flg=FlgToiOut;
93
94 if(!flg) {
95 bolo = mSph(theta,phi);
96 mSnFilled++;
97 }
98
99 if(connected_Coord1Out) putData(0,k,coord1,flg);
100 if(connected_Coord2Out) putData(1,k,coord2,flg);
101 putData(2,k,bolo,flg);
102}
103
104cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<endl;
105
106//---------------------------------------------------------
107} catch (PException & exc) {
108 cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
109 <<"\n .... Msg= "<<exc.Msg()<<endl;
110}
111
112return;
113}
Note: See TracBrowser for help on using the repository browser.