[801] | 1 | // Dominique YVON, CEA/DAPNIA/SPP 02/2000
|
---|
| 2 |
|
---|
| 3 | #include <iomanip.h>
|
---|
[1148] | 4 | #include <new>
|
---|
[801] | 5 | #ifdef __MWERKS__
|
---|
| 6 | #include "macenvvariables.h"
|
---|
| 7 | #else
|
---|
| 8 | # define ERROR_LABEL -32768
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
| 11 | #include "makebolotimeline.h"
|
---|
[1148] | 12 | //#include "fitsioserver.h"
|
---|
[801] | 13 |
|
---|
| 14 |
|
---|
| 15 | MakeBoloTimeline::MakeBoloTimeline(char file[], AbsLightSource& LSrc,
|
---|
[1148] | 16 | AbsLobeNoPolar& Lobe, SpectralResponse& Filter, Normalisation Norm)
|
---|
| 17 | { IsSigCalctool=true;
|
---|
| 18 | IsPtSrcInBandtool=false;
|
---|
| 19 | pSigCalcTool=new SigCalcTool(&LSrc,&Lobe,&Filter);
|
---|
| 20 | MakeBoloTimeline(file,*pSigCalcTool,Norm);
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | MakeBoloTimeline::MakeBoloTimeline(char file[], LightPtSrcLevSInBand& LSrc,
|
---|
| 24 | MeanFreqLobe& Lobe, LevSPanckBand band, Normalisation Norm)
|
---|
| 25 | { IsSigCalctool=false;
|
---|
| 26 | IsPtSrcInBandtool=true;
|
---|
| 27 |
|
---|
| 28 | pPtSrcInBandCalTools=new PtSrcInBandCalTools(&LSrc,&Lobe,band);
|
---|
| 29 | MakeBoloTimeline(file,*pPtSrcInBandCalTools,Norm);
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | MakeBoloTimeline::MakeBoloTimeline(char file[], AbsCalcTool& Tool, Normalisation Norm)
|
---|
| 33 | :NormMethode(Norm), ptool(&Tool)
|
---|
| 34 | {
|
---|
| 35 |
|
---|
[801] | 36 | #ifndef __MWERKS__
|
---|
| 37 | char* PATHResults=getenv("PATHResults");
|
---|
| 38 | #endif
|
---|
[1148] | 39 |
|
---|
| 40 | saveReadMe(file);
|
---|
| 41 |
|
---|
[801] | 42 | char filecur[150];
|
---|
[1148] | 43 | sprintf(filecur,"%s%s.dat", PATHResults,file);
|
---|
| 44 |
|
---|
| 45 | pMystr= new ofstream(filecur,ios::out|ios::trunc);
|
---|
| 46 | // pMystr->setf(ios::scientific);
|
---|
| 47 | (*pMystr)<<setprecision(5);
|
---|
| 48 |
|
---|
| 49 | #ifdef VisuIsActive
|
---|
| 50 | // Visu de controle
|
---|
| 51 | try
|
---|
| 52 | { pSphere=new SphereHEALPix<r_4>(64);
|
---|
| 53 | pSphereInt=new SphereHEALPix<uint_2>(64);
|
---|
| 54 | }
|
---|
| 55 | catch (bad_alloc)
|
---|
| 56 | { cerr<<"bad alloc in MakeBoloTimeline:"<<file<<endl;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | sprintf(Name, "%s%s%s",PATHResults,file,".visu");
|
---|
| 60 | #endif
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | MakeBoloTimeline::~MakeBoloTimeline()
|
---|
| 65 | {
|
---|
| 66 | (*pMystr)<<flush;
|
---|
| 67 | pMystr->close();
|
---|
| 68 | delete pMystr;
|
---|
| 69 |
|
---|
| 70 | if(IsSigCalctool) delete pSigCalcTool;
|
---|
| 71 | if(IsPtSrcInBandtool) delete pPtSrcInBandCalTools;
|
---|
| 72 |
|
---|
| 73 | #ifdef VisuIsActive
|
---|
| 74 | for(long index=0; index<(*pSphere).NbPixels();index++)
|
---|
| 75 | if ((*pSphereInt).PixVal(index)!=0)
|
---|
| 76 | (*pSphere).PixVal(index)=(*pSphere).PixVal(index)/(*pSphereInt).PixVal(index);
|
---|
| 77 |
|
---|
| 78 | // FitsIoServer FitsServer;
|
---|
| 79 | #ifndef __MWERKS__
|
---|
| 80 | char* PATHResults=getenv("PATHResults");
|
---|
| 81 | #endif
|
---|
| 82 |
|
---|
| 83 | // FitsServer.Mollweide_picture_projection((*pSphere),Name); // BUGG XXXXXXXXX
|
---|
| 84 |
|
---|
| 85 | delete pSphere;
|
---|
| 86 | delete pSphereInt;
|
---|
| 87 | #endif
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | void MakeBoloTimeline::addToStreamArchTOI(double theta,double phi)
|
---|
| 91 | { // Theta en heures, Phi en degres, systeme RA Dec
|
---|
| 92 | if((theta==ERROR_LABEL)||(phi==ERROR_LABEL)) return;
|
---|
| 93 |
|
---|
| 94 | // On passe en Radian
|
---|
| 95 | double thetaRad=theta*15./180*M_PI;
|
---|
| 96 | double phiRad=phi/180.*M_PI;
|
---|
| 97 |
|
---|
| 98 | // Go to Galactic ccordinates
|
---|
| 99 | double lgalax=0.;
|
---|
| 100 | double bgalax=0.;
|
---|
| 101 | kmg_eulerRad(thetaRad,phiRad,1,&lgalax,&bgalax);
|
---|
| 102 |
|
---|
| 103 | // Add to time line
|
---|
| 104 | addToStream(lgalax,bgalax);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | void MakeBoloTimeline::addToStream(double lgalax,double bgalax)
|
---|
| 108 | { // lgalax et bgalax en Radian, Systeme coord Galactique J2000
|
---|
| 109 |
|
---|
| 110 | double theta=M_PI/2.-bgalax; // Coordonnees Spheriques galactiques
|
---|
| 111 | double phi=lgalax;
|
---|
| 112 | double value;
|
---|
| 113 |
|
---|
| 114 | switch (NormMethode)
|
---|
| 115 | {
|
---|
| 116 | case RayleighJeans: // Value en TempeRJ
|
---|
| 117 | { value= NormRJ*ptool->compPixelQD(theta,phi);
|
---|
| 118 | break;
|
---|
| 119 | }
|
---|
| 120 | case TempeCMB: // Value en tempeCMB
|
---|
| 121 | { value= NormTCMB*ptool->compPixelQD(theta,phi);
|
---|
| 122 | break;
|
---|
| 123 | }
|
---|
| 124 | default: // Value en power
|
---|
| 125 | { value =ptool->compPixelQD(theta,phi);
|
---|
| 126 | break;
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
| 129 | (*pMystr)<<lgalax<<'\t'<<bgalax<<'\t'<<value<<'\n';
|
---|
| 130 |
|
---|
| 131 | long PixelNumb=(*pSphere).PixIndexSph(theta,phi);
|
---|
| 132 | (*pSphere).PixVal(PixelNumb)+=value;
|
---|
| 133 | (*pSphereInt).PixVal(PixelNumb)++;
|
---|
| 134 |
|
---|
| 135 | return;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | void MakeBoloTimeline::saveReadMe(char File[])
|
---|
| 139 | { char filecur[150];
|
---|
| 140 | // Fill Header file for ascii output
|
---|
| 141 | sprintf(filecur,"%s%s.ReadMe", PATHResults,File);
|
---|
[801] | 142 | cout<<filecur<<endl;
|
---|
| 143 | ofstream ReadMe(filecur,ios::out|ios::trunc);
|
---|
| 144 |
|
---|
| 145 | ReadMe<<" Fichier de timeline pour:"<<endl;
|
---|
[1148] | 146 | ptool->print(ReadMe);
|
---|
[801] | 147 |
|
---|
[1148] | 148 | NormRJ=ptool->NormKelvinRayleighJeans();
|
---|
| 149 | NormTCMB=ptool->NormKelvinCMB();
|
---|
[801] | 150 |
|
---|
| 151 | ReadMe<< setprecision(3);
|
---|
| 152 | ReadMe<<" Constantes de normalisation"<<endl;
|
---|
| 153 | ReadMe<<" RayleighJeans: "<<NormRJ<< " KelvinRJ/(W/m2)"<<endl;
|
---|
| 154 | ReadMe<<" TempeCMB: "<<NormTCMB<< " Kelvin CMB/(W/m2)"<<endl;
|
---|
| 155 |
|
---|
| 156 | ReadMe<<"Cette carte est en unit: ";
|
---|
| 157 | switch(NormMethode)
|
---|
| 158 | {
|
---|
| 159 | case TempeCMB:
|
---|
| 160 | { ReadMe<< "Kelvin CMB"<<endl;
|
---|
| 161 | break;
|
---|
| 162 | }
|
---|
| 163 | case RayleighJeans:
|
---|
| 164 | { ReadMe<< "Kelvin RayleighJeans"<<endl;
|
---|
| 165 | break;
|
---|
| 166 | }
|
---|
| 167 | default: ReadMe<< "Watt/m2 effectif de mirroir"<<endl;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
[1148] | 170 | ReadMe<<"Fichier coordones galactique J2000ecrit selon le format"<<endl;
|
---|
| 171 | ReadMe<<"l_galax(Radian)\tb_galax(Radian)\tAbove Unit"<<endl;
|
---|
| 172 |
|
---|
[801] | 173 | // J'espere que c'est assez
|
---|
| 174 | ReadMe.close();
|
---|
| 175 |
|
---|
[1148] | 176 | return;
|
---|
[801] | 177 | }
|
---|
| 178 |
|
---|