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