[1463] | 1 | #include "toimanager.h"
|
---|
| 2 | #include "pexceptions.h"
|
---|
| 3 | #include "ctimer.h"
|
---|
| 4 | #include "map2toi.h"
|
---|
| 5 |
|
---|
| 6 | ////////////////////////////////////////////////////////////////////////
|
---|
| 7 | Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
|
---|
| 8 | : mSph(sph)
|
---|
| 9 | {
|
---|
[1520] | 10 | SetEquinox();
|
---|
| 11 | SetCoorIn();
|
---|
| 12 | SetCoorMap();
|
---|
[1463] | 13 | }
|
---|
| 14 |
|
---|
| 15 | Map2TOI::~Map2TOI()
|
---|
| 16 | {
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | ////////////////////////////////////////////////////////////////////////
|
---|
| 20 | void Map2TOI::init() {
|
---|
| 21 | cout << "Map2TOI::init" << endl;
|
---|
[1520] | 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
|
---|
[1463] | 27 | }
|
---|
| 28 |
|
---|
| 29 | ////////////////////////////////////////////////////////////////////////
|
---|
| 30 | void Map2TOI::run() {
|
---|
| 31 |
|
---|
| 32 | if(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 |
|
---|
| 37 | long snb = getMinIn();
|
---|
| 38 | long sne = getMaxIn();
|
---|
| 39 | if(snb>sne) {
|
---|
| 40 | cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
| 41 | throw ParmError("Map2TOI::run() - Bad sample interval");
|
---|
| 42 | }
|
---|
| 43 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
|
---|
[1520] | 44 | cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
|
---|
| 45 | throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
|
---|
[1463] | 46 | }
|
---|
[1520] | 47 | bool connected_Coord1Out = checkOutputTOIIndex(0);
|
---|
| 48 | bool connected_Coord2Out = checkOutputTOIIndex(1);
|
---|
[1463] | 49 | if(!checkOutputTOIIndex(2)) {
|
---|
| 50 | cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
|
---|
| 51 | throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
|
---|
| 52 | }
|
---|
[1520] | 53 | if( !(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 | }
|
---|
| 57 | if( !(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 | }
|
---|
[1463] | 61 |
|
---|
| 62 | //---------------------------------------------------------
|
---|
| 63 | try {
|
---|
| 64 |
|
---|
[1520] | 65 | uint_4 mSnRead=0, mSnFilled=0;
|
---|
| 66 | double mjd = MJDfrYear(mActualYear);
|
---|
| 67 |
|
---|
[1463] | 68 | for(int k=snb;k<=sne;k++) {
|
---|
| 69 |
|
---|
[1466] | 70 | int_8 flg = 0;
|
---|
[1520] | 71 | double coord1 = getData(0,k);
|
---|
| 72 | double coord2 = getData(1,k);
|
---|
| 73 | double c1 = coord1, c2=coord2, bolo = -99999.;
|
---|
| 74 | mSnRead++;
|
---|
[1463] | 75 |
|
---|
[1520] | 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 |
|
---|
[1466] | 94 | if(!flg) {
|
---|
[1520] | 95 | bolo = mSph(theta,phi);
|
---|
| 96 | mSnFilled++;
|
---|
[1466] | 97 | }
|
---|
[1463] | 98 |
|
---|
[1520] | 99 | if(connected_Coord1Out) putData(0,k,coord1,flg);
|
---|
| 100 | if(connected_Coord2Out) putData(1,k,coord2,flg);
|
---|
[1466] | 101 | putData(2,k,bolo,flg);
|
---|
[1463] | 102 | }
|
---|
| 103 |
|
---|
[1520] | 104 | cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<endl;
|
---|
| 105 |
|
---|
[1463] | 106 | //---------------------------------------------------------
|
---|
| 107 | } catch (PException & exc) {
|
---|
| 108 | cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 109 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | return;
|
---|
| 113 | }
|
---|