Changeset 2058 in Sophya


Ignore:
Timestamp:
Jun 18, 2002, 2:21:09 PM (23 years ago)
Author:
ansari
Message:

Ajout methode FITSTOIReader::setFlagFile() pour fichiers flag separes
de Level2 - Reza 18/6/2002

Location:
trunk/ArchTOIPipe
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/fitstoirdr.cc

    r2041 r2058  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: fitstoirdr.cc,v 1.29 2002-06-03 14:23:39 ansari Exp $
     5// $Id: fitstoirdr.cc,v 1.30 2002-06-18 12:21:08 ansari Exp $
    66
    77#include "fitstoirdr.h"
     
    2222  implicitSN = false;
    2323  implicitSNStart = 0;
     24
     25  // Variables rajoutee pour gerer les fichiers de flag de LevelS Reza 18/6/2002
     26  sepFlagfile = false;
     27  fptrflg = NULL;
    2428}
    2529
     
    6367    fits_report_error(stderr, fstatus);
    6468    fits_unlock();
    65     throw IOExc("fitsio error");
     69    throw IOExc("FITSTOIReader::openFile() fitsio error");
    6670  }
    6771 
     
    8993    firstSn = (int) (y+.1);
    9094  }
     95
     96  // Ouverture fichier de flag separe  de LevelS (Reza 18/6/2002)
     97  if (sepFlagfile) {
     98    fits_open_file(&fptrflg,sepFlagFileName.c_str(),READONLY,&fstatus);
     99    if (fstatus != 0) {
     100      fits_report_error(stderr, fstatus);
     101      fits_unlock();
     102      throw IOExc("FITSTOIReader::openFile() - sepFlagfile open fitsio error");
     103    }
     104    fits_movabs_hdu(fptrflg, 2, NULL, &fstatus);
     105    if (fstatus != 0) {
     106      fits_report_error(stderr, fstatus);
     107      fits_unlock();
     108      throw IOExc("FITSTOIReader::openFile() - sepFlagfile fits_movabs_hdu(2) fitsio error");
     109    }
     110    long nrowsflg;
     111    fits_get_num_rows(fptrflg,&nrowsflg,&fstatus);
     112    if (nrows != nrowsflg) {
     113      cerr << " FITSTOIReader::openFile()/Error: Different NRows in flag and data files!" << endl;
     114      fits_unlock();
     115      throw ParmError("FITSTOIReader::openFile() Different NRows in flag and data files");
     116    }
     117  }
     118  //
    91119  fits_unlock(); 
    92120}
    93121
    94122void FITSTOIReader::init() {
     123
     124  // Modif pour fichiers de flag separe de LevelS (Reza 18/6/2002)
     125  if (sepFlagfile && (allfn.size() > 1) ) {
     126    cerr << "FITSTOIReader::init()/Error- Multiple files and separate flag file not allowed !"<<endl;
     127    throw ParmError("FITSTOIReader::init() Multiple files and separate flag file not allowed");
     128  }
     129
    95130  openFile(allfn.front());
    96131
     
    148183}
    149184
     185void FITSTOIReader::setFlagFile(string fn, vector<FlagToiDef> flags)
     186{
     187  if (flags.size() < 1) {
     188    cerr << " FITSTOIReader::setFlagFile()/Error flag.size() = 0 ! " << endl;
     189    throw ParmError("FITSTOIReader::setFlagFile() flag.size() = 0");
     190  }
     191
     192  sepFlagfile = true;
     193  sepFlagFileName = fn;
     194  sepFlagCols =  flags;
     195}
     196
    150197void FITSTOIReader::run() {
    151198  for (vector<string>::iterator i=allfn.begin(); i!=allfn.end(); i++) {
     
    154201    else run1();              // Lecture un echantillon a la fois
    155202  }
     203  fits_lock();
     204  if (fptr) {
     205    fits_close_file(fptr,&fstatus);
     206    fptr = NULL;
     207  }
     208  if (sepFlagfile && fptrflg) {
     209    fits_close_file(fptrflg,&fstatus);
     210    fptrflg = NULL;
     211  }
     212  fits_unlock();
    156213}
    157214
     
    198255        fits_read_col_lng(fptr,j+2,i+1,1,1,0,&flg,&anyNul,&fstatus);
    199256      }
     257
     258      if (sepFlagfile) { // Ajout Reza (18/6/2002) pour fichier de flags separe
     259        int sflg;
     260        flg = 0;
     261        for(int skf=0; skf<sepFlagCols.size(); skf++) {
     262          fits_read_col_int(fptrflg, skf+1, i+1,1,1,0,&sflg,&anyNul,&fstatus);
     263          if (sflg) flg |= sepFlagCols[skf];
     264        }
     265      }  // Fin modif pour fichier de flags separe (18/6/2002)
     266
    200267      tabflag[k] = flg;
    201268      //      fits_unlock();
     
    237304 }
    238305 uint_8 * tmpflg = new uint_8[Buff_Sz];
     306
     307 // Ajout Reza (18/6/2002) pour fichier de flags separe
     308 int* stmpflg = NULL;
     309 if (sepFlagfile) stmpflg = new int[Buff_Sz];
     310 // Fin modif pour fichier de flags separe (18/6/2002)
     311 
    239312
    240313 TOIManager* mgr = TOIManager::getManager();
     
    286359       if(colflg[k]==NULL)  continue;
    287360       fits_read_col_lng(fptr,j+2,ideb+1,1,n,0,colflg[k],&anyNul,&fstatus);
     361       // Ajout Reza (18/6/2002) pour fichier de flags separe
     362       if (sepFlagfile) {
     363         uint_8 sflg = 0;
     364         int sjj;
     365         for(sjj=0; sjj<n; sjj++) colflg[k][sjj] = 0;
     366         for(int skf=0; skf<sepFlagCols.size(); skf++) {
     367           fits_read_col_int(fptrflg, skf+1, ideb+1,1,n,0,stmpflg,&anyNul,&fstatus);
     368           for(sjj=0; sjj<n; sjj++)
     369             if (stmpflg) colflg[k][sjj] |= sepFlagCols[skf];
     370         }
     371       }  // Fin modif pour fichier de flags separe (18/6/2002)
     372
    288373     }
    289374     if(fstatus!=0) {
     
    316401 delete [] samplenum;
    317402 delete [] tmpflg;
     403 if (sepFlagfile) delete [] stmpflg;
    318404 {for(int k=0; k<getNOut(); k++) {
    319405   if(colval[k]!=NULL) delete [] colval[k];
  • trunk/ArchTOIPipe/Kernel/fitstoirdr.h

    r1994 r2058  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: fitstoirdr.h,v 1.11 2002-05-13 13:11:32 ansari Exp $
     7// $Id: fitstoirdr.h,v 1.12 2002-06-18 12:21:08 ansari Exp $
    88
    99
     
    1717#include <map>
    1818#include "fitsio.h"
    19 
     19#include "flagtoidef.h"
    2020
    2121class FITSTOIReader : public TOIProcessor {
     
    3030
    3131  virtual void addFile(string fn);
     32
     33  // Methode rajoutee pour gerer les fichiers de flag de LevelS
     34  // Reza 18/6/2002
     35  // fn : Nom du fichier FITS,
     36  // flags: Indique le nombre de colonne et la correspondence avec les
     37  // flags d'ArchTOIPipe flags[0..N-1] ---> 1ere...Neme colonnes
     38  virtual void setFlagFile(string fn, vector<FlagToiDef> flags);
    3239
    3340  virtual void init(); 
     
    6572  int_8 totnscount;   // Nombre total d'echantillon processe
    6673
     74  // Variables rajoutee pour gerer les fichiers de flag de LevelS (Reza 18/6/2002)
     75  bool sepFlagfile;
     76  string sepFlagFileName;
     77  vector<FlagToiDef> sepFlagCols;
     78  fitsfile* fptrflg;
     79
    6780};
    6881
  • trunk/ArchTOIPipe/ProcWSophya/toi2map.cc

    r2054 r2058  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toi2map.cc,v 1.26 2002-06-11 17:14:25 ansari Exp $
     5// $Id: toi2map.cc,v 1.27 2002-06-18 12:21:08 ansari Exp $
    66
    77#include "machdefs.h"
     
    2020 SetCoorIn();
    2121 SetCoorMap();
     22 SetCalibrationFactor();
    2223 SetTestFlag();
    2324 SetTestMin();
     
    195196  int_4 ipix = mMap->PixIndexSph(theta,phi);
    196197  if ((ipix < 0) || (ipix >= mMap->NbPixels()) ) continue;
    197   (*mMap)(ipix) += bolo;   
     198  (*mMap)(ipix) += bolo*mCalibFactor;   
    198199  ((*mWMap)(ipix)) += 1;
    199200  mNSnFill++;
  • trunk/ArchTOIPipe/ProcWSophya/toi2map.h

    r2012 r2058  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: toi2map.h,v 1.15 2002-05-16 20:39:53 ansari Exp $
     7// $Id: toi2map.h,v 1.16 2002-06-18 12:21:09 ansari Exp $
    88
    99#ifndef TOI2MAP_H
     
    5858              {mTypCoorMap = DecodeTypAstro(ctype);}
    5959
     60  // Facteur de calibration
     61  inline void SetCalibrationFactor(double fac = 1.)
     62              { mCalibFactor = fac; }
     63  inline double GetCalibrationFactor()
     64              { return  mCalibFactor; }
     65     
    6066  // Test on flag value ? if yes, BAD sample have flag matching mBadFlag
    6167  inline void SetTestFlag(bool tflg=false, uint_8 badflg=FlgToiAll)
     
    8187  double mActualYear;
    8288
     89  double mCalibFactor;
    8390  bool mTFlag,mTMin,mTMax;
    8491  uint_8 mBadFlag;
  • trunk/ArchTOIPipe/TestPipes/toistat.cc

    r2054 r2058  
    4545    cout << "\n Usage : toistat [-intoi toiname] [-start snb] [-end sne] \n"
    4646         << "         [-wtoi sz] [-wclean wsz,nbw] [-range min,max] [-cleannsig nsig] \n"
    47          << "         [-outppf] [-noprstat] [-useseqbuff] \n"
     47         << "         [-sepflg sepFlagFile] [-outppf] [-noprstat] [-useseqbuff] \n"
    4848         << "         inFitsName outFileName \n"
    4949         << "   -start snb : sets the start sample num \n"
     
    5252         << "              default= -16000,16000\n"
    5353         << "   -intoi toiName : select input TOI name (def bolo)\n"
     54         << "   -sepflg sepFlagFileName: sets separate flag file (Level2)\n"
    5455         << "   -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
    5556         << "   -wclean wsz,nbw : sets cleaner window parameters (256,5) \n"
     
    9091  int clean_nbw = 5;
    9192  double clean_nsig = 999999.;
     93
     94// Fichier de flag separe / Level2 / Reza 18/6/2002
     95  string sepflagfile;   
     96  bool sepflg = false; 
    9297
    9398  // File names
     
    130135      intoi = arg[ia+1]; ia++;
    131136    }   
     137    else if (strcmp(arg[ia],"-sepflg") == 0) {
     138      if (ia == narg-1) Usage(true); 
     139      sepflagfile = arg[ia+1];
     140      sepflg = true; ia++;
     141    }   
    132142    else if (strcmp(arg[ia],"-outppf") == 0)  fgoutppf = true;
    133143
     
    166176    cout << "> Creating FITSTOIReader object - InFile=" << infile << endl;
    167177    FITSTOIReader r(infile);
     178    if (sepflg) {
     179      cout << " Setting separate flag file for InTOI_bolo File=" << sepflagfile
     180           << " (Flags=FlgToiSpike, FlgToiSource)" << endl;
     181      vector<FlagToiDef> flgcol;
     182      flgcol.push_back(FlgToiSpike);
     183      flgcol.push_back(FlgToiSource);
     184      r.setFlagFile(sepflagfile, flgcol);
     185    }
    168186
    169187    cout << "> Creating SimpleCleaner() " << endl;
  • trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc

    r2050 r2058  
    2727     <<"           [-a label_coord1] [-d label_coord2] [-b label_bolomuv]"<<endl
    2828     <<"           [-n nlat] [-i c,h] [-o c,h]"<<endl
    29      <<"           [-m vmin] [-M vmax] [-f flag]"<<endl
     29     <<"           [-m vmin] [-M vmax] [-f flag] [-F sepFlagFileName]"<<endl
    3030     <<"           fitsin_point fitsin_bolo fitsphout [fitsphwout]"<<endl
    3131     <<" -p lp : print level (def=0)"<<endl
     
    4444     <<" -f flag : samples are bad if match flag"<<endl
    4545     <<" -N nbfiles : Number of fitsin_point files fitsin_point%d.fits 0..nb-1"<<endl
     46     <<" -c calibcoeff : Coefficient de calibration a appliquer (def=1.)"<<endl
    4647     <<" -I : sampleNum are implicit in fits files (def=no)"<<endl
     48     <<" -F sepFlagFileName : separate flag file name for levelS"<<endl
     49     <<"                      (FlagColName: Glitch PtSrc)"<<endl
    4750     <<" fitsin_point : fits file for pointing"<<endl
    4851     <<" fitsin_bolo : fits file for bolo values"<<endl
     
    7073bool fgprstat = true;
    7174int nbpointfiles = 0;
     75double coeffcalib = 1.;
     76string sepflagfile;   // Fichier de flag separe / Level2 / Reza 18/6/2002
     77bool sepflg = false;  //   "     "     "      "       "       "       "
     78
    7279int c;
    73 while((c = getopt(narg,arg,"hIp:s:w:a:d:b:n:i:o:m:M:f:e:N:")) != -1) {
     80while((c = getopt(narg,arg,"hIp:s:w:a:d:b:n:i:o:m:M:f:e:N:c:F:")) != -1) {
    7481  switch (c) {
    7582  case 's' :
     
    125132    nbpointfiles = atoi(optarg);
    126133    break;
     134  case 'c' :
     135    coeffcalib = atof(optarg);
     136    break;
    127137  case 'I' :
    128138    snimplicit = true;
     139    break;
     140  case 'F' :
     141    sepflagfile = optarg;
     142    sepflg = true;
    129143    break;
    130144  case 'h' :
     
    154168    <<"  ...... ctype="<<tcoormap<<endl;
    155169cout<<"Equinoxe "<<equi<<" years"<<endl;
    156 
     170cout<<"CoeffCalib "<<coeffcalib<<endl;
     171 
    157172SophyaInit();
    158173InitTim();
     
    170185 if(ncolb<1) exit(-4);
    171186
     187
     188 sepflagfile = optarg;
     189 sepflg = true;
     190 if (sepflg) {
     191   cout << " Setting separate flag file for InTOI_bolo File=" << sepflagfile
     192        << " (Flags=FlgToiSpike, FlgToiSource)" << endl;
     193   vector<FlagToiDef> flgcol;
     194   flgcol.push_back(FlgToiSpike);
     195   flgcol.push_back(FlgToiSource);
     196   rfitsb.setFlagFile(sepflagfile, flgcol);
     197 }
    172198 string pointfileI = fitsin_point;
    173199 MuTyV numf=0;
     
    212238 toi2m.SetTestMin(tmin,vmin);
    213239 toi2m.SetTestMax(tmax,vmax);
     240 toi2m.SetCalibrationFactor(coeffcalib);
    214241 toi2m.Print(cout);
    215242
Note: See TracChangeset for help on using the changeset viewer.