source: Sophya/trunk/ArchTOIPipe/ProcWSophya/toi2map.cc@ 1496

Last change on this file since 1496 was 1466, checked in by cmv, 24 years ago

adapt getData cmv 11/4/01

File size: 3.7 KB
Line 
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////////////////////////////////////////////////////////////////////////
9TOI2Map::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
36TOI2Map::~TOI2Map()
37{
38 if(mWSph && !mWSphInternal) delete mWSph;
39}
40
41////////////////////////////////////////////////////////////////////////
42void 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////////////////////////////////////////////////////////////////////////
50void TOI2Map::run()
51{
52long snb = getMinIn();
53long sne = getMaxIn();
54
55if(snb>sne) {
56 cout<<"TOI2Map::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
57 throw ParmError("TOI2Map::run() - Bad sample interval");
58}
59if(!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
66try {
67
68int ii;
69uint_4 mNSnFill=0, mNpixFill=0, NFill[NFILL];
70for(ii=0;ii<NFILL;ii++) NFill[ii]=0;
71
72// Remplissage des spheres
73for(int s=snb;s<=sne;s++) {
74 int_8 fgbolo = 0;
75 double bolo;
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
79 getData(2,s,bolo,fgbolo);
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.;
93 } else phi = alpha * M_PI/12.;
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
127return;
128}
Note: See TracBrowser for help on using the repository browser.