Changeset 1355 in Sophya
- Timestamp:
- Dec 18, 2000, 9:06:40 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/PMixer/skymixer.cc
r1296 r1355 25 25 // ----------------------------------------------------------------- 26 26 // ------------- Function declaration ------------------------------ 27 int CheckCards(DataCards & dc, string & msg );27 int CheckCards(DataCards & dc, string & msg, FitsOutFile& fios); 28 28 char * BuildFITSFileName(string const & fname); 29 SpectralResponse * getSpectralResponse(DataCards & dc );30 RadSpectra * getEmissionSpectra(DataCards & dc, int nc );29 SpectralResponse * getSpectralResponse(DataCards & dc, FitsOutFile& fios); 30 RadSpectra * getEmissionSpectra(DataCards & dc, int nc, FitsOutFile& fios); 31 31 void SKM_MergeFITSKeywords(char * flnm); 32 32 void SKM_MergeFITSKeywords2(DVList & dvl); … … 72 72 static POutPersist * so = NULL; // Debug PPFOut file 73 73 static DVList * dvl_fitskw = NULL; // Global DVList for all FITS Keywords 74 74 bool checkpdmtype=false; 75 bool dvliston= false; 75 76 // --------- SkyMixer Version -------------- 76 static double skm_version = 1. 4;77 static double skm_version = 1.5; 77 78 78 79 // ------------------------------------------------------------------------- … … 87 88 88 89 InitTim(); 89 90 FitsOutFile fios(arg[2]); 91 90 92 cout << " skymixer Version= " << skm_version << " SophyaVersion= " 91 93 << SophyaVersion() << endl; … … 107 109 dc.ReadFile(dcard); 108 110 109 rc = CheckCards(dc, msg );111 rc = CheckCards(dc, msg,fios); 110 112 if (rc) { 111 113 cerr << " Error condition -> Rc= " << rc << endl; … … 127 129 // We create an output persist file for writing debug objects 128 130 if (debuglev > 0) so = new POutPersist("skymixdbg.ppf"); 129 131 int countHead = 2; 130 132 SphereHEALPix<float> outgs(hp_nside); 131 133 try{ … … 136 138 cout << " Reading output HealPix map from FITS file " << (string)ifnm << endl; 137 139 { 138 F ITS_SphereHEALPix<float> fios(&outgs);139 fi os.Read(ifnm,2);140 FitsInFile fitsin(ifnm); 141 fitsin >> outgs; 140 142 // Getting FITS keywords in primary header 141 143 // SKM_MergeFITSKeywords(ifnm); 142 144 // Getting FITS keywords in data object header 143 SKM_MergeFITSKeywords2(outgs.Info()); 145 if(checkpdmtype) 146 { 147 int status = 1; 148 string whatsup=fitsin.getStringKeyword(1,"PDMTYPE",status); 149 if(!(status==0&&whatsup=="COMPMAP")) 150 { 151 cerr << " !!!! skymixer - file" << ifnm << " is not a COMPMAP " << endl; 152 throw ParmError("Error"); 153 } 154 else cout << "read the comment COMPMAP from " << ifnm << endl; 155 } 156 if(dvliston) SKM_MergeFITSKeywords2(outgs.Info()); 157 else 158 { 159 fios.appendInputHeader(fitsin, countHead); 160 } 144 161 } 145 162 if(printlev>0) … … 160 177 161 178 // Decoding detection pass-band filter 162 sr = getSpectralResponse(dc );179 sr = getSpectralResponse(dc,fios); 163 180 PrtTim(" After FilterCreation "); 164 181 … … 203 220 SphereHEALPix<float> ings(hp_nside); 204 221 { 205 F ITS_SphereHEALPix<float> fiosIn(&ings);206 fiosIn .Read(flnm,2);222 FitsInFile fiosIn(flnm); 223 fiosIn >> ings; 207 224 // Getting FITS keywords in primary header 208 225 // SKM_MergeFITSKeywords(flnm); 209 226 // Getting FITS keywords in data object header 210 SKM_MergeFITSKeywords2(ings.Info()); 227 //if(fiosIn.hasKeyword(string("PDMTYPE"), 1)) cout << "read the comment COMPMAP from " << flnm << endl; 228 if(checkpdmtype) 229 { 230 int status = 1; 231 string ch = "PDMTYPE"; 232 string whatsup=fiosIn.getStringKeyword(1,ch,status); 233 if(!(status==0&&whatsup=="COMPMAP")) 234 { 235 cerr << " !!!! skymixer - file" << flnm << " is not a COMPMAP " << endl; 236 throw ParmError("Error"); 237 } 238 else cout << "read the comment COMPMAP from " << flnm << endl; 239 } 240 if(dvliston) SKM_MergeFITSKeywords2(ings.Info()); 241 else 242 { 243 fios.appendInputHeader(fiosIn, countHead); 244 } 211 245 } 212 246 if (debuglev > 4) { // Writing the input map to the outppf … … 229 263 { 230 264 if (es) { delete es; es = NULL; } 231 es = getEmissionSpectra(dc, sk );265 es = getEmissionSpectra(dc, sk,fios); 232 266 addComponent(*sr, outgs, ings, *es, K); 233 267 } … … 244 278 SphereHEALPix<float> betaMap(hp_nside); 245 279 { 246 F ITS_SphereHEALPix<float> fiosBM(&betaMap);247 fiosBM .Read(flnm,2);280 FitsInFile fiosBM(flnm); 281 fiosBM >> betaMap; 248 282 // Getting FITS keywords in primary header 249 283 // SKM_MergeFITSKeywords(flnm); 250 284 // Getting FITS keywords in data object header 251 SKM_MergeFITSKeywords2(betaMap.Info()); 285 //if(fiosBM.hasKeyword(string("COMPMAP"), 1)) cout << "read the comment COMPMAP from " << flnm << endl; 286 if(checkpdmtype) 287 { 288 int status = 1; 289 string whatsup=fiosBM.getStringKeyword(1,"PDMTYPE",status); 290 if(!(status==0&&whatsup=="INDEXMAP")) 291 { 292 cerr << " !!!! skymixer - file" << flnm << " is not an INDEXMAP " << endl; 293 throw ParmError("Error"); 294 } 295 else cout << "read the comment INDEXMAP from " << flnm << endl; 296 } 297 if(dvliston) SKM_MergeFITSKeywords2(betaMap.Info()); 298 else 299 { 300 fios.appendInputHeader(fiosBM, countHead); 301 } 252 302 } 253 303 if (printlev > 2) { … … 309 359 << (string)(arg[2]) << endl; 310 360 { 311 FitsOutFile fios(arg[2]);361 // FitsOutFile fios(arg[2]); 312 362 fios.firstImageOnPrimaryHeader(false); // Use secondary header 313 363 DVList& dvl = (*dvl_fitskw); … … 348 398 349 399 /* Nouvelle-Fonction */ 350 int CheckCards(DataCards & dc, string & msg )400 int CheckCards(DataCards & dc, string & msg, FitsOutFile& fios) 351 401 // Function to check datacards 352 402 { … … 368 418 return(rc); 369 419 } 370 dvl.SetS("SKYMIX", dc.GetParams("SKYMIX")); 420 if(dvliston) 421 dvl.SetS("SKYMIX", dc.GetParams("SKYMIX")); 422 else 423 { 424 fios.insertCommentLineOnHeader("--------------------"); 425 fios.insertCommentLineOnHeader("SkyMixer DataCard"); 426 fios.insertCommentLineOnHeader("--------------------"); 427 428 string key = "SKYMIX"+ (string)dc.GetParams("SKYMIX"); 429 fios.insertCommentLineOnHeader(key); 430 } 431 432 key = "CHECKPDMTYPE"; 433 if (dc.HasKey(key)) { 434 checkpdmtype=true; 435 } 436 437 371 438 key = "READMAP"; 372 439 if (dc.HasKey(key)) { … … 377 444 } 378 445 else rdmap = true; 379 dvl.SetS(key, dc.GetParams(key)); 446 447 if(dvliston) dvl.SetS(key, dc.GetParams(key)); 448 else 449 { 450 string keynew = key + (string)dc.GetParams(key); 451 fios.insertCommentLineOnHeader(keynew); 452 } 380 453 } 381 454 … … 389 462 } 390 463 391 if (dc.HasKey(key)) dvl.SetS("GAUSFILT", dc.GetParams(key)); 392 if (dc.HasKey(key2)) dvl.SetS("FILTFILE", dc.GetParams(key2)); 393 if (dc.HasKey(key3)) dvl.SetS("DIPOLE", dc.GetParams(key3)); 394 464 if (dc.HasKey(key)) 465 { 466 if(dvliston) dvl.SetS("GAUSFILT", dc.GetParams(key)); 467 else 468 { 469 string keynew = key + (string)dc.GetParams(key); 470 fios.insertCommentLineOnHeader(keynew); 471 } 472 } 473 if (dc.HasKey(key2)) 474 { 475 if(dvliston) dvl.SetS("FILTFILE", dc.GetParams(key2)); 476 else 477 { 478 string keynew = key2 + (string)dc.GetParams(key2); 479 fios.insertCommentLineOnHeader(keynew); 480 } 481 } 482 if (dc.HasKey(key3)) 483 { 484 if(dvliston) dvl.SetS("DIPOLE", dc.GetParams(key3)); 485 else 486 { 487 string keynew = key3 + (string)dc.GetParams(key3); 488 fios.insertCommentLineOnHeader(keynew); 489 } 490 } 395 491 // Decoding number of component and pixelisation parameter 396 492 int mg = 32; … … 417 513 sprintf(buff, "DIPOLE%d", kc+1); 418 514 key3 = buff; 419 if (dc.NbParam(key) < 1 && dc.NbParam(key3)<1) { 420 msg = "Missing or invalid card : " + key + " " + key2 + " " + key3; 421 pb = true; break; 422 } 423 515 if (dc.NbParam(key) < 1 && (dc.NbParam(key3)<1)) 516 { 517 msg = "Invalid card or Missing card" + key + " or " + key3 ; 518 pb = true; break; 519 } 520 424 521 sprintf(buff, "MAPFIL%d", kc+1); 425 if (dc.HasKey(key)) dvl.SetS(buff, dc.GetParams(key)); 522 if (dc.HasKey(key)) 523 { 524 if(dvliston) dvl.SetS(buff, dc.GetParams(key)); 525 else 526 { 527 string keynew = buff + (string)dc.GetParams(key); 528 fios.insertCommentLineOnHeader(keynew); 529 } 530 } 426 531 sprintf(buff, "DIPOLE%d", kc+1); 427 if (dc.HasKey(key3)) dvl.SetS(buff, dc.GetParams(key3)); 428 532 if (dc.HasKey(key3)) 533 { 534 if(dvliston) dvl.SetS(buff, dc.GetParams(key3)); 535 else 536 { 537 string keynew = buff + (string)dc.GetParams(key3); 538 fios.insertCommentLineOnHeader(keynew); 539 } 540 } 429 541 sprintf(buff, "SPECTRAFITSFILE%d", kc+1); 430 542 key = buff; … … 440 552 key6 = buff; 441 553 if ( (dc.NbParam(key) < 3) && (dc.NbParam(key2) < 1) && (dc.NbParam(key3) < 6) && (dc.NbParam(key4)<2) 442 && (dc.NbParam(key6)<1) && (dc.NbParam(key5)< 3)) {554 && (dc.NbParam(key6)<1) && (dc.NbParam(key5)<1)) { 443 555 msg = "Missing card or invalid parameters : " + key + " " + key2 + " " + key3 + " " + key4+ " " + key5; 444 556 pb = true; break; … … 446 558 447 559 sprintf(buff, "SPECTF%d", kc+1); 448 if (dc.HasKey(key)) dvl.SetS(buff, dc.GetParams(key)); 560 if (dc.HasKey(key)) { 561 if(dvliston) dvl.SetS(buff, dc.GetParams(key)); 562 else { 563 string keynew = buff + (string)dc.GetParams(key); 564 fios.insertCommentLineOnHeader(keynew);} 565 } 449 566 sprintf(buff, "BLACKB%d", kc+1); 450 if (dc.HasKey(key2)) dvl.SetS(buff, dc.GetParams(key2)); 567 if (dc.HasKey(key2)) { 568 if(dvliston) dvl.SetS(buff, dc.GetParams(key2)); 569 else { 570 string keynew = buff + (string)dc.GetParams(key2); 571 fios.insertCommentLineOnHeader(keynew);} 572 } 573 451 574 sprintf(buff, "PLAWSP%d", kc+1); 452 if (dc.HasKey(key3)) dvl.SetS(buff, dc.GetParams(key3)); 575 if (dc.HasKey(key3)) { 576 if(dvliston) dvl.SetS(buff, dc.GetParams(key3)); 577 else { 578 string keynew = buff + (string)dc.GetParams(key3); 579 fios.insertCommentLineOnHeader(keynew);} 580 } 581 453 582 sprintf(buff, "BETAFI%d", kc+1); 454 if (dc.HasKey(key4)) dvl.SetS(buff, dc.GetParams(key4)); 583 if (dc.HasKey(key4)) { 584 if(dvliston) dvl.SetS(buff, dc.GetParams(key4)); 585 else { 586 string keynew = buff + (string)dc.GetParams(key4); 587 fios.insertCommentLineOnHeader(keynew);} 588 } 589 455 590 sprintf(buff, "DIPOLE%d", kc+1); 456 if (dc.HasKey(key5)) dvl.SetS(buff, dc.GetParams(key5)); 591 if (dc.HasKey(key5)) { 592 if(dvliston) dvl.SetS(buff, dc.GetParams(key5)); 593 else { 594 string keynew = buff + (string)dc.GetParams(key5); 595 fios.insertCommentLineOnHeader(keynew);} 596 } 597 457 598 sprintf(buff, "DERIBB%d", kc+1); 458 if (dc.HasKey(key6)) dvl.SetS(buff, dc.GetParams(key6)); 459 460 } 599 if (dc.HasKey(key6)) { 600 if(dvliston) dvl.SetS(buff, dc.GetParams(key6)); 601 else { 602 string keynew = buff + (string)dc.GetParams(key6); 603 fios.insertCommentLineOnHeader(keynew);} 604 } 605 606 } 461 607 462 608 if (pb) { … … 494 640 495 641 /* Nouvelle-Fonction */ 496 SpectralResponse * getSpectralResponse(DataCards & dc )642 SpectralResponse * getSpectralResponse(DataCards & dc, FitsOutFile& fios) 497 643 { 498 644 SpectralResponse * filt = NULL; … … 513 659 // SKM_MergeFITSKeywords(ifnm); 514 660 // Getting FITS keywords in data object header 515 SKM_MergeFITSKeywords2(mtx.Info()); 661 if(checkpdmtype) 662 { 663 int status = 1; 664 string whatsup=fiis.getStringKeyword(1,"PDMTYPE",status); 665 if(!(status==0&&whatsup=="COMPMAP")) 666 { 667 cerr << " !!!! skymixer - file" << ifnm << " is not a COMPMAP " << endl; 668 throw ParmError("Error"); 669 } 670 else cout << "read the comment COMPMAP from " << ifnm << endl; 671 } 672 if(dvliston) SKM_MergeFITSKeywords2(mtx.Info()); 673 else 674 { 675 fios.appendInputHeader(fiis, 2); 676 } 516 677 double numin = dc.DParam(key, 2, 1.); 517 678 double numax = dc.DParam(key, 3, 9999.); … … 547 708 548 709 /* Nouvelle-Fonction */ 549 RadSpectra * getEmissionSpectra(DataCards & dc, int nc )710 RadSpectra * getEmissionSpectra(DataCards & dc, int nc, FitsOutFile& fios) 550 711 { 551 712 char numb[16]; … … 569 730 // SKM_MergeFITSKeywords(ifnm); 570 731 // Getting FITS keywords in data object header 571 SKM_MergeFITSKeywords2(mtx.Info()); 732 //if(fiis.hasKeyword(string("PDMTYPE"), 1)) cout << "read the comment COMPMAP from " << ifnm << endl; 733 if(checkpdmtype) 734 { 735 int status = 1; 736 string whatsup=fiis.getStringKeyword(1,"PDMTYPE",status); 737 if(!(status==0&&whatsup=="FGRSPEC")) 738 { 739 cerr << " !!!! skymixer - file" << ifnm << " is not a FGRSPEC" << endl; 740 throw ParmError("Error"); 741 } 742 else cout << "read the comment FGRSPEC from " << ifnm << endl; 743 } 744 if(dvliston) SKM_MergeFITSKeywords2(mtx.Info()); 745 else 746 { 747 fios.appendInputHeader(fiis, 2); 748 } 572 749 double numin = dc.DParam(key, 2, 1.); 573 750 double numax = dc.DParam(key, 3, 9999.);
Note:
See TracChangeset
for help on using the changeset viewer.