// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: flag2map.cc,v 1.3 2002-05-31 09:55:42 cecile Exp $ #include "machdefs.h" #include "toimanager.h" #include "pexceptions.h" #include "ctimer.h" #include "flag2map.h" // La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta #include "smathconst.h" //////////////////////////////////////////////////////////////////////// FLAG2Map::FLAG2Map(PixelMap* map,PixelMap* wmap) : mMap(map), mWMap(wmap), mWMapInternal(false), totnscount(0) { SetEquinox(); SetCoorIn(); SetCoorMap(); SetTestFlag(); SetTestMin(); SetTestMax(); if(mMap->NbPixels()<1) { cout<<"FLAG2Map::FLAG2Map() Bad number of pixels in sphere mMap " <NbPixels()<SetPixels(0.); int nlat = mMap->SizeIndex(); string typmap = mMap->TypeOfMap(); if(mWMap==NULL) { // We would need a cloning function in maps. $$TBD$$ $CHECK$ if (typmap == "LOCAL") { mWMap = new LocalMap(*(LocalMap*)mMap); } else if (typmap == "RING") { mWMap = new SphereHEALPix(nlat); } else { cout << "FLAG2Map::FLAG2Map() cannot handle map of type " << typmap << endl; throw ParmError("FLAG2Map::FLAG2Map() - bad type of map"); } mWMapInternal = true; } else { mWMapInternal = false; if(nlat != mWMap->SizeIndex()) { cout<<"FLAG2Map::FLAG2Map() Bad size for sphere mWMap, does not " <<"correspond to mMap : "<SizeIndex()<<", "<SizeIndex()< *)mWMap)->Resize(nlat); cout<<"Resize have been done..."<NbPixels()<1) { cout<<"FLAG2Map::FLAG2Map() Bad number of pixels in sphere mWMap " <NbPixels()<SetPixels(0); } FLAG2Map::~FLAG2Map() { if(mWMap && mWMapInternal) delete mWMap; } //////////////////////////////////////////////////////////////////////// void FLAG2Map::Print(::ostream & os) { os<<"FLAG2Map::Print -- Map type " << mMap->TypeOfMap() << " SizeIndex = "<SizeIndex()<sne) { cout<<"FLAG2Map::run() - Bad sample interval"< 0) cout << "sn " << s << " val " << bolo << " fgbolo " << fgbolo << endl; // Comme il n'y a pas de toi en sortie, il faut dire // aux processeur/toi que l'on a plus besoin des donnees. if (s%100 == 0) wontNeedBefore(s-1); // if(mTFlag && fgbolo&mBadFlag) continue; if(mTMin && bolomValMax) continue; if (fgbolo != 2) continue; // pas un glitch; // sphere phi entre [0,2*Pi] en radians // sphere theta entre [0,Pi] en radians double phi=-1.; CoordConvertToStd(mTypCoorIn,&coord1,&coord2); if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // Eq -> Gal EqtoGal(mjd,coord1,coord2,&coord1,&coord2); phi = coord1 * Pi/180.; } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // Gal -> Eq GaltoEq(mjd,coord1,coord2,&coord1,&coord2); phi = coord1 * Pi/12.; } else if(mTypCoorMap&TypCoordGal) { // Gal -> Gal phi = coord1 * Pi/180.; } else if(mTypCoorMap&TypCoordEq) { // Eq -> Eq phi = coord1 * Pi/12.; } ToCoLat(&coord2,TypUniteD); double theta = coord2 * Pi/180.; if(phi<0. | phi>=2*Pi || theta<0. || theta>Pi) {BadCoorRange++; continue;} int_4 ipix = mMap->PixIndexSph(theta,phi); (*mMap)(ipix) += bolo; ((*mWMap)(ipix)) += 1; mNSnFill++; } cout<<"FLAG2Map::run(): Fin de boucle sur les sampleNum"<NbPixels();i++) { r_8 wf = (*mWMap)(i); if(wf>0.) {mNpixFill++; (*mMap)(i) /= wf;} int_4 nf = int_4(wf); if(nf>=NFILL) nf=NFILL-1; NFill[nf]++; } cout<<"FLAG2Map::run(): mNpixTot="<NbPixels() <<" mNpixFill="< FracSky="<NbPixels()<<"%" <<" NFill["<