Changeset 3701 in Sophya
- Timestamp:
- Dec 5, 2009, 1:00:11 AM (16 years ago)
- Location:
- trunk/AddOn/TAcq
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/brproc.cc
r3698 r3701 57 57 visdt_.AddFloatColumn("vim"); 58 58 59 /*60 char colnm[32];61 for(size_t i=0; i<2*memgr_.NbFibres(); i++) {62 for(size_t j=i; j<2*memgr_.NbFibres(); j++) {63 sprintf(colnm,"vr_%d_%d",(int)(i+1),(int)j+1);64 visdt_.AddFloatColumn(colnm);65 sprintf(colnm,"vi_%d_%d",(int)(i+1),(int)j+1);66 visdt_.AddFloatColumn(colnm);67 }68 }69 */70 59 if (nmean_ < 1) nmean_=memgr_.NbPaquets(); 71 60 if (nmean_ < 1) nmean_=1; … … 95 84 POutPersist po(outpath_+"visdt.ppf"); 96 85 po << visdt_; 86 POutPersist poc(outpath_+"chanum.ppf"); 87 po << chanum_; 88 97 89 delete[] xnt_; 98 90 } … … 109 101 if (totnbpaq_%nmean_ == 0) { 110 102 if (totnbpaq_ > 0) { 103 moyfc_/=nmean_; 104 moytt_/=nmean_; 105 vismtx_.Info()["MeanFC"] = moyfc_; 106 vismtx_.Info()["MeanTT"] = moytt_; 107 vismtx_.Info()["NPAQSUM"] = nmean_; 108 111 109 // ATTENTION : Matrice visibilites non moyennee 112 110 char nfile[32]; … … 117 115 cout << numfile_ << "-BRVisibilityCalculator::Process() NPaqProc=" 118 116 << totnbpaq_ << " -> Visibility Matrix in " << flnm << endl; 119 moyfc_/=nmean_;120 moytt_/=nmean_;121 117 FillVisibTable(moyfc_, moytt_); 122 118 numfile_++; -
trunk/AddOn/TAcq/svv2mtx.cc
r3699 r3701 4 4 5 5 /* ---------------------------------------------------------- 6 Programme de lecture multi canaux pour BAORadio 7 R. Ansari, C. Magneville 6 Projet BAORadio - (C) LAL/IRFU 2008-2010 7 8 Programme de lecture des fichiers vecteurs/matrices de 9 visibilites produits par mcrd / vismfib 10 R. Ansari, C. Magneville - LAL/Irfu 8 11 V : Mai 2009 9 12 ---------------------------------------------------------- */ … … 23 26 // #include "tarrinit.h" 24 27 #include "ntuple.h" 28 #include "datatable.h" 25 29 #include "histinit.h" 26 30 #include "matharr.h" 27 31 #include "timestamp.h" 32 #include <utilarr.h> 28 33 29 34 // include sophya mesure ressource CPU/memoire ... … … 33 38 34 39 40 //--------------------------- Fonctions de ce fichier ------------------- 35 41 int Usage(bool fgshort=true); 36 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW) 37 int ProcSVFilesVJun09(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, int card=1); 38 int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq); 42 43 int DecodeProc(int narg, char* arg[]); 44 int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, 45 vector<sa_size_t> tfrlist); 46 int FillVisDTable(BaseDataTable& visdt_, TMatrix< complex<r_4> > visdt_, TVector< uint_4> chanum_, 47 sa_size_t jf1_, sa_size_t jf2_, sa_size_t djf_) ; 48 49 int DecodeProcVJun09(int narg, char* arg[]); 50 int ProcSVFilesVJun09(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, int card); 51 //------------------------------------------------------------------------------------------------------------ 52 53 /* --Fonction-- */ 54 int Usage(bool fgshort) 55 { 56 cout << " --- svv2mtx.cc : Read PPF files produced by mcrd/visfmib to make time-frequency\n" 57 << " matrices and Visibilites=f(time) datatable " << endl; 58 cout << " Usage: svv2mtx -mcrd InOutPath Imin,Imax,step NumFreq1,NumFreq2,NBinFreq [card=1] \n" 59 << " OR \n" 60 << " svv2mtx InOutPath Imin,Imax,step NumFreq1,NumFreq2,NBinFreq VisMtxRowList" << endl; 61 if (fgshort) { 62 cout << " svv2mtx -h for detailed instructions" << endl; 63 return 1; 64 } 65 cout << " -mcrd : Read mcrd output files -> ProcSVFilesVJun09() \n" 66 << " InOutPath : Input/Output directory name \n" 67 << " Imin,Imax,IStep: Input PPF files sequence number \n" 68 << " FileNames=InOutPath/Ch12_II.fits Imin<=II<=Imax II+=IStep \n" 69 << " NumFreq1,NumFreq2,NBinFreq: Freq Zone and number of frequency bins for ntuple\n" 70 << " VisMtxRowList : List of visibiliy matrix rows (0,2,...) -> time-freq map \n" 71 << " card=1 Ch12 , card=2 Ch34 (mcrd output files) " << endl; 72 return 1; 73 } 39 74 40 75 //---------------------------------------------------- … … 44 79 if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false); 45 80 if (narg<4) return Usage(true); 46 47 81 HiStatsInitiator _inia; 48 82 // TArrayInitiator _inia; … … 50 84 int rc = 0; 51 85 try { 52 string inoutpath = arg[1]; 53 int imin=0; 54 int imax=0; 55 int istep=1; 56 sscanf(arg[2],"%d,%d,%d",&imin,&imax,&istep); 57 int jf1=0; 58 int jf2=0; 59 int nfreq=0; 60 sscanf(arg[3],"%d,%d,%d",&jf1,&jf2,&nfreq); 61 int card=1; 62 if (narg>4) card=atoi(arg[4]); 63 cout << " ----- svv2mtx.cc Start - InOutPath= " << inoutpath << " IMin,Max,Step=" 64 << imin << "," << imax << "," << istep << " Card=" << card << endl; 65 cout << "Frequency num range JF=" << jf1 << "," << jf2 << "," << nfreq << " ------- " << endl; 86 bool fgvjun09=false; 87 if ((strcmp(arg[1],"-mcrd")==0)) fgvjun09=true; 66 88 ResourceUsage resu; 67 rc=ProcSVFilesVJun09(inoutpath, imin, imax, istep, jf1, jf2, nfreq, card); 89 if (fgvjun09) DecodeProcVJun09(narg-2, arg+2); 90 else DecodeProc(narg-1, arg+1); 68 91 resu.Update(); 69 92 cout << resu; … … 89 112 } 90 113 91 114 //-------------------------------------------------------------------- 115 // Traitement fichiers produits par vismfib (V Nov09) 116 /* --Fonction-- */ 117 int DecodeProc(int narg, char* arg[]) 118 { 119 // Decodage des arguments et traitement 120 string inoutpath = arg[0]; 121 int imin=0; 122 int imax=0; 123 int istep=1; 124 sscanf(arg[1],"%d,%d,%d",&imin,&imax,&istep); 125 int jf1=0; 126 int jf2=0; 127 int nfreq=0; 128 sscanf(arg[2],"%d,%d,%d",&jf1,&jf2,&nfreq); 129 int card=1; 130 vector<sa_size_t> rowlist; 131 if (narg>3) { 132 EnumeratedSequence es; 133 int nbad; 134 es.Append(arg[3], nbad, ","); 135 for(int j=0; j<es.Size(); j++) rowlist.push_back((int)es.Value(j)); 136 } 137 if (rowlist.size()<1) rowlist.push_back(0); 138 139 cout << " ----- svv2mtx/DecodeProc - Start - InOutPath= " << inoutpath << " IMin,Max,Step=" 140 << imin << "," << imax << "," << istep << " Card=" << card << endl; 141 cout << "Frequency num range JF=" << jf1 << "," << jf2 << "," << nfreq << " ------- " << endl; 142 cout << " RowList: " ; 143 for(int j=0; j<rowlist.size(); j++) cout << rowlist[j] << " , " ; 144 cout << endl; 145 int rc=ProcSVFiles(inoutpath, imin, imax, istep, jf1, jf2, nfreq, rowlist); 146 return rc; 147 } 92 148 93 149 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW) 150 /* --Fonction-- */ 151 int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, 152 vector<sa_size_t> rowlist) 153 { 154 Timer tm("ProcSVFiles"); 155 156 vector< TMatrix< complex<r_4> > > vmtf(rowlist.size()); 157 158 DataTable visdt; 159 visdt.AddDoubleColumn("mfc"); 160 visdt.AddDoubleColumn("mtt"); 161 visdt.AddIntegerColumn("jfreq"); 162 visdt.AddIntegerColumn("numch"); 163 visdt.AddFloatColumn("vre"); 164 visdt.AddFloatColumn("vim"); 165 166 if (jf1<1) jf1=1; 167 if ((jf2<1)||(jf2<jf1)) jf2=jf1; 168 if (nfreq<1) nfreq=1; 169 int djf=(jf2-jf1)/nfreq; 170 if (djf<1) djf=0; 171 172 char fname[1024]; 173 174 TVector< uint_4 > chanum; 175 sprintf(fname, "%s/chanum.ppf",inoutpath.c_str()); 176 { 177 PInPersist pic(fname); 178 pic >> chanum; 179 } 180 181 sa_size_t nrows = (imax-imin+1)/istep;\ 182 sa_size_t kr=0; 183 184 for(int ifile=imin; ifile<=imax; ifile+=istep) { 185 sprintf(fname, "%s/vismtx%d.ppf",inoutpath.c_str(),ifile); 186 cout << " ProcSVFiles[" << ifile << "] opening file " << fname << endl; 187 PInPersist pin(fname); 188 TMatrix< complex<r_4> > vismtx; 189 pin >> vismtx; 190 191 if (ifile==imin) { 192 sa_size_t ncols = vismtx.NCols(); 193 cout << " ProcSVFilesVJun09/Info: Output Time-Frequency matrices NRows=NFiles" 194 << nrows << " NCols=NFreq=" << ncols << endl; 195 for(size_t j=0; j<rowlist.size(); j++) vmtf[j].SetSize(nrows, ncols); 196 } 197 for(size_t j=0; j<rowlist.size(); j++) 198 vmtf[j].Row(kr) = vismtx.Row(rowlist[j]); 199 kr++; 200 201 // Calcul moyenne dans des bandes en frequence 202 FillVisDTable(visdt, vismtx, chanum, jf1, jf2, djf); 203 } 204 205 sprintf(fname, "%s/vistfreqmtx.ppf",inoutpath.c_str()); 206 cout << "ProcSVFiles: Opening file " << fname << " for writing Visi(Freq,Time) matrices" << endl; 207 POutPersist po(fname); 208 char tagb[64]; 209 for(size_t j=0; j<rowlist.size(); j++) { 210 sprintf(tagb,"visft%d", chanum(rowlist[j])); 211 po << PPFNameTag(tagb) << vmtf[j]; 212 } 213 cout << visdt; 214 sprintf(fname, "%s/svvdt.ppf",inoutpath.c_str()); 215 cout << "ProcSVFile: writing visibility datatable to file " << fname << endl; 216 POutPersist pod(fname); 217 pod << visdt; 218 219 return 0; 220 } 221 222 /* --Fonction-- */ 223 int FillVisDTable(BaseDataTable& visdt_, TMatrix< complex<r_4> > vismtx_, TVector< uint_4> chanum_, 224 sa_size_t jf1_, sa_size_t jf2_, sa_size_t djf_) 225 { 226 double xnt_[20]; 227 xnt_[0]=(double)vismtx_.Info()["MeanFC"]; 228 xnt_[1]=(double)vismtx_.Info()["MeanTT"]/1.25e8; 229 230 uint_4 nmean_=vismtx_.Info()["NPAQSUM"]; 231 if (djf_<2) { 232 for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) { 233 for(sa_size_t jf=jf1_; jf<jf2_; jf++) { 234 xnt_[2]=jf; 235 xnt_[3]=chanum_(rv); 236 xnt_[4]=vismtx_(rv,jf).real()/(r_4)(nmean_); 237 xnt_[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_); 238 visdt_.AddRow(xnt_); 239 } 240 } 241 } 242 else { 243 for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) { 244 for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) { 245 r_4 moyreal=0.; 246 r_4 moyimag=0.; 247 for(sa_size_t jjf=jf; jjf<jf+djf_; jjf++) { 248 moyreal+=vismtx_(rv,jjf).real(); 249 moyimag+=vismtx_(rv,jjf).imag(); 250 } 251 xnt_[2]=jf+djf_/2; 252 xnt_[3]=chanum_(rv); 253 xnt_[4]=moyreal/(r_4)(nmean_*djf_); 254 xnt_[5]=moyimag/(r_4)(nmean_*djf_); 255 visdt_.AddRow(xnt_); 256 } 257 } 258 } 259 return 0; 260 } 261 262 263 //-------------------------------------------------------------------- 264 // Traitement fichiers produits par mcrd (V Jun09) 265 /* --Fonction-- */ 266 int DecodeProcVJun09(int narg, char* arg[]) 267 { 268 // Decodage des arguments et traitement 269 string inoutpath = arg[0]; 270 int imin=0; 271 int imax=0; 272 int istep=1; 273 sscanf(arg[1],"%d,%d,%d",&imin,&imax,&istep); 274 int jf1=0; 275 int jf2=0; 276 int nfreq=0; 277 sscanf(arg[2],"%d,%d,%d",&jf1,&jf2,&nfreq); 278 int card=1; 279 if (narg>3) card=atoi(arg[3]); 280 cout << " ----- svv2mtx/DecodeProcVJun09 - Start - InOutPath= " << inoutpath << " IMin,Max,Step=" 281 << imin << "," << imax << "," << istep << " Card=" << card << endl; 282 cout << "Frequency num range JF=" << jf1 << "," << jf2 << "," << nfreq << " ------- " << endl; 283 int rc=ProcSVFilesVJun09(inoutpath, imin, imax, istep, jf1, jf2, nfreq, card); 284 return rc; 285 } 286 287 288 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW) 289 /* --Fonction-- */ 94 290 int ProcSVFilesVJun09(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, int card) 95 291 { … … 113 309 else 114 310 sprintf(fname, "%s/Ch12_%d.ppf",inoutpath.c_str(),ifile); 115 cout << " ProcSVFiles [" << ifile << "] opening file " << fname << endl;311 cout << " ProcSVFilesVJun09[" << ifile << "] opening file " << fname << endl; 116 312 PInPersist pin(fname); 117 313 string tag1="specV1"; … … 218 414 219 415 220 221 222 /* --Fonction-- */223 int Usage(bool fgshort)224 {225 cout << " --- svv2mtx.cc : Read PPF files produced by mcrd to make matrices BAORadio" << endl;226 cout << " Usage: mcrd InOutPath Imin,Imax,step NumFreq1,NumFreq2,NBinFreq [card=1]" << endl;227 if (fgshort) {228 cout << " mcrd -h for detailed instructions" << endl;229 return 1;230 }231 cout << " InOutPath : Input/Output directory name " << endl;232 cout << " Imin,Imax,IStep: Input PPF files sequence number \n"233 << " FileNames=InOutPath/Ch12_II.fits Imin<=II<=Imax II+=IStep \n"234 << " NumFreq1,NumFreq2,NBinFreq: Freq Zone and number of frequency bins for ntuple\n"235 << " card=1 Ch12 , card=2 Ch34 " << endl;236 return 1;237 }
Note:
See TracChangeset
for help on using the changeset viewer.