// Utilisation de SOPHYA pour faciliter les tests ... #include "sopnamsp.h" #include "machdefs.h" /* ---------------------------------------------------------- Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2015 visi2dtacx: programme de lecture des fichiers matrices de visibilites de PAON4, remplissage et ecriture d'un DataTable avec les cross-correlations en fonction du temps R. Ansari, J.E. Campagne, C. Magneville - LAL/Irfu ---------------------------------------------------------- */ // include standard c/c++ #include #include #include #include #include #include #include "pexceptions.h" #include "tvector.h" #include "fioarr.h" // #include "tarrinit.h" #include "ntuple.h" #include "datatable.h" #include "histinit.h" #include "matharr.h" #include "timestamp.h" #include // include sophya mesure ressource CPU/memoire ... #include "resusage.h" #include "ctimer.h" #include "timing.h" // include lecteur de fichiers visibilites #include "visip4reader.h" //--------------------------- Fonctions de ce fichier ------------------- int Usage(bool fgshort=true); // int DecodeArgs(int narg, char* arg[]); /* --Fonction-- */ int Usage(bool fgea) { cout << " --- visi2dtacx.cc : Read PPF files produced by mfacq time-frequency\n" << endl; if (fgea) cout << " visi2dtacx: Missing or wrong argument ! " << endl; cout << " Usage: visi2dtacx [-tfm Nf] InPathBAO5 InPathBAO6 Imin,Imax GainPPFFile OutPPFFile Freq1 Freq2 DeltaFreq DeltaIAvg [PrtLev=0] \n" << " -tfm Nf : create time-frequncy maps of cross-correlation binning Nf frequencies \n" << " InPathBAO5/6: path for input vismtx_J_iii.ppf on bao5/6 \n" << " Imin,Imax : read files for Imin<=iii<=Imax iii+=step \n" << " GainPPFFile: Input gains PPF file name \n" << " OutPPFFile: Output PPF file name \n" << " Freq1 Freq2: the two frequencies for which cross-correlations are computed [=1375 1410 MHz] \n" << " DeltaFreq: frequency band (in MHz) [=1 MHz] \n" << " DeltaIAvg: compute average power every DeltaI input vismtx files, def=10 \n" << " Note: bande_freq=[freq1,2-deltafreq , freq1,2+deltafreq] \n"<< endl; /* if (fgshort) { cout << " rdvisip4 -h for detailed instructions" << endl; return 1; } */ return 1; } //---------------------------------------------------- //---------------------------------------------------- int main(int narg, char* arg[]) { if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false); if (narg<10) return Usage(true); int offa=0; bool FgTFM=false; // true -> create time-frequency maps of cross-correlations sa_size_t TFMfbin=8; if (strcmp(arg[1],"-tfm")==0) { if (narg<12) return Usage(true); FgTFM=true; TFMfbin=atoi(arg[2]); if (TFMfbin<1) TFMfbin=8; offa=2; } string path5 = arg[offa+1]; string path6 = arg[offa+2]; int Imin,Imax,Istep=1; sscanf(arg[offa+3],"%d,%d",&Imin,&Imax); Istep=1; string gainfile=arg[offa+4]; string outfile=arg[offa+5]; // frequency range definition double deltafreq=1.; double freq1=1375.; double freq2=1410.; int nargo=narg-offa; if ((nargo>7)&&(strcmp(arg[offa+6],"-")!=0)) freq1=atof(arg[offa+6]); if ((nargo>8)&&(strcmp(arg[offa+7],"-")!=0)) freq2=atof(arg[offa+7]); if ((nargo>6)&&(strcmp(arg[offa+8],"-")!=0)) deltafreq=atof(arg[offa+8]); // time averaging interval definition, in term of visibility files int deltaIavg=10; if ((nargo>9)&&(strcmp(arg[offa+9],"-")!=0)) deltaIavg=atoi(arg[offa+9]); if (deltaIavg<1) deltaIavg=1; int prtlev=1; if (nargo>10) prtlev=atoi(arg[offa+10]); cout << " visi2dtacx/Info: Path BAO5:"< "< "< JF=2792) sa_size_t JFmin21=2776,JFmax21=2808; // +/- 1 MHz autour de 1420 MHz sa_size_t JFmin21_5=2710,JFmax21_5=2874; // +/- 5 MHz autour de 1420 MHz cout << " pjHI +/-1 MHz @1420 MHz " << JFmin21<<" <=NumFreq<= "<>PPFNameTag("gains")>>gains; pin>>PPFNameTag("gn")>>gn; for (int p=0; p<8; p++) cout<<"gn["< paths; paths.push_back(path5); paths.push_back(path6); VisiP4Reader vreader(paths, Imin,Imax,Istep,true); vreader.setPrintLevel(prtlev); bool fgok=true; TMatrix< complex > vismtx; TMatrix< complex > acsum; TMatrix< complex > cxsum; double acdt[32]; // les 4*8=32 valeurs d'autocorrelation pour remplissage dans la table complex cxdt[18]; // les 3*6=18 valeurs de cross-correlations pour remplissage dans la table TimeStamp dateobs, cfdate; TimeStamp dateorg(2015,1,1,12,0,0.); // Date origine 1 jan 2015 double mttag; int cnt=0, cntnt=0, pcntnt=0; int I=0; //----- 6 TimeFrequency maps vector< TArray< complex > > vtfm; // Getting en empty row_ptr DataTableRowPtr rowp = dt.EmptyRowPtr(); //---- for the time-freqency map filling sa_size_t TFMtmidx=0; sa_size_t tfmSX, tfmSY; while (fgok) { fgok=vreader.ReadNext(vismtx, cfdate, mttag); if (fgok) { if (cnt==0) { //resizing matrices for sum of auto-correlations and sum of 6 cross-correlations acsum.SetSize(8, vismtx.NCols()); cxsum.SetSize(6, vismtx.NCols()); if (FgTFM) { //allocating time-frequency maps tfmSX=(Imax-Imin)/Istep/deltaIavg; tfmSY=vismtx.NCols()/TFMfbin; cout << " visi2dtacx/Info: allocating Time-Freqncy maps : Time->NX="<NY="< >(tfmSX, tfmSY) ); } } if (I==0) { // start filling a new DataTable row dateobs=cfdate; if (prtlev>0) cout << "visi2dtacx/Info: dateobs="< > & tfmap = vtfm[k]; tfmap /= complex((r_4)(1./(double)deltaIavg/(double)TFMfbin), 0.); potfm << PPFNameTag(tfm_names[k]) << tfmap; } } // resu.Update(); cout << resu; // Update est fait lors du print } catch (PException& exc) { cerr << " visi2dtacx.cc catched PException " << exc.Msg() << endl; rc = 77; } catch (std::exception& sex) { cerr << "\n visi2dtacx.cc std::exception :" << (string)typeid(sex).name() << "\n msg= " << sex.what() << endl; rc = 78; } catch (...) { cerr << " visi2dtacx.cc catched unknown (...) exception " << endl; rc = 79; } cout << ">>>> visi2dtacx.cc ------- END ----------- RC=" << rc << endl; return rc; }