Changeset 886 in Sophya for trunk/SophyaProg
- Timestamp:
- Apr 11, 2000, 6:11:05 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/PMixer/skymixer.cc
r885 r886 17 17 #include "spherehealpix.h" 18 18 #include "fiospherehealpix.h" 19 19 #include "fitsspherehealpix.h" 20 20 #include "radspecvector.h" 21 21 #include "blackbody.h" … … 101 101 so = NULL; 102 102 103 try {104 string dcard = arg[1];105 cout << " Decoding parameters from file " << dcard << endl;106 dc.ReadFile(dcard);107 108 rc = CheckCards(dc, msg);109 if (rc) {110 cerr << " Error condition -> Rc= " << rc << endl;111 cerr << " Msg= " << msg << endl;112 return(rc);113 }114 }115 catch (PException exc) {116 msg = exc.Msg();117 cerr << " !!!! skymixer/ Readcard - Catched exception - Msg= " << exc.Msg() << endl;118 return(90);119 }103 try { 104 string dcard = arg[1]; 105 cout << " Decoding parameters from file " << dcard << endl; 106 dc.ReadFile(dcard); 107 108 rc = CheckCards(dc, msg); 109 if (rc) { 110 cerr << " Error condition -> Rc= " << rc << endl; 111 cerr << " Msg= " << msg << endl; 112 return(rc); 113 } 114 } 115 catch (PException exc) { 116 msg = exc.Msg(); 117 cerr << " !!!! skymixer/ Readcard - Catched exception - Msg= " << exc.Msg() << endl; 118 return(90); 119 } 120 120 121 121 … … 127 127 if (debuglev > 0) so = new POutPersist("skymixdbg.ppf"); 128 128 129 SphereHEALPix<float> outgs(hp_nside); 130 bool okout = false; 131 132 try { 133 if (rdmap) { // Reading map from FITS file 134 FitsIoServer fios; 135 char ifnm[256]; 136 strncpy(ifnm, dc.SParam("READMAP", 0).c_str(), 255); 137 ifnm[255] = '\0'; 138 cout << " Reading output HealPix map from FITS file " << (string)ifnm << endl; 139 fios.load(outgs, ifnm, 2); 140 cout << " Output HealPIx Map read - NbPixels= " << outgs.NbPixels() << endl; 141 if (printlev > 0) { 142 MeanSig(outgs.DataBlock(), moy, sig ); 143 cout << " MeanSig for outpout map - Mean= " << moy << " Sigma= " << sig << endl; 144 } 145 } 146 else { 147 cout << " Output HealPix Map created - NbPixels= " << outgs.NbPixels() << endl; 148 outgs.SetPixels(0.); 149 } 150 151 // Decoding detection pass-band filter 152 sr = getSpectralResponse(dc); 153 PrtTim(" After FilterCreation "); 154 155 FitsIoServer fios; // Our FITS IO Server 156 char * flnm, buff[90]; 157 string key; 158 159 SphereHEALPix<float> ings(hp_nside); // The input map 160 double K = 1.; 161 double freqOfMap = 1.; 162 // Loop over sky component 163 int sk; 164 for(sk = 0; sk<nskycomp; sk++) { 165 cout << " Processing sky component No " << sk+1 << endl; 129 SphereHEALPix<float> outgs(hp_nside); 130 try{ 131 if (rdmap) { // Reading map from FITS file 132 char ifnm[256]; 133 strncpy(ifnm, dc.SParam("READMAP", 0).c_str(), 255); 134 ifnm[255] = '\0'; 135 cout << " Reading output HealPix map from FITS file " << (string)ifnm << endl; 136 FITS_SphereHEALPix<float> fios(ifnm); 137 outgs = (SphereHEALPix<float>)fios; 138 cout << " Output HealPIx Map read - NbPixels= " << outgs.NbPixels() << endl; 139 if (printlev > 0) { 140 MeanSig(outgs.DataBlock(), moy, sig ); 141 cout << " MeanSig for outpout map - Mean= " << moy << " Sigma= " << sig << endl; 142 } 143 } 144 else { 145 cout << " Output HealPix Map created - NbPixels= " << outgs.NbPixels() << endl; 146 outgs.SetPixels(0.); 147 } 166 148 167 sprintf(buff, "%d", sk+1);168 key = (string)"MAPFITSFILE" + buff;169 flnm = BuildFITSFileName(dc.SParam(key, 0));149 // Decoding detection pass-band filter 150 sr = getSpectralResponse(dc); 151 PrtTim(" After FilterCreation "); 170 152 171 K = dc.DParam(key, 1, 1.); 153 char * flnm, buff[90]; 154 string key; 172 155 173 bool mapDependentOfFreq = false; 174 key = (string)"BETAFITSFILE"+ buff; 175 if(dc.HasKey(key)) 176 { 177 mapDependentOfFreq = true; 156 // SphereHEALPix<float> ings(hp_nside); // The input map 157 double K = 1.; 158 double freqOfMap = 1.; 159 // Loop over sky component 160 int sk; 161 for(sk = 0; sk<nskycomp; sk++) { 162 cout << " Processing sky component No " << sk+1 << endl; 163 164 sprintf(buff, "%d", sk+1); 165 key = (string)"MAPFITSFILE" + buff; 166 flnm = BuildFITSFileName(dc.SParam(key, 0)); 167 168 K = dc.DParam(key, 1, 1.); 169 170 bool mapDependentOfFreq = false; 171 key = (string)"BETAFITSFILE"+ buff; 172 if(dc.HasKey(key)) 173 { 174 mapDependentOfFreq = true; 175 } 176 cout << "the map has a mapDependentOfFreq = " << 177 mapDependentOfFreq << endl; 178 179 cout << " Reading Input FITS map " << (string)flnm << endl; 180 FITS_SphereHEALPix<float> fiosIn(flnm); 181 SphereHEALPix<float> ings = (SphereHEALPix<float>)fiosIn; 182 183 if (debuglev > 4) { // Writing the input map to the outppf 184 FIO_SphereHEALPix<float> fiog(ings); 185 fiog.Write(*so, key); 178 186 } 179 cout << "the map has a mapDependentOfFreq = " << 180 mapDependentOfFreq << endl; 181 182 cout << " Reading Input FITS map " << (string)flnm << endl; 183 fios.load(ings, flnm, 2); 184 if (debuglev > 4) { // Writing the input map to the outppf 185 FIO_SphereHEALPix<float> fiog(ings); 186 fiog.Write(*so, key); 187 } 188 if (printlev > 2) { 189 MeanSig(ings.DataBlock(), moy, sig ); 190 cout << " MeanSig for input map - Mean= " << moy << " Sigma= " << sig << endl; 191 } 192 // getting Emission spectra 193 if(!mapDependentOfFreq) 194 { 195 if (es) { delete es; es = NULL; } 196 es = getEmissionSpectra(dc, sk); 197 addComponent(*sr, outgs, ings, *es, K); 187 if (printlev > 2) { 188 MeanSig(ings.DataBlock(), moy, sig ); 189 cout << " MeanSig for input map - Mean= " << moy << " Sigma= " << sig << endl; 198 190 } 199 else 200 { 201 key = (string)"BETAFITSFILE"+ buff; 202 SphereHEALPix<float> betaMap; 203 flnm = BuildFITSFileName(dc.SParam(key, 0)); 204 double normFreq = dc.DParam(key, 1, 1.); 205 if (printlev > 4) cout << "....BetaFits... normalization Freq = " << normFreq << endl; 206 int nSideForInt = dc.DParam(key, 2, 1.); 207 if (printlev > 4) cout << "....BetaFits... NSide for Integration map = " << nSideForInt << endl; 208 cout << "....BetaFits... Reading Beta FITS map " << (string)flnm << endl; 209 fios.load(betaMap, flnm, 2); 210 if(nSideForInt<0) nSideForInt = sqrt((double)betaMap.NbPixels()/12); 211 212 bool bydefault = true; 213 if(!bydefault) 214 addComponentBeta(outgs,ings,*sr,betaMap,normFreq, K); 215 else 216 { 217 // integrate the betamap over the SpectralResponse 218 SphereHEALPix<float> intBetaMap(nSideForInt); 219 integratedMap(*sr, betaMap, normFreq, intBetaMap); 220 betaMap.Resize(8); 221 MeanSig(intBetaMap.DataBlock(), moy, sig ); 222 if (printlev > 4) cout << "....BetaFits... MeanSig for intBetaMap - Mean= " << moy << " Sigma= " << sig << endl; 223 // add the integrated beta map 224 addComponentBeta(outgs,ings,intBetaMap, K); 225 } 191 // getting Emission spectra 192 if(!mapDependentOfFreq) 193 { 194 if (es) { delete es; es = NULL; } 195 es = getEmissionSpectra(dc, sk); 196 addComponent(*sr, outgs, ings, *es, K); 197 } 198 else 199 { 200 key = (string)"BETAFITSFILE"+ buff; 201 //SphereHEALPix<float> betaMap; 202 flnm = BuildFITSFileName(dc.SParam(key, 0)); 203 double normFreq = dc.DParam(key, 1, 1.); 204 if (printlev > 4) cout << "....BetaFits... normalization Freq = " << normFreq << endl; 205 int nSideForInt = dc.DParam(key, 2, 1.); 206 if (printlev > 4) cout << "....BetaFits... NSide for Integration map = " << nSideForInt << endl; 207 cout << "....BetaFits... Reading Beta FITS map " << (string)flnm << endl; 208 209 FITS_SphereHEALPix<float> fiosBM(flnm); 210 SphereHEALPix<float> betaMap = (SphereHEALPix<float>)fiosBM; 211 212 if(nSideForInt<0) nSideForInt = sqrt((double)betaMap.NbPixels()/12); 213 214 bool bydefault = true; 215 if(!bydefault) 216 addComponentBeta(outgs,ings,*sr,betaMap,normFreq, K); 217 else 218 { 219 // integrate the betamap over the SpectralResponse 220 SphereHEALPix<float> intBetaMap(nSideForInt); 221 integratedMap(*sr, betaMap, normFreq, intBetaMap); 222 betaMap.Resize(8); 223 MeanSig(intBetaMap.DataBlock(), moy, sig ); 224 if (printlev > 4) cout << "....BetaFits... MeanSig for intBetaMap - Mean= " << moy << " Sigma= " << sig << endl; 225 // add the integrated beta map 226 addComponentBeta(outgs,ings,intBetaMap, K); 227 } 228 MeanSig(outgs.DataBlock(), moy, sig ); 229 cout << " MeanSig for Sum map - Mean= " << moy << " Sigma= " << sig << endl; 230 } 231 232 if (printlev > 1) { 226 233 MeanSig(outgs.DataBlock(), moy, sig ); 227 234 cout << " MeanSig for Sum map - Mean= " << moy << " Sigma= " << sig << endl; 228 235 } 229 230 okout = true; 231 if (printlev > 1) { 232 MeanSig(outgs.DataBlock(), moy, sig ); 233 cout << " MeanSig for Sum map - Mean= " << moy << " Sigma= " << sig << endl; 234 } 235 sprintf(buff, "End of Proc. Comp. %d ", sk+1); 236 cout << " --------------------------------------- \n" << endl; 237 PrtTim(buff); 238 } // End of sky component loop 239 } // End of try block 240 241 catch (PException exc) { 242 msg = exc.Msg(); 243 cerr << " !!!! skymixer - Catched exception - Msg= " << exc.Msg() << endl; 244 rc = 50; 245 } 246 247 // Saving the output map in FITS format 248 if (okout) { 249 FitsIoServer fios; 250 fios.save(outgs, arg[2]); 251 cout << "Output Map (SphereHEALPix<float>) written to FITS file " 252 << (string)(arg[2]) << endl; 253 PrtTim("End of WriteFITS "); 254 // Saving the output map in PPF format 255 if (narg > 3) { 236 sprintf(buff, "End of Proc. Comp. %d ", sk+1); 237 PrtTim(buff); 238 } 239 } 240 catch(PException exc) 241 { 242 cout << "catched PException" << endl; 243 msg = exc.Msg(); 244 cerr << " !!!! skymixer - Catched exception - Msg= " << exc.Msg() << endl; 245 rc = 50; 246 return(50); 247 } 248 249 // Saving the output map in FITS format 250 cout << "Output Map (SphereHEALPix<float>) written to FITS file " 251 << (string)(arg[2]) << endl; 252 FITS_SphereHEALPix<float> fios2(outgs); 253 fios2.Write(arg[2]); 254 PrtTim("End of WriteFITS "); 255 // Saving the output map in PPF format 256 if (narg > 3) { 256 257 POutPersist s(arg[3]); 257 258 FIO_SphereHEALPix<float> fiog(&outgs) ; 258 259 fiog.Write(s); 259 260 cout << "Output Map (SphereHEALPix<float>) written to POutPersist file " 260 261 << (string)(arg[3]) << endl; 261 262 PrtTim("End of WritePPF "); 262 } 263 } 264 if (so) delete so; // Closing the debug ppf file 265 return(rc); 263 } 264 if (so) delete so; // Closing the debug ppf file 265 return(rc); 266 266 } 267 267
Note:
See TracChangeset
for help on using the changeset viewer.