// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: toi2map.cc,v 1.22 2001-12-01 13:34:08 aubourg Exp $ #include "machdefs.h" #include "toimanager.h" #include "pexceptions.h" #include "ctimer.h" #include "toigmap.h" //////////////////////////////////////////////////////////////////////// TOI2Map::TOI2Map(PixelMap* map,PixelMap* wmap) : mMap(map), mWMap(map), mWMapInternal(false) { SetEquinox(); SetCoorIn(); SetCoorOut(); SetTestFlag(); SetTestMin(); SetTestMax(); mIsColat = false; if(mMap->NbPixels()<1) { cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mMap " <NbPixels()<SetPixels(0.); int nlat = mMap->SizeIndex(); if(mWMap==NULL) { // We would need a cloning function in maps. $$TBD$$ $CHECK$ string typmap = mMap->TypeOfMap(); if (typmap == "LOCAL") { mWMap = new LocalMap(*(LocalMap*)mMap); } else if (typmap == "RING") { mWMap = new SphereHEALPix(nlat); } else { cout << "TOI2Map::TOI2Map() cannot handle map of type " << typmap << endl; throw ParmError("TOI2Map::TOI2Map() - bad type of map"); } mWMapInternal = true; } else { mWMapInternal = false; if(nlat != mWMap->SizeIndex()) { cout << "TOI2Map::TOI2Map() Bad size for sphere mWMap, does not " << "correspond to mMap : " << mMap->SizeIndex() << ", " << mWMap->SizeIndex() << endl; throw ParmError("TOI2Map::TOI2Map() - Different sizes for map and wmap"); } } if(mWMap->NbPixels()<1) { cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mWMap " <NbPixels()<SetPixels(0); } TOI2Map::~TOI2Map() { if(mWMap && mWMapInternal) delete mWMap; } //////////////////////////////////////////////////////////////////////// void TOI2Map::Print(::ostream & os) { os<<"TOI2Map::Print -- Map type " << mMap->TypeOfMap() << " SizeIndex = "<SizeIndex()<sne) { cout<<"TOI2Map::run() - Bad sample interval"<=i0+bufsz) { i0 = s; int nget = (sne-s+1mValMax) continue; // sphere phi entre [0,2*Pi] en radians // sphere theta entre [0,Pi] en radians double phi=-1.,theta; CoordConvertToStd(mTypCoorIn,coord1,coord2); if(mTypCoorIn&TypCoordEq && mTypCoorOut&TypCoordGal) { // Eq -> Gal EqtoGal(mjd,coord1,coord2,&coord1,&coord2); phi = coord1 * M_PI/180.; } else if(mTypCoorIn&TypCoordGal && mTypCoorOut&TypCoordEq) { // Gal -> Eq GaltoEq(mjd,coord1,coord2,&coord1,&coord2); phi = coord1 * M_PI/12.; } else if(mTypCoorOut&TypCoordGal) { // Gal -> Gal phi = coord1 * M_PI/180.; } else if(mTypCoorOut&TypCoordEq) { // Eq -> Eq phi = coord1 * M_PI/12.; } if (phi<0) phi += 2*M_PI; if (phi>=2*M_PI) phi -= 2*M_PI; if (mIsColat) { theta = coord2 * M_PI/180; } else { theta = (90.-coord2) * M_PI/180.; } if(phi<0. || phi>=2*M_PI) continue; if(theta<0. || theta>=M_PI) continue; int_4 ipix = mMap->PixIndexSph(theta,phi); (*mMap)(ipix) += bolo; ((*mWMap)(ipix)) += 1; mNSnFill++; } cout<<"TOI2Map::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<<"TOI2Map::run(): mNpixTot="<NbPixels() <<" mNpixFill="< FracSky="<NbPixels()<<"%" <<" NFill["<