Changeset 1355 in Sophya


Ignore:
Timestamp:
Dec 18, 2000, 9:06:40 AM (25 years ago)
Author:
sophie
Message:

sophie: changes according to Garching requirements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/PMixer/skymixer.cc

    r1296 r1355  
    2525// -----------------------------------------------------------------
    2626// ------------- Function declaration ------------------------------
    27 int CheckCards(DataCards & dc, string & msg);
     27int CheckCards(DataCards & dc, string & msg, FitsOutFile& fios);
    2828char * BuildFITSFileName(string const & fname);
    29 SpectralResponse * getSpectralResponse(DataCards & dc);
    30 RadSpectra * getEmissionSpectra(DataCards & dc, int nc);
     29SpectralResponse * getSpectralResponse(DataCards & dc, FitsOutFile& fios);
     30RadSpectra * getEmissionSpectra(DataCards & dc, int nc, FitsOutFile& fios);
    3131void SKM_MergeFITSKeywords(char * flnm);
    3232void SKM_MergeFITSKeywords2(DVList & dvl);
     
    7272static POutPersist * so = NULL;    // Debug PPFOut file
    7373static DVList * dvl_fitskw = NULL; // Global DVList for all FITS Keywords
    74 
     74bool checkpdmtype=false;
     75bool dvliston= false;
    7576// --------- SkyMixer Version --------------
    76 static double skm_version = 1.4;
     77static double skm_version = 1.5;
    7778
    7879// -------------------------------------------------------------------------
     
    8788 
    8889  InitTim();
    89 
     90  FitsOutFile fios(arg[2]);
     91     
    9092  cout << " skymixer Version= " << skm_version << " SophyaVersion= "
    9193       << SophyaVersion() << endl;
     
    107109    dc.ReadFile(dcard);
    108110   
    109     rc = CheckCards(dc, msg);
     111    rc = CheckCards(dc, msg,fios);
    110112    if (rc) {
    111113      cerr << " Error condition -> Rc= " << rc << endl;
     
    127129  // We create an output persist file for writing debug objects
    128130  if (debuglev > 0) so = new POutPersist("skymixdbg.ppf");
    129  
     131  int countHead = 2;
    130132  SphereHEALPix<float> outgs(hp_nside);
    131133  try{
     
    136138      cout << " Reading output HealPix map from FITS file " << (string)ifnm << endl;
    137139      {
    138         FITS_SphereHEALPix<float> fios(&outgs);
    139         fios.Read(ifnm,2);
     140        FitsInFile fitsin(ifnm);
     141        fitsin >> outgs;
    140142        //  Getting FITS keywords in primary header
    141143        //      SKM_MergeFITSKeywords(ifnm);
    142144        //  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          }
    144161      }
    145162      if(printlev>0)
     
    160177   
    161178    // Decoding detection pass-band filter
    162     sr = getSpectralResponse(dc);
     179    sr = getSpectralResponse(dc,fios);
    163180    PrtTim(" After FilterCreation ");
    164181   
     
    203220          SphereHEALPix<float> ings(hp_nside);
    204221          {
    205             FITS_SphereHEALPix<float> fiosIn(&ings);
    206             fiosIn.Read(flnm,2);
     222            FitsInFile fiosIn(flnm);
     223            fiosIn >> ings;
    207224            //  Getting FITS keywords in primary header
    208225            //  SKM_MergeFITSKeywords(flnm);
    209226            //  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              }
    211245          }
    212246          if (debuglev > 4) {  // Writing the input map to the outppf
     
    229263            {
    230264              if (es) { delete es; es = NULL; }
    231               es = getEmissionSpectra(dc, sk);
     265              es = getEmissionSpectra(dc, sk,fios);
    232266              addComponent(*sr, outgs, ings, *es, K);
    233267            }
     
    244278              SphereHEALPix<float> betaMap(hp_nside);
    245279              {
    246                 FITS_SphereHEALPix<float> fiosBM(&betaMap);
    247                 fiosBM.Read(flnm,2);
     280                FitsInFile fiosBM(flnm);
     281                fiosBM >> betaMap;
    248282                //  Getting FITS keywords in primary header
    249283                // SKM_MergeFITSKeywords(flnm);
    250284                //  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                  }
    252302              }
    253303              if (printlev > 2) {
     
    309359        << (string)(arg[2]) << endl;
    310360   {
    311      FitsOutFile fios(arg[2]);
     361     //     FitsOutFile fios(arg[2]);
    312362     fios.firstImageOnPrimaryHeader(false); // Use secondary header
    313363     DVList& dvl = (*dvl_fitskw);
     
    348398
    349399/* Nouvelle-Fonction */
    350 int CheckCards(DataCards & dc, string & msg)
     400int CheckCards(DataCards & dc, string & msg, FitsOutFile& fios)
    351401//   Function to check datacards
    352402{
     
    368418     return(rc);
    369419  }
    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 
    371438  key = "READMAP";
    372439  if (dc.HasKey(key)) {
     
    377444    }
    378445    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      }
    380453  }
    381454
     
    389462    }
    390463
    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    }
    395491  // Decoding number of component and pixelisation parameter
    396492  int mg = 32;
     
    417513    sprintf(buff, "DIPOLE%d", kc+1);
    418514    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       
    424521    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      }
    426531    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      }
    429541    sprintf(buff, "SPECTRAFITSFILE%d", kc+1);
    430542    key = buff;
     
    440552    key6 = buff;
    441553    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))  {   
    443555      msg = "Missing card or invalid parameters : " + key + " " + key2 + " " + key3 + " " + key4+ " " + key5;
    444556      pb = true;  break;
     
    446558
    447559    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    }
    449566    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
    451574    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
    453582    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
    455590    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
    457598    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  }
    461607
    462608  if (pb)  {
     
    494640
    495641/* Nouvelle-Fonction */
    496 SpectralResponse * getSpectralResponse(DataCards & dc)
     642SpectralResponse * getSpectralResponse(DataCards & dc, FitsOutFile& fios)
    497643{
    498644  SpectralResponse * filt = NULL;
     
    513659    //    SKM_MergeFITSKeywords(ifnm);
    514660    //  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      }
    516677    double numin = dc.DParam(key, 2, 1.);
    517678    double numax = dc.DParam(key, 3, 9999.);
     
    547708
    548709/* Nouvelle-Fonction */
    549 RadSpectra * getEmissionSpectra(DataCards & dc, int nc)
     710RadSpectra * getEmissionSpectra(DataCards & dc, int nc, FitsOutFile& fios)
    550711{
    551712  char numb[16];
     
    569730    //    SKM_MergeFITSKeywords(ifnm);
    570731    //  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      }
    572749    double numin = dc.DParam(key, 2, 1.);
    573750    double numax = dc.DParam(key, 3, 9999.);
Note: See TracChangeset for help on using the changeset viewer.