Commit cf642bc6 authored by Jean-Eric Campagne's avatar Jean-Eric Campagne
Browse files

(JEC/RZ) 4/7/16 introduce the possibility to read the mean FFT coef. matrix (offsets)

parent ca3d4f36
......@@ -3,15 +3,20 @@
R. Ansari, J.E. Campagne, C. Magneville - Feb 2015
-------------------------------------------------------------------
List of files:
- makefile
- visip4reader.h .cc a class to read sequentially the visibility files
produced by mfac, merge the different frequency bands and set of visibilities
and reorder frequencies
Updated July 2016: added the possibility to read the mean FFT coeff matrix computed
during visibility computation
- rdvisip4.cc : a simple main program to read visibilitiy files and produce a single
mean visibility matrix
Updated April 2015: computes also a frequency dependent gain gain(nu) using a gain
function developed by Christophe (cmv) for cluster data analysis
Updated July 2016: use -m option to read the mean FFT coef matrix
- visi2ntac.cc : a simple main program to read visibilitiy files and produce a NTuple
with total power as a function of time for the 8 PAON4 auto-correlations
Updated April 2015: reads the gain g(nu) file produced by rdvisip4.cc , corrects the
......
......@@ -55,7 +55,8 @@ 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 InPathBAO5 InPathBAO6 Imin,Imax,step OutPPFFile GainPPFFile [PrintLev=1] \n"
cout << " Usage: rdvisip4 [-m] InPathBAO5 InPathBAO6 Imin,Imax,step OutPPFFile GainPPFFile [PrintLev=1] \n"
<< " -m: read also the mean Fourier coeff matrix \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"
......@@ -75,18 +76,26 @@ int main(int narg, char* arg[])
{
if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false);
if (narg<6) return Usage(true);
string path5 = arg[1];
string path6 = arg[2];
if ((narg>1)&&(strcmp(arg[1],"-m")==0) && (narg<7)) return Usage(false);
int off = 0;
bool fgrdmean = false;
if (strcmp(arg[1],"-m")==0 ){ fgrdmean = true; off++; }
string path5 = arg[1+off];
string path6 = arg[2+off];
int Imin,Imax,Istep;
sscanf(arg[3],"%d,%d,%d",&Imin,&Imax,&Istep);
string outfile=arg[4];
string gainfile=arg[5];
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) prtlev=atoi(arg[6]);
if (narg>6+off) prtlev=atoi(arg[6+off]);
cout << " rdvisip4/Info: Path BAO5:"<<path5<<" BAO6:"<<path6<<"\n"
<< " Imin,max,step="<<Imin<<","<<Imax<<","<<Istep<<" OutFile:"<<outfile
<< " PrtLev="<<prtlev<<endl;
<< " PrtLev="<<prtlev
<<endl;
if(fgrdmean) cout << "Trying to read also the FFT mean coef matrix" <<endl;
HiStatsInitiator _inia;
// TArrayInitiator _inia;
......@@ -104,16 +113,24 @@ int main(int narg, char* arg[])
VisiP4Reader vreader(paths, Imin,Imax,Istep,true);
vreader.setPrintLevel(prtlev);
bool fgok=true;
TMatrix< complex<r_4> > vismtx;
TMatrix< complex<r_4> > vismtx_mean;
TMatrix< complex<r_4> > vismtx, meanmtx; //vismtx: visib matrice, meanmtx: mean FFT coef
TMatrix< complex<r_4> > vismtx_mean, meanmtx_mean;
TimeStamp dateobs;
double mttag;
int cnt=0;
while (fgok) {
fgok=vreader.ReadNext(vismtx, dateobs, mttag);
if(fgrdmean) {
fgok=vreader.ReadNext(vismtx, meanmtx, dateobs, mttag);
} 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;
}
cnt++;
if (cnt%nmod==0) cout<<"rdvisip4/Info file read count="<<cnt<<" / nfiles="<<nfiles<<endl;
}
......@@ -126,6 +143,12 @@ int main(int narg, char* arg[])
cout<<" rdvisip4/Info: Saving vismtx_mean to PPF file "<<outfile<<endl;
POutPersist po(outfile);
po<<vismtx_mean;
if(fgrdmean){
meanmtx_mean /= complex<r_4>((r_4)cnt, (r_4)0.);
cout<<" rdvisip4/Info: Saving meanmtx_mean to PPF file "<<outfile<<endl;
po<<meanmtx_mean;
}
}
// resu.Update();
cout << resu; // Update est fait lors du print
......
......@@ -10,6 +10,7 @@ VisiP4Reader::VisiP4Reader(vector<string> const& vpath, int ifirst, int ilast, i
: paths(vpath), first(ifirst), last(ilast), step(istep), fgreorderfreq(reorderfreq),
curfilenum(ifirst)
{
setNChan();
setNVis();
setNFreq();
setNBands(paths.size());
......@@ -36,7 +37,8 @@ VisiP4Reader::VisiP4Reader(vector<string> const& vpath, int ifirst, int ilast, i
}
/* --Methode-- */
bool VisiP4Reader::ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs, double& mttag)
bool VisiP4Reader::ReadNext_P(TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
TimeStamp& dateobs, double& mttag)
{
if (paths.size() != NBAND) {
cout << " VisiP4Reader::ReadNext / ERROR: paths.size() != NBAND ..."<<endl;
......@@ -47,16 +49,31 @@ bool VisiP4Reader::ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs
return false;
}
if (prtlevel>0) cout << "---- VisiP4Reader::ReadNext() - curfilenum= "<<curfilenum<<" (LastNum="<<last<<")"<<endl;
bool fgwithmean = false;
if(meanmtx) fgwithmean = true;
if (prtlevel>0) {
cout << "---- VisiP4Reader::ReadNext() - curfilenum= "<<curfilenum<<" (LastNum="<<last<<")"
<< (fgwithmean ? " Read also mean coef ":" ") <<endl;
}
vector<double> vmtt;
vismtx.ReSize(NVIS, NFREQ);
TMatrix< complex<r_4> > svismtx;
TMatrix< complex<r_4> > * vmtxp=&vismtx;
vismtx->ReSize(NVIS, NFREQ);
if(fgwithmean) meanmtx->ReSize(NCHAN, NFREQ);
TMatrix< complex<r_4> > svismtx, smeanmtx;
TMatrix< complex<r_4> > * vmtxp = vismtx;
TMatrix< complex<r_4> > * mmtxp = meanmtx;
if (fgreorderfreq) { // s'il faut reordonner les frequences, on a besoin d'une matrice tampon
svismtx.ReSize(NVIS, NFREQ);
vmtxp=&svismtx;
vmtxp = &svismtx;
if(fgwithmean){
smeanmtx.ReSize(NCHAN, NFREQ);
mmtxp = &smeanmtx;
}
}
TMatrix< complex<r_4> > & myvismtx = (*vmtxp);
char filenamebuff[2048];
......@@ -75,14 +92,21 @@ bool VisiP4Reader::ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs
<<" freqRange="<<cvf<<"-"<<cvl;
{
PInPersist pin(filenamebuff);
TMatrix< complex<r_4> > vmtx;
pin>>vmtx;
TMatrix< complex<r_4> > vmtx, mmtx;
if(fgwithmean && (g == 0) ) {
pin>>vmtx >> mmtx;
} else {
pin>>vmtx;
}
string sdate=vmtx.Info()["DATEOBS"];
dateobs=TimeStamp(sdate);
if (prtlevel>1) cout << " DateObs="<<dateobs<<endl;
if (prtlevel>2) cout << " ... vmtx: "<<vmtx.InfoString()<<endl;
if (prtlevel>3) cout << " ... vmtx.Info(): \n"<<vmtx.Info()<<endl;
myvismtx.SubMatrix(Range(rvf,rvl), Range(cvf, cvl)) = vmtx;
if(fgwithmean && (g == 0)) { //remplir la matrice des moyennes des coeff FFT
mmtxp->SubMatrix(Range::all(), Range(cvf, cvl)) = mmtx;
}
mttag=vmtx.Info()["MeanTT"]; mttag/=(125.e3);
vmtt.push_back(mttag);
}
......@@ -93,7 +117,11 @@ bool VisiP4Reader::ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs
for(size_t i=0; i<vmtt.size(); i++) cout << vmtt[i] << " ";
cout<<endl;
}
if (fgreorderfreq) ReorderFreqs(myvismtx, vismtx);
if (fgreorderfreq){
ReorderFreqs(myvismtx, *vismtx);
if(fgwithmean) ReorderFreqs(*mmtxp, *meanmtx);
}
curfilenum++;
return true;
}
......@@ -123,3 +151,4 @@ void VisiP4Reader::ReorderFreqs(TMatrix< complex<r_4> > & svismtx, TMatrix< comp
return;
}
......@@ -20,12 +20,26 @@ using namespace SOPHYA;
class VisiP4Reader {
public:
VisiP4Reader(vector<string> const& vpath, int ifirst, int ilast, int istep=1, bool reorderfreq=true);
bool ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs, double& mttag);
bool ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs, double& mttag)
{
return ReadNext_P(&vismtx, NULL, dateobs, mttag);
}
bool ReadNext(TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & meanmtx,
TimeStamp& dateobs, double& mttag)
{
return ReadNext_P(&vismtx, &meanmtx, dateobs, mttag);
}
void ReorderFreqs(TMatrix< complex<r_4> > & svismtx, TMatrix< complex<r_4> > & vismtx);
inline void setNChan(sa_size_t nchan=8)
{ NCHAN=nchan; }
inline void setNVis(sa_size_t nvis=36)
{ NVIS=nvis; }
inline void setNFreq(sa_size_t nfreq=4096)
{ NFREQ=nfreq; }
inline void setNBands(int nband=2)
......@@ -48,11 +62,17 @@ public:
{ return prtlevel; }
protected:
bool ReadNext_P(TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
TimeStamp& dateobs, double& mttag);
vector<string> paths; // path for visibility files produced for each BAO5,BAO6 (first,second frequency band)
int first, last, step; // visibility files with first<=I<=last are read , with step
bool fgreorderfreq;
int curfilenum; // current file number
sa_size_t NCHAN; // nombre total de voies
sa_size_t NVIS; // nombre total de visibilites
sa_size_t NFREQ; // nombre total de frequence
int NBAND; // nombre de bande de frequence (= nb de machines de calcul)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment