Changeset 3733 in Sophya for trunk/AddOn


Ignore:
Timestamp:
Jan 26, 2010, 6:22:52 PM (16 years ago)
Author:
cmv
Message:

modifs sur calcul de nbinfreq + cosmetique, cmv 26/01/2010

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/svv2mtx2.cc

    r3732 r3733  
    1717#include <stdlib.h>
    1818#include <string.h>
     19#include <unistd.h>
    1920#include <sys/stat.h>
    2021#include <iostream>
     
    2930int Usage(void)
    3031{
    31 cout<<" --- svv2mtx2.cc : Read PPF files produced by mcrd/visfmib"<<endl
    32     <<"     and make time(row) - mean_frequency(col) matrices"<<endl
    33     <<"Usage: svv2mtx2 InOutPath Imin,Imax NumFreq1,NumFreq2,NBinFreq"<<endl
    34     << " svv2mtx2 -h for detailed instructions"<<endl;
     32cout<<" --- svv2mtx2.cc : Read PPF files produced by visfmib"<<endl
     33    <<"                   and make time(row) - mean_frequency(col) matrices"<<endl
     34    <<"Usage: svv2mtx2 -T Imin,Imax -F NumFreq1,NumFreq2,NBinFreq -o svvdt2.ppf InOutPath"<<endl;
    3535return 1;
    3636}
     
    4040{
    4141  // --- Decodage des arguments et traitement
    42   if ((narg>1)&&(strcmp(arg[1],"-h")==0))  return Usage();
    43   if (narg<=1) return Usage();
    44   string inoutpath = arg[1];
     42  string ppfoutname = "svvdt2.ppf";
    4543  int ifilmin=0, ifilmax=-1;
    46   if(narg>2) sscanf(arg[2],"%d,%d",&ifilmin,&ifilmax);
     44  int jfr1=0, jfr2=0, nbinfreq=0;
     45
     46  char c;
     47  while((c = getopt(narg,arg,"hT:F:o:")) != -1) {
     48    switch (c) {
     49    case 'T' :
     50      sscanf(optarg,"%d,%d",&ifilmin,&ifilmax);
     51      break;
     52    case 'F' :
     53      sscanf(optarg,"%d,%d,%d",&jfr1,&jfr2,&nbinfreq);
     54      break;
     55    case 'o' :
     56      ppfoutname = optarg;
     57      break;
     58    case 'h' :
     59    default :
     60      Usage(); return -1;
     61    }
     62  }
     63  if(optind>=narg) {Usage(); return -2;}
     64  string inoutpath = arg[optind];
    4765  if(ifilmin<0) ifilmin=0;
    48   int jfr1=0, jfr2=0, nbinfreq=0;
    49   if(narg>3) sscanf(arg[3],"%d,%d,%d",&jfr1,&jfr2,&nbinfreq);
    50   char str[1024];
     66  if(nbinfreq<=0) nbinfreq=1;
     67  cout<<"inoutpath="<<inoutpath<<endl;
     68  cout<<"request: file "<<ifilmin<<" to "<<ifilmax<<endl;
     69  cout<<"request: freq "<<jfr1<<" to "<<jfr2<<" grouped in "<<nbinfreq<<" bins"<<endl;
     70  char str[2048];
    5171
    5272  // --- recherche des fichiers de visibilites
     
    109129        throw ParmError("ERROR: nvisi != chanum.Size() !!!");
    110130      // how many average frequencies ?
    111       if(jfr1<=0) jfr1=1;
     131      if(jfr1<=0) jfr1=0;
    112132      if(jfr1>=nfreq0) jfr1=nfreq0-1;
    113133      if(jfr2<jfr1 || jfr2>=nfreq0) jfr2=nfreq0-1;
    114       if(nbinfreq<=0) nbinfreq=1;
    115134      if(nbinfreq>jfr2-jfr1+1) nbinfreq=jfr2-jfr1+1;
    116135      nmoyfreq = (jfr2-jfr1+1)/nbinfreq;
    117136      if(nmoyfreq*nbinfreq<jfr2-jfr1+1) nmoyfreq++;
     137      nbinfreq = (jfr2-jfr1+1) / nmoyfreq;
     138      if(nmoyfreq*nbinfreq<jfr2-jfr1+1) nbinfreq++;
    118139      cout<<"frequency averaging: jfr1="<<jfr1<<" jfr2="<<jfr2
    119140          <<" nbinfreq="<<nbinfreq<<" (nmoyfreq="<<nmoyfreq<<")"<<endl;
     
    162183  }
    163184
    164   sprintf(str, "%s/svvdt2.ppf",inoutpath.c_str());
     185  sprintf(str, "%s/%s",inoutpath.c_str(),ppfoutname.c_str());
    165186  cout<<"writing visibility matrix to file "<<str<<endl;
    166187  POutPersist pos(str);
Note: See TracChangeset for help on using the changeset viewer.