Changeset 350 in Sophya for trunk


Ignore:
Timestamp:
Aug 4, 1999, 4:10:06 PM (26 years ago)
Author:
ansari
Message:

Gestion TRANGE, MJD0, PERECH....

Location:
trunk/Poubelle/archTOI.old
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Poubelle/archTOI.old/archeopsfile.cc

    r346 r350  
     1// archeopsfile.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#define utilitaires_de_block_archeops
    26#include "archeopsfile.h"
     
    335339        type_block(peekBlock) < 0 || type_block(peekBlock) > 19 ||
    336340        longueur_block(peekBlock) != long_block[type_block(peekBlock)]) {
    337       cout << "block de type/longueur invalide" << endl;
     341      cout << "invalid block, bad type or length" << endl;
    338342      memset(peekBlock, 0, sizeof(block_type_modele)); // don't keep trash...
    339343      peekPos = searchNextBlock(peekPos);
     
    343347    swapContent(peekBlock);
    344348    if (verifie_block(peekBlock) != block_correct) {
    345       cout << "block invalide " << numero_block(peekBlock);
     349      cout << "invalid block " << numero_block(peekBlock);
    346350      if (!fixBlock(peekBlock)) {
    347351        cout << " -- skipped" << endl;
     
    378382}
    379383
    380 bool ArcheopsFile::fixBlock(block_type_modele* blk) {
     384bool ArcheopsFile::fixBlock(block_type_modele* ) {
    381385  return false;
    382386}
     
    505509           #else
    506510           block_type_param* param = lastParam();
     511           if (!param) return;
    507512           int jc=0;for(int j=0;j<nb_max_bolo;j++)       // jc = bolo_comprime  //   j=bolo normal
    508513           {
     
    730735  if (*p2 == ':' || *p2 == '/') p2++;
    731736  if (*p2 == 'h') p2++;
    732   if (!strncmp(p2, "ARK",3)) {
     737  if (!strncmp(p2, "ARK",3) || !strncmp(p2,"ark",3)) {
    733738    rawMJD = 1377.4;
    734739  } else {
     
    806811bool ArcheopsFile::hasGPSTime() {
    807812  if (!lastGPS()) return false;
    808   return blockSet->gpsParser.hasGPSTime();
     813 // return blockSet->gpsParser.hasGPSTime();
     814  return blockSet->gpsParser.hasTime();
    809815}
    810816
  • trunk/Poubelle/archTOI.old/archeopsfile.h

    r342 r350  
     1// archeopsfile.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
    14#ifndef ARCHEOPSFILE_H
    25#define ARCHEOPSFILE_H
  • trunk/Poubelle/archTOI.old/archtoi.cc

    r342 r350  
     1// archtoi.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#include <string>
    26#include <iostream.h>
     
    2731void ArchTOI::init()
    2832{
    29   format = ascii;
     33  format = ascii_fmt;
    3034  undef  = "#";
    3135  allBolos = false;
     
    6064  tsttoi(sampleNum)
    6165  else tsttoi(internalTime)
    62   else tsttoi(utc)
     66  else tsttoi(mjd)
    6367  else tsttoi(boloTens)
    6468  else tsttoi(boloRaw)
    65   else tsttoi(sstSignal)
    66   else tsttoi(sstRaw)
     69  else tsttoi(sstDiode)
     70  else tsttoi(sstChannel)
    6771  else tsttoi(sstStarZ)
    6872  else tsttoi(sstStarF)
     
    117121  }
    118122  if (key == "#ASCII") {
    119     format = ascii;
     123    format = ascii_fmt;
     124  } else if (key == "#FITS") {
     125    format = fits_fmt;
    120126  } else if (key == "#TRANGE") {
    121127    double tmin, tmax;
     
    135141    double t0;
    136142    sscanf(arg.c_str(), "%lg", &t0);
    137     svr.SetMJD0(0);
     143    svr.SetMJD0(t0);
     144  } else if (key == "#PERECH") {
     145    double t0;
     146    sscanf(arg.c_str(), "%lg", &t0);
     147    svr.SetPerEch(t0);
    138148  } else if (key == "#END") {
    139149    return false;
     
    190200  while (iter.Next()) {
    191201    int nn = iter.getSampleIndex();
    192     // if (nn%200 == 0) {cout << "."; cout.flush();
    193     //   if (ofn != iter.currentFile()->filename()) {
    194     //    ofn = iter.currentFile()->filename();
    195     //   cout << "current file=" << ofn << endl;
    196     //  }
    197       //}
    198       //if (nn%(200*80) == 0) cout << endl;
     202     if (nn%200 == 0) {
     203       cout << "."; cout.flush();
     204     }
     205     if (nn%(200*80) == 0) cout << endl;
    199206    // Si rien de dispo parmi les triggering, alors on passe au suivant
    200207    bool hasValue = false;
  • trunk/Poubelle/archTOI.old/archtoi.h

    r342 r350  
     1// archtoi.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
    14#ifndef ARCHTOI_H
    25#define ARCHTOI_H
     
    1821  void run(string const& filename);
    1922 
    20   enum fmt {ascii};
     23  enum fmt {ascii_fmt, fits_fmt};
    2124  enum flg {hasflag = 1,
    2225            useNA   = 2};
  • trunk/Poubelle/archTOI.old/archtoidump.cc

    r342 r350  
     1// archtoidump.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
    13
    24#include <iostream.h>
  • trunk/Poubelle/archTOI.old/archtoimain.cc

    r342 r350  
     1// archtoimain.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
    14#include <iostream.h>
    25#include <fstream.h>
  • trunk/Poubelle/archTOI.old/gpsparser.cc

    r346 r350  
     1// gpsparser.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#include <string.h>
    26#include <stdio.h>
     
    6367// $104020,3740.712,N,00400.781,W,0,00,01.0,0003,M,-050,M,,
    6468
    65 //#include <fstream.h>
    66 //#include <iomanip.h>
     69#include <fstream.h>
     70#include <iomanip.h>
    6771//ofstream gpsdump("gpsdump");
    6872//ofstream gpsdata("gpsdata");
     
    7276  strncpy(gpsString, blk->gps, 80);
    7377  char* p = gpsString;
    74  // gpsdump << p ; if (p[strlen(p)-1] != '\n') gpsdump << '\n';
     78// gpsdump << p ; if (p[strlen(p)-1] != '\n') gpsdump << '\n';
    7579  char* fence = p+80;
    7680  stringOk = false;
     
    154158  if (*p != 'M') return;
    155159
    156   //if (gpsutc < outc) jr += 86400;
    157   //outc = gpsutc;
    158   //gpsdata << setprecision(10) << gpsutc + jr << " " << gpslat << " " << gpslong << " " << quality << " " << nsat << '\n';
     160//  if (gpsutc < outc) jr += 86400;
     161//  outc = gpsutc;
     162//  gpsdata << setprecision(10) << gpsutc + jr << " " << gpslat << " " << gpslong << " " << quality << " " << nsat << '\n';
    159163
    160164  stringOk = true;
  • trunk/Poubelle/archTOI.old/gpsparser.h

    r342 r350  
     1// gpsparser.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
    14#ifndef GPSPARSER_H
    25#define GPSPARSER_H
  • trunk/Poubelle/archTOI.old/ssthandler.cc

    r342 r350  
     1// ssthandler.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15// Prediction mouvement d'etoiles entre un tour et le suivant...
    26// si TS -> TS + dT, H -> H + dT,    dT=dH
  • trunk/Poubelle/archTOI.old/ssthandler.h

    r342 r350  
     1// ssthandler.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
    14#ifndef SSTHANDLER_H
    25#define SSTHANDLER_H
  • trunk/Poubelle/archTOI.old/toiinterpolator.cc

    r342 r350  
     1// toiinterpolator.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#include "toiinterpolator.h"
    26
  • trunk/Poubelle/archTOI.old/toiinterpolator.h

    r342 r350  
     1// toiinterpolator.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#ifndef TOIINTERPOLATOR_H
    26#define TOIINTERPOLATOR_H
  • trunk/Poubelle/archTOI.old/toiiter.cc

    r342 r350  
     1// toiiter.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#include "toiiter.h"
    26#include "toiinterpolator.h"
     
    1317 file = NULL;
    1418 directory = "";
    15  fileName = "";
    1619 
    1720 files.clear();
     
    2629 tBlock0 = -1;
    2730 perEch = -1;
     31 // Values for Trapani 99 = default values
     32 tBlock0 = 1376.8358818;
     33 perEch = 0.005836818076;
    2834 
    2935 trigMask = 0;
     
    3743TOIIter::TOIIter(TOIIter const& x) {
    3844  directory = x.directory;
    39   fileName = x.fileName;
    4045  files = x.files;
    4146  //  curFile = x.curFile; // $CHECK$ DANGER !!
     
    8287
    8388void TOIIter::Init() {
    84  // On a soit un repertoire, soit un fichier, soit une liste de fichiers....
     89 // On a soit un repertoire, soit une liste de fichiers....
    8590  if (directory == "") {
    86     if (files.empty()) {   // un seul fichier
    87       file = new ArcheopsFile(fileName);
     91    if (files.empty()) {   // Ni repertoire, ni fichiers
     92      cerr << "toiiter : pas de repertoire, pas de fichiers" << endl;
     93      exit(-1);
    8894    } else {
    89       curFile = files.begin();
    90       file = new ArcheopsFile((*curFile).c_str());
     95      // On a deja une liste de fichiers
    9196    }
    9297  } else { // On a un repertoire a explorer
     
    123128          }
    124129        } else if (isOnBoardRecorder) {
    125           if (strncmp(ent->d_name, "ARK", 3)) continue;
     130          if (strncmp(ent->d_name, "ARK", 3) && strncmp(ent->d_name, "ark", 3)) continue;
    126131          char * sfx = ent->d_name + strlen(ent->d_name) - 4;
    127           if (strcmp(sfx, ".DAT")) continue;
     132          if (strcmp(sfx, ".DAT") && strcmp(sfx, ".dat")) continue;
    128133          files.insert(directory + ent->d_name);
    129134        }
     
    131136    }
    132137    closedir(dir);
    133     curFile = files.begin();
    134     file = new ArcheopsFile((*curFile).c_str());
    135   }
     138  }
     139   
     140  ScanFiles();
     141 
     142  curFile = files.begin();
     143  file = new ArcheopsFile((*curFile).c_str());
     144  cout << "opening file " << (*curFile).c_str() << endl;
    136145
    137146  // On avance jusqu'a avoir au moins un bloc param et un bloc reglage,
     
    139148  // Si on a des donnees de l'enregistreur de vol, pas de bloc param, et
    140149  // on en simule un
     150  double oldTStart = tStart;
     151  tStart = -9.e99; // pour init, on accepte des blocs avant tstart....
     152 
    141153  if (!file->lastParam()) {
    142154    if (isOnBoardRecorder) {
     
    170182    file->popMark();
    171183  }
     184  tStart = oldTStart;  // on restaure
    172185 
    173186  if (perEch < 0)
     
    200213          trigMask |= block_sst_mask;
    201214          break;
    202         case sstSignal:
     215        case sstDiode:
    203216          file->needSSTProcessMask(SSTHandler::rmveOffset);
    204217          trigMask |= block_sst_mask;
    205218          break;
    206         case sstRaw:
     219        case sstChannel:
    207220          trigMask |= block_sst_mask;
    208221          break;
     
    234247    }
    235248    delete file; file = NULL; // on ne travaille plus sur le fichier directement...
     249  }
     250}
     251
     252void TOIIter::ScanFiles() {
     253  file1stSamp.clear();
     254  cout << "Scanning all files" << endl;
     255  // Petite astuce pour les STL non conformes comme celles de digital
     256  // qui ne supportent pas files.erase(i) suivi de i++....
     257  set<string> copy = files;
     258  for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
     259    ArcheopsFile fich((*i).c_str());
     260    if (fich.nextBlock()) {
     261      file1stSamp[*i] = fich.blockNum()*72; // premier numsample
     262      cout << "File " << *i << " 1st sample = " << fich.blockNum()*72 << endl;
     263    } else {
     264      cout << "File " << *i << " unrecoverable, skipping" << endl;
     265      files.erase(*i);
     266    }
     267  }
     268  cout << "Scan done" << endl;
     269 
     270  // Et maintenant, on ne garde que ceux qui tombent dans l'intervalle...
     271  copy = files;
     272  string prev="";
     273  for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
     274    double smp = file1stSamp[*i];
     275    double t   = tBlock0 + smp * perEch/86400.;
     276    if (t>tEnd) {  // premier echantillon apres tEnd
     277     files.erase(*i);
     278     prev = "";
     279     continue;
     280    }
     281    if (t<tStart) { // premier echantillon avant tStart -> on vire le precedent si existe
     282      if (prev != "") {
     283        files.erase(prev);
     284      }
     285    }
     286    prev = *i;
    236287  }
    237288}
     
    256307}
    257308
     309
    258310bool TOIIter::Next() {
     311  while (1) {
     312    if (!NextSample()) return false; // end of files
     313    double t = tBlock0+(file->blockNum() * file->nEchBlock() + imes) * perEch/86400.;
     314    if (t < tStart) continue;
     315    if (t > tEnd) return false;
     316    return true;
     317  }
     318}
     319
     320bool TOIIter::NextSample() {
    259321  if (rawIter) {  // Delegation pour interpolation
    260322    // Trouve prochain sample disponible
     
    324386     case sampleNum:
    325387     case internalTime:
    326      case utc:
     388     case mjd:
    327389       return true;
    328390     case boloTens:
     
    331393     case boloRaw:
    332394       return file->lastBolo() != NULL;
    333      case sstSignal:
    334      case sstRaw:
     395     case sstDiode:
     396     case sstChannel:
    335397       return file->lastSST() != NULL;
    336398     case sstStarZ:
     
    370432       //return (file->blockNum() * file->nEchBlock() + imes) * file->perEchant();
    371433       return (file->blockNum() * file->nEchBlock() + imes) * perEch;
    372      case utc:
    373       /* printf("utc: %d %d %g %g %g\n",file->blockNum(),
     434     case mjd:
     435      /* printf("mjd: %d %d %g %g %g\n",file->blockNum(),
    374436         (file->blockNum() * file->nEchBlock() + imes),
    375437         file->perEchant(),
     
    382444     case boloRaw:
    383445       return file->getRawBolo(index, imes);
    384      case sstSignal:
     446     case sstDiode:
    385447       return file->getSSTSignal(index, imes);
    386      case sstRaw:
     448     case sstChannel:
    387449       return file->getSSTRawSignal(index, imes);
    388450     case sstStarZ:
     
    419481     case sampleNum:
    420482     case internalTime:
    421      case utc:
     483     case mjd:
    422484       return true;
    423485     case boloTens:
     
    425487     case boloRaw:
    426488       return file->blockNum() == file->getBoloBlockNum();
    427      case sstRaw:
    428      case sstSignal:
     489     case sstChannel:
     490     case sstDiode:
    429491     case sstStarZ:
    430492     case sstStarF:
  • trunk/Poubelle/archTOI.old/toiiter.h

    r342 r350  
     1// toiiter.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
    14#ifndef TOIITER_H
    25#define TOIITER_H
     
    58#include <vector>
    69#include <set>
     10#include <map>
    711#include <string>
    812#include "archeopsfile.h"
     
    1115  sampleNum,  // Numero d''echantillon (timer interne transputer)
    1216  internalTime, // temps transputer depuis debut manip, en secondes.
    13   utc,        // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux.
     17  mjd,        // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux.
    1418  boloTens,   // tension en microVolts, filtree avec filtre carre indexe par bolometre
    1519  boloRaw,    // tension brute, non filtree indexe par bolometre
    1620  boloTemp,   // Kelvins
    17   sstSignal,  // signal brut SST, indice = diode, 0-45
    18   sstRaw,    // signal brut SST, indice = canal, 0-47
     21  sstDiode,   // signal brut SST, indice = diode, 0-45
     22  sstChannel, // signal brut SST, indice = canal, 0-47
    1923  sstStarZ,   // numero de diode d''une eventuelle etoile,   i=etoile 0..n
    2024  sstStarF,   // flux d''une eventuelle etoile,             <0 si moins de i+1 etoiles
     
    7882   TOIIter();
    7983   void Init(); // After setting the options, opens the first file.
     84   void ScanFiles(); // Parcourt tous les fichiers, cherche le premier echantillon...
    8085   
     86   bool NextSample(); // no test of trange
    8187   bool NextFile();
    8288   
    8389   ArcheopsFile* file;
    84    string directory;   // If several files to be read
    85    string fileName;    // If only one file to be read
    86    set<string> files;  // list of files in the directory...
     90   string directory;   // If directory scanning
     91   set<string> files;  // list of files to be read...
     92   map<string, long> file1stSamp; // premier echantillon de chaque fichier
    8793   set<string>::iterator curFile;
    8894   bool  isOnBoardRecorder;
  • trunk/Poubelle/archTOI.old/toisvr.cc

    r342 r350  
     1// toisvr.cc
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#include "toisvr.h"
    26
     
    610void TOISvr::SetDirectory(string d) {
    711  iter.directory = d;
    8   iter.fileName = "";
    9 }
    10 
    11 void TOISvr::SetFile(string f) {
    12   iter.directory = "";
    13   iter.fileName = f;
    1412}
    1513
    1614void TOISvr::AddFile(string f) {
    17   iter.directory = "";
    1815  iter.files.insert(f);
    1916}
     
    2320}
    2421
     22void TOISvr::SetPerEch(double t0) { // en secondes, periode d'echantillonnage
     23  iter.perEch = t0;
     24}
    2525
    2626void TOISvr::OnBoardRecorderFiles(bool x) {
  • trunk/Poubelle/archTOI.old/toisvr.h

    r342 r350  
     1// toisvr.h
     2// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     3
     4
    15#ifndef TOISVR_H
    26#define TOISVR_H
     
    913 
    1014  void SetDirectory(string);
    11   void SetFile(string);
    1215  void AddFile(string);
    1316  void OnBoardRecorderFiles(bool);
    1417  void SetMJD0(double);
     18  void SetPerEch(double);
    1519 
    1620  void SetTimeInterval(double tStart, double tEnd);
Note: See TracChangeset for help on using the changeset viewer.