[1738] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[1762] | 5 | // $Id: map2toi.cc,v 1.9 2001-11-13 16:22:47 aubourg Exp $
|
---|
[1738] | 6 |
|
---|
[1463] | 7 | #include "toimanager.h"
|
---|
| 8 | #include "pexceptions.h"
|
---|
| 9 | #include "ctimer.h"
|
---|
| 10 | #include "map2toi.h"
|
---|
| 11 |
|
---|
| 12 | ////////////////////////////////////////////////////////////////////////
|
---|
| 13 | Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
|
---|
| 14 | : mSph(sph)
|
---|
| 15 | {
|
---|
[1520] | 16 | SetEquinox();
|
---|
| 17 | SetCoorIn();
|
---|
| 18 | SetCoorMap();
|
---|
[1463] | 19 | }
|
---|
| 20 |
|
---|
| 21 | Map2TOI::~Map2TOI()
|
---|
| 22 | {
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | ////////////////////////////////////////////////////////////////////////
|
---|
[1762] | 26 | void Map2TOI::Print(::ostream & os)
|
---|
[1530] | 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 | ////////////////////////////////////////////////////////////////////////
|
---|
[1463] | 46 | void Map2TOI::init() {
|
---|
| 47 | cout << "Map2TOI::init" << endl;
|
---|
[1520] | 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
|
---|
[1463] | 53 | }
|
---|
| 54 |
|
---|
| 55 | ////////////////////////////////////////////////////////////////////////
|
---|
| 56 | void Map2TOI::run() {
|
---|
| 57 |
|
---|
| 58 | if(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 |
|
---|
| 63 | long snb = getMinIn();
|
---|
| 64 | long sne = getMaxIn();
|
---|
| 65 | if(snb>sne) {
|
---|
| 66 | cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
| 67 | throw ParmError("Map2TOI::run() - Bad sample interval");
|
---|
| 68 | }
|
---|
| 69 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
|
---|
[1520] | 70 | cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
|
---|
| 71 | throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
|
---|
[1463] | 72 | }
|
---|
[1520] | 73 | bool connected_Coord1Out = checkOutputTOIIndex(0);
|
---|
| 74 | bool connected_Coord2Out = checkOutputTOIIndex(1);
|
---|
[1463] | 75 | if(!checkOutputTOIIndex(2)) {
|
---|
| 76 | cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
|
---|
| 77 | throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
|
---|
| 78 | }
|
---|
[1520] | 79 | if( !(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 | }
|
---|
| 83 | if( !(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 | }
|
---|
[1463] | 87 |
|
---|
| 88 | //---------------------------------------------------------
|
---|
| 89 | try {
|
---|
| 90 |
|
---|
[1520] | 91 | uint_4 mSnRead=0, mSnFilled=0;
|
---|
| 92 | double mjd = MJDfrYear(mActualYear);
|
---|
| 93 |
|
---|
[1463] | 94 | for(int k=snb;k<=sne;k++) {
|
---|
| 95 |
|
---|
[1532] | 96 | uint_8 flg = 0;
|
---|
[1520] | 97 | double coord1 = getData(0,k);
|
---|
| 98 | double coord2 = getData(1,k);
|
---|
| 99 | double c1 = coord1, c2=coord2, bolo = -99999.;
|
---|
| 100 | mSnRead++;
|
---|
[1463] | 101 |
|
---|
[1520] | 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 |
|
---|
[1466] | 120 | if(!flg) {
|
---|
[1520] | 121 | bolo = mSph(theta,phi);
|
---|
| 122 | mSnFilled++;
|
---|
[1466] | 123 | }
|
---|
[1463] | 124 |
|
---|
[1520] | 125 | if(connected_Coord1Out) putData(0,k,coord1,flg);
|
---|
| 126 | if(connected_Coord2Out) putData(1,k,coord2,flg);
|
---|
[1466] | 127 | putData(2,k,bolo,flg);
|
---|
[1463] | 128 | }
|
---|
| 129 |
|
---|
[1520] | 130 | cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<endl;
|
---|
| 131 |
|
---|
[1463] | 132 | //---------------------------------------------------------
|
---|
| 133 | } catch (PException & exc) {
|
---|
| 134 | cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 135 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | return;
|
---|
| 139 | }
|
---|