[1738] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[1809] | 5 | // $Id: map2toi.cc,v 1.10 2001-12-03 20:38:02 cmv Exp $
|
---|
[1738] | 6 |
|
---|
[1463] | 7 | #include "toimanager.h"
|
---|
| 8 | #include "pexceptions.h"
|
---|
| 9 | #include "ctimer.h"
|
---|
| 10 | #include "map2toi.h"
|
---|
[1809] | 11 | // La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
|
---|
| 12 | #include "smathconst.h"
|
---|
[1463] | 13 |
|
---|
| 14 | ////////////////////////////////////////////////////////////////////////
|
---|
| 15 | Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
|
---|
| 16 | : mSph(sph)
|
---|
| 17 | {
|
---|
[1809] | 18 | SetBad();
|
---|
[1520] | 19 | SetEquinox();
|
---|
| 20 | SetCoorIn();
|
---|
| 21 | SetCoorMap();
|
---|
[1463] | 22 | }
|
---|
| 23 |
|
---|
| 24 | Map2TOI::~Map2TOI()
|
---|
| 25 | {
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | ////////////////////////////////////////////////////////////////////////
|
---|
[1762] | 29 | void Map2TOI::Print(::ostream & os)
|
---|
[1530] | 30 | {
|
---|
[1809] | 31 | os<<"Map2TOI::Print -- Sphere NLat = "<<mSph.SizeIndex()<<endl
|
---|
| 32 | <<" - Equinoxe: "<<mActualYear<<" y"<<endl
|
---|
| 33 | <<" - TypCoorIn: "<<mTypCoorIn<<" = "<<DecodeTypAstro(mTypCoorIn)<<endl
|
---|
| 34 | <<" - TypCoorMap: "<<mTypCoorMap<<" = "<<DecodeTypAstro(mTypCoorMap)<<endl;
|
---|
[1530] | 35 | }
|
---|
| 36 |
|
---|
| 37 | ////////////////////////////////////////////////////////////////////////
|
---|
[1463] | 38 | void Map2TOI::init() {
|
---|
| 39 | cout << "Map2TOI::init" << endl;
|
---|
[1520] | 40 | declareInput("Coord1In"); // input index 0
|
---|
| 41 | declareInput("Coord2In"); // input index 1
|
---|
| 42 | declareOutput("Coord1Out"); // output index 0
|
---|
| 43 | declareOutput("Coord2Out"); // output index 1
|
---|
| 44 | declareOutput("BoloOut"); // output index 2
|
---|
[1463] | 45 | }
|
---|
| 46 |
|
---|
| 47 | ////////////////////////////////////////////////////////////////////////
|
---|
| 48 | void Map2TOI::run() {
|
---|
| 49 |
|
---|
| 50 | if(mSph.NbPixels()<1) {
|
---|
| 51 | cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
|
---|
| 52 | throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | long snb = getMinIn();
|
---|
| 56 | long sne = getMaxIn();
|
---|
| 57 | if(snb>sne) {
|
---|
| 58 | cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
| 59 | throw ParmError("Map2TOI::run() - Bad sample interval");
|
---|
| 60 | }
|
---|
| 61 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
|
---|
[1520] | 62 | cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
|
---|
| 63 | throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
|
---|
[1463] | 64 | }
|
---|
[1520] | 65 | bool connected_Coord1Out = checkOutputTOIIndex(0);
|
---|
| 66 | bool connected_Coord2Out = checkOutputTOIIndex(1);
|
---|
[1463] | 67 | if(!checkOutputTOIIndex(2)) {
|
---|
| 68 | cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
|
---|
| 69 | throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
|
---|
| 70 | }
|
---|
[1520] | 71 | if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
|
---|
| 72 | cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
|
---|
| 73 | throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
|
---|
| 74 | }
|
---|
| 75 | if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
|
---|
| 76 | cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
|
---|
| 77 | throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
|
---|
| 78 | }
|
---|
[1463] | 79 |
|
---|
| 80 | //---------------------------------------------------------
|
---|
| 81 | try {
|
---|
| 82 |
|
---|
[1520] | 83 | double mjd = MJDfrYear(mActualYear);
|
---|
[1809] | 84 | cout<<"Map2TOI::run() - modified Julian day "<<mjd<<endl;
|
---|
[1520] | 85 |
|
---|
[1809] | 86 | uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
|
---|
| 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 |
|
---|
[1809] | 96 | // Conversion de CoordIn to Standard
|
---|
| 97 | double phi=-1.;
|
---|
| 98 | CoordConvertToStd(mTypCoorIn,&c1,&c2);
|
---|
| 99 |
|
---|
| 100 | // Conversion dans le systeme astronomique approprie
|
---|
[1520] | 101 | if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq CMap=Gal
|
---|
| 102 | EqtoGal(mjd,c1,c2,&c1,&c2);
|
---|
[1809] | 103 | phi = c1 * Pi/180.;
|
---|
[1520] | 104 | } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
|
---|
| 105 | GaltoEq(mjd,c1,c2,&c1,&c2);
|
---|
[1809] | 106 | phi = c1 * Pi/12.;
|
---|
[1520] | 107 | } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
|
---|
[1809] | 108 | phi = c1 * Pi/180.;
|
---|
[1520] | 109 | } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
|
---|
[1809] | 110 | phi = c1 * Pi/12.;
|
---|
[1520] | 111 | }
|
---|
[1809] | 112 | ToCoLat(&c2,TypUniteD);
|
---|
| 113 | double theta = c2 * Pi/180.;
|
---|
| 114 | if(phi<0. || phi>=2*Pi || theta<0. || theta>Pi)
|
---|
| 115 | {BadCoorRange++; flg = mBadFlag; }
|
---|
[1520] | 116 |
|
---|
[1466] | 117 | if(!flg) {
|
---|
[1520] | 118 | bolo = mSph(theta,phi);
|
---|
| 119 | mSnFilled++;
|
---|
[1466] | 120 | }
|
---|
[1463] | 121 |
|
---|
[1520] | 122 | if(connected_Coord1Out) putData(0,k,coord1,flg);
|
---|
| 123 | if(connected_Coord2Out) putData(1,k,coord2,flg);
|
---|
[1466] | 124 | putData(2,k,bolo,flg);
|
---|
[1463] | 125 | }
|
---|
| 126 |
|
---|
[1809] | 127 | cout<<"TOI2Map::run: Samples Read "<<mSnRead
|
---|
| 128 | <<" Filled "<<mSnFilled
|
---|
| 129 | <<" BadCoorRange="<<BadCoorRange<<endl;
|
---|
[1520] | 130 |
|
---|
[1463] | 131 | //---------------------------------------------------------
|
---|
| 132 | } catch (PException & exc) {
|
---|
| 133 | cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 134 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | return;
|
---|
| 138 | }
|
---|