[1463] | 1 | #include "machdefs.h"
|
---|
| 2 | #include "toimanager.h"
|
---|
| 3 | #include "pexceptions.h"
|
---|
| 4 | #include "ctimer.h"
|
---|
| 5 | #include "toi2map.h"
|
---|
| 6 | #include "xastropack.h"
|
---|
| 7 |
|
---|
| 8 | ////////////////////////////////////////////////////////////////////////
|
---|
| 9 | TOI2Map::TOI2Map(SphereHEALPix<r_8>* sph,SphereHEALPix<r_8>* wsph)
|
---|
| 10 | : mSph(sph), mWSph(wsph), mWSphInternal(false), mTypCoor(false), mActualYear(2001.)
|
---|
| 11 | {
|
---|
| 12 | if(mSph->NbPixels()<1) {
|
---|
| 13 | cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mSph "
|
---|
| 14 | <<mSph->NbPixels()<<endl;
|
---|
| 15 | throw ParmError("TOI2Map::TOI2Map() - Bad number of pixels in sphere");
|
---|
| 16 | }
|
---|
| 17 | mSph->SetPixels(0.);
|
---|
| 18 | int nlat = mSph->SizeIndex();
|
---|
| 19 |
|
---|
| 20 | if(mWSph==NULL) {
|
---|
| 21 | mWSph = new SphereHEALPix<r_8>(nlat);
|
---|
| 22 | mWSphInternal = true;
|
---|
| 23 | } else {
|
---|
| 24 | mWSphInternal = false;
|
---|
| 25 | if(nlat != mWSph->SizeIndex()) mWSph->Resize(nlat);
|
---|
| 26 | }
|
---|
| 27 | if(mWSph->NbPixels()<1) {
|
---|
| 28 | cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mWSph "
|
---|
| 29 | <<mWSph->NbPixels()<<endl;
|
---|
| 30 | throw ParmError("TOI2Map::TOI2Map() - Bad number of pixels in sphere");
|
---|
| 31 | }
|
---|
| 32 | mWSph->SetPixels(0);
|
---|
| 33 |
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | TOI2Map::~TOI2Map()
|
---|
| 37 | {
|
---|
| 38 | if(mWSph && !mWSphInternal) delete mWSph;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | ////////////////////////////////////////////////////////////////////////
|
---|
| 42 | void TOI2Map::init() {
|
---|
| 43 | cout << "TOI2Map::init" << endl;
|
---|
| 44 | declareInput("AlphaIn"); // input index 0
|
---|
| 45 | declareInput("DeltaIn"); // input index 1
|
---|
| 46 | declareInput("BoloIn"); // input index 2
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | ////////////////////////////////////////////////////////////////////////
|
---|
| 50 | void TOI2Map::run()
|
---|
| 51 | {
|
---|
| 52 | long snb = getMinIn();
|
---|
| 53 | long sne = getMaxIn();
|
---|
| 54 |
|
---|
| 55 | if(snb>sne) {
|
---|
| 56 | cout<<"TOI2Map::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
| 57 | throw ParmError("TOI2Map::run() - Bad sample interval");
|
---|
| 58 | }
|
---|
| 59 | if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1) || !checkInputTOIIndex(2)) {
|
---|
| 60 | cout<<"TOI2Map::run() - Input TOI (AlphaIn or DeltaIn or BoloIn) not connected! "<<endl;
|
---|
| 61 | throw ParmError("TOI2Map::run() Output TOI (AlphaIn or DeltaIn or BoloIn) not connected!");
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | //---------------------------------------------------------
|
---|
| 65 | #define NFILL 25
|
---|
| 66 | try {
|
---|
| 67 |
|
---|
| 68 | int ii;
|
---|
| 69 | uint_4 mNSnFill=0, mNpixFill=0, NFill[NFILL];
|
---|
| 70 | for(ii=0;ii<NFILL;ii++) NFill[ii]=0;
|
---|
| 71 |
|
---|
| 72 | // Remplissage des spheres
|
---|
| 73 | for(int s=snb;s<=sne;s++) {
|
---|
[1466] | 74 | int_8 fgbolo = 0;
|
---|
| 75 | double bolo;
|
---|
[1463] | 76 |
|
---|
| 77 | double alpha = getData(0,s); // alpha entre [0,24[ en heures
|
---|
| 78 | double delta = getData(1,s); // delta entre [-90,90] en degres
|
---|
[1466] | 79 | getData(2,s,bolo,fgbolo);
|
---|
[1463] | 80 |
|
---|
| 81 | if(delta<-90. || delta>90.) fgbolo=1;
|
---|
| 82 | if(alpha<0. || alpha>=24.) fgbolo=1;
|
---|
| 83 | if(bolo<-32767.) fgbolo=1; // Bidouille Archeops
|
---|
| 84 |
|
---|
| 85 | if(!fgbolo) {
|
---|
| 86 | // sphere phi entre [0,2*Pi] en radians
|
---|
| 87 | // sphere theta entre [0,Pi] en radians
|
---|
| 88 | double phi,theta;
|
---|
| 89 | if(mTypCoor) {
|
---|
| 90 | double mjd = MJDfrYear(mActualYear);
|
---|
| 91 | EqtoGal(mjd,alpha,delta,&alpha,&delta);
|
---|
| 92 | phi = alpha * M_PI/180.;
|
---|
[1466] | 93 | } else phi = alpha * M_PI/12.;
|
---|
[1463] | 94 | theta = (90.-delta)*M_PI/180.;
|
---|
| 95 | int_4 ipix = mSph->PixIndexSph(theta,phi);
|
---|
| 96 | (*mSph)(ipix) += bolo;
|
---|
| 97 | ((*mWSph)(ipix))++;
|
---|
| 98 | mNSnFill++;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | // Remplissage des spheres
|
---|
| 103 | for(int_4 i=0;i<mSph->NbPixels();i++) {
|
---|
| 104 | r_8 wf = (*mWSph)(i);
|
---|
| 105 | if( wf > 0. ) {
|
---|
| 106 | mNpixFill++;
|
---|
| 107 | (*mSph)(i) /= wf;
|
---|
| 108 | }
|
---|
| 109 | int_4 nf = int_4(wf);
|
---|
| 110 | if(nf>=NFILL) nf=NFILL-1; NFill[nf]++;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | cout<<"TOI2Map::run(): mNpixTot="<<mSph->NbPixels()
|
---|
| 114 | <<" mNpixFill="<<mNpixFill
|
---|
| 115 | <<" mNSnFill="<<mNSnFill<<endl
|
---|
| 116 | <<" --> FracSky="<<mNpixFill*100./(double)mSph->NbPixels()<<"%"<<endl
|
---|
| 117 | <<"NFill["<<NFILL<<"] = "<<endl;
|
---|
| 118 | for(ii=0;ii<NFILL;ii++) cout<<NFill[ii]<<" ";
|
---|
| 119 | cout<<endl;
|
---|
| 120 |
|
---|
| 121 | //---------------------------------------------------------
|
---|
| 122 | } catch (PException & exc) {
|
---|
| 123 | cout<<"TOI2Map: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 124 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | return;
|
---|
| 128 | }
|
---|