source: Sophya/trunk/ArchTOIPipe/ProcWSophya/map2toi.cc@ 2227

Last change on this file since 2227 was 2040, checked in by ansari, 23 years ago

Correction totnscount++ ds Map2TOI - Reza 30/5/2002

File size: 4.5 KB
RevLine 
[1738]1// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
2// Eric Aubourg
3// Christophe Magneville
4// Reza Ansari
[2040]5// $Id: map2toi.cc,v 1.12 2002-05-31 15:49:00 ansari Exp $
[1738]6
[1463]7#include "toimanager.h"
8#include "pexceptions.h"
9#include "ctimer.h"
10#include "map2toi.h"
[1809]11// La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
12#include "smathconst.h"
[1463]13
14////////////////////////////////////////////////////////////////////////
15Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
[2039]16: mSph(sph), totnscount(0)
[1463]17{
[1809]18 SetBad();
[1520]19 SetEquinox();
20 SetCoorIn();
21 SetCoorMap();
[1463]22}
23
24Map2TOI::~Map2TOI()
25{
26}
27
28////////////////////////////////////////////////////////////////////////
[1762]29void Map2TOI::Print(::ostream & os)
[1530]30{
[1809]31 os<<"Map2TOI::Print -- Sphere NLat = "<<mSph.SizeIndex()<<endl
32 <<" - Equinoxe: "<<mActualYear<<" y"<<endl
33 <<" - TypCoorIn: "<<mTypCoorIn<<" = "<<DecodeTypAstro(mTypCoorIn)<<endl
34 <<" - TypCoorMap: "<<mTypCoorMap<<" = "<<DecodeTypAstro(mTypCoorMap)<<endl;
[1530]35}
36
37////////////////////////////////////////////////////////////////////////
[1463]38void Map2TOI::init() {
39 cout << "Map2TOI::init" << endl;
[1520]40 declareInput("Coord1In"); // input index 0
41 declareInput("Coord2In"); // input index 1
42 declareOutput("Coord1Out"); // output index 0
43 declareOutput("Coord2Out"); // output index 1
44 declareOutput("BoloOut"); // output index 2
[1463]45}
46
47////////////////////////////////////////////////////////////////////////
48void Map2TOI::run() {
49
50if(mSph.NbPixels()<1) {
51 cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
52 throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
53}
54
55long snb = getMinIn();
56long sne = getMaxIn();
57if(snb>sne) {
58 cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
59 throw ParmError("Map2TOI::run() - Bad sample interval");
60}
61if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
[1520]62 cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
63 throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
[1463]64}
[1520]65bool connected_Coord1Out = checkOutputTOIIndex(0);
66bool connected_Coord2Out = checkOutputTOIIndex(1);
[1463]67if(!checkOutputTOIIndex(2)) {
68 cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
69 throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
70}
[1520]71if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
72 cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
73 throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
74}
75if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
76 cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
77 throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
78}
[1463]79
80//---------------------------------------------------------
81try {
82
[1520]83double mjd = MJDfrYear(mActualYear);
[1809]84cout<<"Map2TOI::run() - modified Julian day "<<mjd<<endl;
[1520]85
[1809]86uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
87
[1463]88for(int k=snb;k<=sne;k++) {
89
[1532]90 uint_8 flg = 0;
[1520]91 double coord1 = getData(0,k);
92 double coord2 = getData(1,k);
93 double c1 = coord1, c2=coord2, bolo = -99999.;
94 mSnRead++;
[1463]95
[1809]96 // Conversion de CoordIn to Standard
97 double phi=-1.;
98 CoordConvertToStd(mTypCoorIn,&c1,&c2);
99
100 // Conversion dans le systeme astronomique approprie
[1520]101 if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq CMap=Gal
102 EqtoGal(mjd,c1,c2,&c1,&c2);
[1809]103 phi = c1 * Pi/180.;
[1520]104 } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
105 GaltoEq(mjd,c1,c2,&c1,&c2);
[1809]106 phi = c1 * Pi/12.;
[1520]107 } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
[1809]108 phi = c1 * Pi/180.;
[1520]109 } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
[1809]110 phi = c1 * Pi/12.;
[1520]111 }
[1809]112 ToCoLat(&c2,TypUniteD);
113 double theta = c2 * Pi/180.;
114 if(phi<0. || phi>=2*Pi || theta<0. || theta>Pi)
115 {BadCoorRange++; flg = mBadFlag; }
[1520]116
[1466]117 if(!flg) {
[1520]118 bolo = mSph(theta,phi);
119 mSnFilled++;
[1466]120 }
[1463]121
[1520]122 if(connected_Coord1Out) putData(0,k,coord1,flg);
123 if(connected_Coord2Out) putData(1,k,coord2,flg);
[1466]124 putData(2,k,bolo,flg);
[2040]125 totnscount++;
[1463]126}
127
[1809]128cout<<"TOI2Map::run: Samples Read "<<mSnRead
129 <<" Filled "<<mSnFilled
130 <<" BadCoorRange="<<BadCoorRange<<endl;
[1520]131
[1463]132//---------------------------------------------------------
133} catch (PException & exc) {
134 cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
135 <<"\n .... Msg= "<<exc.Msg()<<endl;
136}
137
138return;
139}
Note: See TracBrowser for help on using the repository browser.