[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 | {
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | Map2TOI::~Map2TOI()
|
---|
| 13 | {
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | ////////////////////////////////////////////////////////////////////////
|
---|
| 17 | void Map2TOI::init() {
|
---|
| 18 | cout << "Map2TOI::init" << endl;
|
---|
| 19 | declareInput("AlphaIn"); // input index 0
|
---|
| 20 | declareInput("DeltaIn"); // input index 1
|
---|
| 21 | declareOutput("AlphaOut"); // output index 0
|
---|
| 22 | declareOutput("DeltaOut"); // output index 1
|
---|
| 23 | declareOutput("BoloOut"); // output index 2
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////
|
---|
| 27 | void Map2TOI::run() {
|
---|
| 28 |
|
---|
| 29 | if(mSph.NbPixels()<1) {
|
---|
| 30 | cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
|
---|
| 31 | throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | long snb = getMinIn();
|
---|
| 35 | long sne = getMaxIn();
|
---|
| 36 | if(snb>sne) {
|
---|
| 37 | cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
| 38 | throw ParmError("Map2TOI::run() - Bad sample interval");
|
---|
| 39 | }
|
---|
| 40 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
|
---|
| 41 | cout<<"Map2TOI::run() - Input TOI (AlphaIn or DeltaIn) not connected! "<<endl;
|
---|
| 42 | throw ParmError("Map2TOI::run() Output TOI (AlphaIn or DeltaIn) not connected!");
|
---|
| 43 | }
|
---|
| 44 | bool connected_AlphaOut = checkOutputTOIIndex(0);
|
---|
| 45 | bool connected_DeltaOut = checkOutputTOIIndex(1);
|
---|
| 46 | if(!checkOutputTOIIndex(2)) {
|
---|
| 47 | cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
|
---|
| 48 | throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | //---------------------------------------------------------
|
---|
| 52 | try {
|
---|
| 53 |
|
---|
| 54 | for(int k=snb;k<=sne;k++) {
|
---|
| 55 |
|
---|
[1466] | 56 | int_8 flg = 0;
|
---|
[1514] | 57 | // double alpha = getData(0,k); // alpha entre [0,24[ en heures
|
---|
| 58 | // if(alpha<0. || alpha>=24.) flg=1;
|
---|
| 59 | // On passe l'angle en longitude en degres - de [0,360[ deg
|
---|
| 60 | double alpha = getData(0,k); // alpha entre [0,360[ en heures
|
---|
| 61 | if(alpha<0. || alpha>=360.) flg=1;
|
---|
[1463] | 62 | double delta = getData(1,k); // delta entre [-90,90] en degres
|
---|
[1466] | 63 | if(delta<-90. || delta>90.) flg=1;
|
---|
| 64 | double bolo = -99999.;
|
---|
[1463] | 65 |
|
---|
[1466] | 66 | if(!flg) {
|
---|
[1514] | 67 | // double phi = alpha *M_PI/12.; // sphere phi entre [0,2*Pi] en radian
|
---|
| 68 | double phi = alpha *M_PI/180.; // sphere phi entre [0,2*Pi] en radian
|
---|
[1466] | 69 | double teta = (90.-delta) *M_PI/180.; // sphere teta entre [0,Pi] en radian
|
---|
| 70 | bolo = mSph(teta,phi);
|
---|
| 71 | }
|
---|
[1463] | 72 |
|
---|
| 73 | if(connected_AlphaOut) putData(0,k,alpha,0);
|
---|
| 74 | if(connected_DeltaOut) putData(1,k,delta,0);
|
---|
[1466] | 75 | putData(2,k,bolo,flg);
|
---|
[1463] | 76 | }
|
---|
| 77 |
|
---|
| 78 | //---------------------------------------------------------
|
---|
| 79 | } catch (PException & exc) {
|
---|
| 80 | cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 81 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | return;
|
---|
| 85 | }
|
---|