[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;
|
---|
[1463] | 57 | double alpha = getData(0,k); // alpha entre [0,24[ en heures
|
---|
[1466] | 58 | if(alpha<0. || alpha>=24.) flg=1;
|
---|
[1463] | 59 | double delta = getData(1,k); // delta entre [-90,90] en degres
|
---|
[1466] | 60 | if(delta<-90. || delta>90.) flg=1;
|
---|
| 61 | double bolo = -99999.;
|
---|
[1463] | 62 |
|
---|
[1466] | 63 | if(!flg) {
|
---|
| 64 | double phi = alpha *M_PI/12.; // sphere phi entre [0,2*Pi] en radian
|
---|
| 65 | double teta = (90.-delta) *M_PI/180.; // sphere teta entre [0,Pi] en radian
|
---|
| 66 | bolo = mSph(teta,phi);
|
---|
| 67 | }
|
---|
[1463] | 68 |
|
---|
| 69 | if(connected_AlphaOut) putData(0,k,alpha,0);
|
---|
| 70 | if(connected_DeltaOut) putData(1,k,delta,0);
|
---|
[1466] | 71 | putData(2,k,bolo,flg);
|
---|
[1463] | 72 | }
|
---|
| 73 |
|
---|
| 74 | //---------------------------------------------------------
|
---|
| 75 | } catch (PException & exc) {
|
---|
| 76 | cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 77 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | return;
|
---|
| 81 | }
|
---|