// Utilisation de SOPHYA pour faciliter les tests ... #include "sopnamsp.h" #include "machdefs.h" /* ---------------------------------------------------------- Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2015 Programme de lecture des fichiers matrices de visibilites de PAON4 produits mfacq R. Ansari, J.E. Campagne, C. Magneville - LAL/Irfu V0 : Fev 2015 ---------------------------------------------------------- */ // 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" // ---- compute gain for each channel from visibilies and save it to file void computeSaveGain(TMatrix< complex > & vismtx_mean, string const & gainfile); // ----- adaptation de la fonction de calcul de gain, ecrit par cmv pour l'analyse Amas (Aout 2013) Matrix computeGain2(Matrix & acs, int SZW=96,float frackeep=0.75); // ----- fonction pour normaliser les gains Vector normalizeGain2(Matrix& gain); //--------------------------- Fonctions de ce fichier ------------------- int Usage(bool fgshort=true); // int DecodeArgs(int narg, char* arg[]); /* --Fonction-- */ int Usage(bool fgea) { cout << " --- rdvisip4.cc : Read PPF files produced by mfacq time-frequency\n" << endl; if (fgea) cout << " rdvisip4: Missing or wrong argument ! " << endl; cout << " Usage: rdvisip4 [-mr] InPathBAO5 InPathBAO6 Imin,Imax,step OutPPFFile GainPPFFile [PrintLev=1] \n" << " -m: read also the mean Fourier coeff matrix \n" << " -r: reorder frequence (for FFT firmeware) \n" << " -mr: do both \n" << " InPathBAO5/6: path for input vismtx_J_iii.ppf on bao5/6 \n" << " Imin,Imax,step : read files for Imin<=iii<=Imax iii+=step \n" << " OutPPFFile: Output PPF file name (with the average visibility matrix) \n" << " GainPPFFile: PPF file name containing the computed gain g(nu) \n"<1)&&(strcmp(arg[1],"-h")==0)) return Usage(false); if (narg<6) return Usage(true); if ((narg>1)&&((strcmp(arg[1],"-m")==0)||(strcmp(arg[1],"-r")==0)||(strcmp(arg[1],"-mr")==0)) && (narg<7)) return Usage(false); int off = 0; bool fgrdmean = false; bool fgreorderfreq = false; if (strcmp(arg[1],"-m")==0 ){ fgrdmean = true; off++; } else if (strcmp(arg[1],"-r")==0 ){ fgreorderfreq = true; off++; } else if (strcmp(arg[1],"-mr")==0 ){ fgrdmean = fgreorderfreq = true; off++; } string path5 = arg[1+off]; string path6 = arg[2+off]; int Imin=0,Imax=10,Istep=1; sscanf(arg[3+off],"%d,%d,%d",&Imin,&Imax,&Istep); string outfile=arg[4+off]; string gainfile=arg[5+off]; int prtlev=1; if (narg>6+off) prtlev=atoi(arg[6+off]); cout << " rdvisip4/Info: Path BAO5:"< paths; paths.push_back(path5); paths.push_back(path6); int nfiles=(Imax-Imin+1)/Istep; int nmod=nfiles/20; if (nmod<1) nmod=1; VisiP4Reader vreader(paths, Imin,Imax,Istep,fgreorderfreq); vreader.setPrintLevel(prtlev); bool fgok=true; //vismtx: visib matrice, meanmtx: mean FFT coef, vismtx_center: visib matrix corrigee de l'offset (normalisee avec NPAQSUM) TMatrix< complex > vismtx, meanmtx, vismtx_center; TMatrix< complex > vismtx_mean, meanmtx_mean, vismtx_center_mean; TimeStamp dateobs; double mttag; int cnt=0; while (fgok) { if(fgrdmean) { fgok=vreader.ReadNext(vismtx, meanmtx, dateobs, mttag); vismtx_center = vreader.SubtractOffset(vismtx, meanmtx); } else { fgok=vreader.ReadNext(vismtx, dateobs, mttag); } if (fgok) { if (cnt==0) vismtx_mean=vismtx; else vismtx_mean+=vismtx; if(fgrdmean) { if (cnt==0) meanmtx_mean = meanmtx; else meanmtx_mean += meanmtx; if (cnt==0) vismtx_center_mean = vismtx_center; else vismtx_center_mean += vismtx_center; } cnt++; if (cnt%nmod==0) cout<<"rdvisip4/Info file read count="<0) { vismtx_mean /= complex((r_4)cnt, (r_4)0.); cout << " rdvisip4/Info: computing gains ..."<((r_4)cnt, (r_4)0.); cout<<" rdvisip4/Info: Saving meanmtx_mean to PPF file "<((r_4)cnt, (r_4)0.); cout<<" rdvisip4/Info: Saving vismtx_center_mean to PPF file "<>>> rdvisip4.cc ------- END ----------- RC=" << rc << endl; return rc; } //--------------------- Fonctions pour le calcul de gain ----------------------- //----- include specifique pour computeGain2() #include "nbtrixx.h" #include "cspline.h" /*--Fonction--*/ void computeSaveGain(TMatrix< complex > & vismtx_mean, string const & gainfile) { sa_size_t KVAC[8]={0,8,15,21,26,30,33,35}; Matrix acs(8, vismtx_mean.NCols()); for(sa_size_t r=0; r<8; r++) for(sa_size_t c=0; c DVon(ncols); DVon = 0.; for(int c=1; c vsplx, vsply; for(int c=0; c