Changeset 3733 in Sophya
- Timestamp:
- Jan 26, 2010, 6:22:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/svv2mtx2.cc
r3732 r3733 17 17 #include <stdlib.h> 18 18 #include <string.h> 19 #include <unistd.h> 19 20 #include <sys/stat.h> 20 21 #include <iostream> … … 29 30 int Usage(void) 30 31 { 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; 32 cout<<" --- 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; 35 35 return 1; 36 36 } … … 40 40 { 41 41 // --- 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"; 45 43 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]; 47 65 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]; 51 71 52 72 // --- recherche des fichiers de visibilites … … 109 129 throw ParmError("ERROR: nvisi != chanum.Size() !!!"); 110 130 // how many average frequencies ? 111 if(jfr1<=0) jfr1= 1;131 if(jfr1<=0) jfr1=0; 112 132 if(jfr1>=nfreq0) jfr1=nfreq0-1; 113 133 if(jfr2<jfr1 || jfr2>=nfreq0) jfr2=nfreq0-1; 114 if(nbinfreq<=0) nbinfreq=1;115 134 if(nbinfreq>jfr2-jfr1+1) nbinfreq=jfr2-jfr1+1; 116 135 nmoyfreq = (jfr2-jfr1+1)/nbinfreq; 117 136 if(nmoyfreq*nbinfreq<jfr2-jfr1+1) nmoyfreq++; 137 nbinfreq = (jfr2-jfr1+1) / nmoyfreq; 138 if(nmoyfreq*nbinfreq<jfr2-jfr1+1) nbinfreq++; 118 139 cout<<"frequency averaging: jfr1="<<jfr1<<" jfr2="<<jfr2 119 140 <<" nbinfreq="<<nbinfreq<<" (nmoyfreq="<<nmoyfreq<<")"<<endl; … … 162 183 } 163 184 164 sprintf(str, "%s/ svvdt2.ppf",inoutpath.c_str());185 sprintf(str, "%s/%s",inoutpath.c_str(),ppfoutname.c_str()); 165 186 cout<<"writing visibility matrix to file "<<str<<endl; 166 187 POutPersist pos(str);
Note:
See TracChangeset
for help on using the changeset viewer.