// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: toi2map.cc,v 1.32 2003-01-10 08:04:47 aubourg Exp $ #include "machdefs.h" #include "toimanager.h" #include "pexceptions.h" #include "ctimer.h" #include "toi2map.h" // La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta #include "smathconst.h" #include "fitsspherehealpix.h" //////////////////////////////////////////////////////////////////////// TOI2Map::TOI2Map(string mapFName, string wmapFName, int nside) : mMap(new SphereHEALPix(nside)), mWMap(new SphereHEALPix(nside)), mWMapInternal(false), totnscount(0), usednscount(0), mMapFName(mapFName), mWMapFName(wmapFName) { commonConst(); } //////////////////////////////////////////////////////////////////////// TOI2Map::TOI2Map(PixelMap* map,PixelMap* wmap) : mMap(map), mWMap(wmap), mWMapInternal(false), totnscount(0), usednscount(0), mMapFName(""), mWMapFName("") { commonConst(); } void TOI2Map::commonConst() { SetEquinox(); SetCoorIn(); SetCoorMap(); SetCalibrationFactor(); SetTestFlag(); SetTestMin(); SetTestMax(); if(mMap->NbPixels()<1) { cout<<"TOI2Map::TOI2Map() 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,false); } 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 : "<SizeIndex()<<", "<SizeIndex()< *)mWMap)->Resize(nlat); cout<<"Resize have been done..."<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"<mValMax)) {nbadsn++; continue;} usednscount++; // 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); if ((ipix < 0) || (ipix >= mMap->NbPixels()) ) continue; /* if (mNSnFill % 1000 == 0) { cout << ipix << " " << (*mMap)(ipix) << " + " << bolo*mCalibFactor << " " << ((*mWMap)(ipix)) << endl; } */ (*mMap)(ipix) += bolo*mCalibFactor; ((*mWMap)(ipix)) += 1; mNSnFill++; } cout<<"TOI2Map::run(): End of SN loop - TotalProcessedSamples=" < " << (*mMap)(i); } */ int_4 nf = int_4(wf); if(nf>=NFILL) nf=NFILL-1; NFill[nf]++; } cout<<"TOI2Map::run(): mNpixTot="<NbPixels() <<" mNpixFill="< FracSky="<NbPixels()<<"%" <<" NFill["<*)mMap; } { FitsOutFile sfits(mWMapFName,FitsFile::clear); sfits << * (SphereHEALPix*)mWMap; } } //--------------------------------------------------------- } catch (PException & exc) { cout<<"TOI2Map: Catched Exception "<<(string)typeid(exc).name() <<"\n .... Msg= "<