Commit adbf224d authored by OP's avatar OP
Browse files

add a counter of read items + corr bug dans reader

parent 47dbe520
......@@ -180,6 +180,7 @@ int main(int narg, const char* arg[])
//reads next visibility matrix window
fgok = wreader.Shift();
cout << " read "<< wreader.getNbReads()<<" ok "<< fgok<<":"<<endl;
if (!fgok) break;
for (size_t k=0 ; k<wreader.getWindowSize() ; k++){
......
......@@ -168,9 +168,9 @@ int main(int narg, const char* arg[])
// recupere le jour de depart @ 0h
datestart = TimeStamp(cfdate.DaysPart(),0.);
cout << "vis2ra/Info: alloc done cnt=" <<cnt<<endl;
}
dateobs=cfdate;
double racourant = P4Coords::RAFromTimeTU(dateobs);
sa_size_t idxra = ram.getMapIndex(racourant);
......@@ -209,7 +209,8 @@ int main(int narg, const char* arg[])
// ... done
cnt++;
if ( (cnt>0) && (cnt%50==0) ) {
if ( (cnt>0) && (cnt%100==0) ) {
cout << " vis2ra/Info: RA-map fill, VisMtxCount= "<<cnt<<endl;
// cout << " vis2ra/Info: RA-map fill, VisMtxCount="<<cnt<< " /Max="<<Imax<<" DateObs="<<dateobs<<endl;
}
} // Fin de la boucle de lecture
......
......@@ -176,36 +176,44 @@ bool VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMat
TMatrix< complex<r_4> > vmtx, mmtx, fcxmtx;
TMatrix< complex<r_4> > * pmmtx=(fgwithmean && (g == 0) )?&mmtx:NULL;
TMatrix< complex<r_4> > * pfcxmtx=(fgwithfreqcx && (g == 0) )?&fcxmtx:NULL;
ReadVisMtx(b,g,sernum,vmtx,pmmtx,pfcxmtx);
int npaq = vmtx.Info()["NPAQSUM"];
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;
// Dividing by the number of paquets used to compute the visibility.
complex<r_4> zfacnorm((r_4)npaq, 0.);
vmtx /= zfacnorm;
myvismtx.SubMatrix(Range(rvf,rvl), Range(cvf, cvl)) = vmtx;
if ((g==0)&&(b==0)) myvismtx.Info() = vmtx.Info();
char nmpaqsum[48];
sprintf(nmpaqsum,"NPAQSUM_%d_%d",b,g);
myvismtx.Info()[nmpaqsum] = npaq;
if(fgwithmean && (g == 0)) { //remplir la matrice des moyennes des coeff FFT
mmtx /= zfacnorm;
mmtxp->SubMatrix(Range::all(), Range(cvf, cvl)) = mmtx;
mmtxp->Info() = mmtx.Info();
}
if(fgwithfreqcx && (g == 0)) { //remplir la matrice des moyennes des coeff FFT
fcxmtx /= zfacnorm;
fcxmtxp->SubMatrix(Range::all(), Range(cvf, cvl)) = fcxmtx;
npaq = mmtx.Info()["NPAQSUM"];
fcxmtxp->Info() = fcxmtx.Info();
try{
ReadVisMtx(b,g,sernum,vmtx,pmmtx,pfcxmtx);
int npaq = vmtx.Info()["NPAQSUM"];
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;
// Dividing by the number of paquets used to compute the visibility.
complex<r_4> zfacnorm((r_4)npaq, 0.);
vmtx /= zfacnorm;
myvismtx.SubMatrix(Range(rvf,rvl), Range(cvf, cvl)) = vmtx;
if ((g==0)&&(b==0)) myvismtx.Info() = vmtx.Info();
char nmpaqsum[48];
sprintf(nmpaqsum,"NPAQSUM_%d_%d",b,g);
myvismtx.Info()[nmpaqsum] = npaq;
if(fgwithmean && (g == 0)) { //remplir la matrice des moyennes des coeff FFT
mmtx /= zfacnorm;
mmtxp->SubMatrix(Range::all(), Range(cvf, cvl)) = mmtx;
mmtxp->Info() = mmtx.Info();
}
if(fgwithfreqcx && (g == 0)) { //remplir la matrice des moyennes des coeff FFT
fcxmtx /= zfacnorm;
fcxmtxp->SubMatrix(Range::all(), Range(cvf, cvl)) = fcxmtx;
npaq = mmtx.Info()["NPAQSUM"];
fcxmtxp->Info() = fcxmtx.Info();
}
mttag=vmtx.Info()["MeanTT"]; mttag/=(125.e3);
vmtt.push_back(mttag);
}
mttag=vmtx.Info()["MeanTT"]; mttag/=(125.e3);
vmtt.push_back(mttag);
catch (PException& exc) {
cerr << " visip4reader.cc catched PException " << exc.Msg() << endl;
cout << " visip4reader.cc catched PException " << exc.Msg() << endl;
return false;
}
}
} // end-of-loop over visibility groups
} // end-of-loop over bands
......@@ -221,7 +229,7 @@ bool VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMat
}
return true;
return true ;
}
/* --Methode-- */
......@@ -294,6 +302,7 @@ void VisiP4ReaderNoDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< co
sprintf(filenamebuff,"%s/vismtx_%d_%ld.ppf",paths_[band].c_str(), visgrp, sernum);
if (prtlevel>3)
cout << " VisiP4ReaderNoDB::ReadVisMtx() - opening file: "<<filenamebuff<<endl;
PInPersist pin(filenamebuff);
if( pmmtx && fxmtx ) {
pin>>vmtx >> (*pmmtx) >> (*fxmtx);
......@@ -307,6 +316,8 @@ void VisiP4ReaderNoDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< co
else {
pin>>vmtx;
}
return;
}
......
......@@ -78,7 +78,7 @@ VisiP4WindowReader::~VisiP4WindowReader()
/* --Methode-- */
size_t VisiP4WindowReader::getTotalNbWindows()
{
return ((size_t)((p4vreaderp_->getSerialLast()-p4vreaderp_->getSerialFirst())/(p4vreaderp_->getSerialStep()*wsz_)));
return ((size_t)((p4vreaderp_->getSerialLast()-p4vreaderp_->getSerialFirst()+1)/(p4vreaderp_->getSerialStep()*wsz_)));
}
/* --Methode-- */
......@@ -110,9 +110,12 @@ bool VisiP4WindowReader::Shift()
size_t k0 = 0;
TimeStamp dateobs;
double mttag;
nbreads_ = 0;
if (! visarr_.IsAllocated() ) { // this is the first time shift is called
TMatrix< complex<r_4> > vismtx;
if (! (getReader().ReadNext(vismtx, dateobs, mttag)) ) return false;
if (! (getReader().ReadNext(vismtx, dateobs, mttag)) ) {
return false;
}
sa_size_t siz[BASEARRAY_MAXNDIMS]={0,0,0,0,0};
siz[0]=vismtx.SizeX();
siz[1]=vismtx.SizeY();
......@@ -121,12 +124,16 @@ bool VisiP4WindowReader::Shift()
visarr_(Range::all(), Range::all(), Range(0)) = vismtx;
vtu_[0]=dateobs;
k0=1;
nbreads_ ++;
}
for(size_t k=k0; k<wsz_; k++) {
for(size_t k=k0; k<wsz_; k++) {
TMatrix< complex<r_4> > vismtx = visarr_(Range::all(), Range::all(), Range((sa_size_t)k));
if (! (getReader().ReadNext(vismtx, dateobs, mttag)) ) return false;
if ( (getReader().ReadNext(vismtx, dateobs, mttag)) ) nbreads_ ++;
vtu_[k]=dateobs;
}
if (nbreads_ == 0 ) return false;
return true;
}
......@@ -151,7 +158,7 @@ TMatrix< complex<r_4> > VisiP4WindowReader::getAverageVisMtx(TimeStamp& tu, bool
throw ParmError("VisiP4WindowReader::getAverageVisMtx() some of the VisiMatrices have been gain/phase corrected, but NOT ALL!");
TArray< complex<r_4> > avar(visarr_.SizeX(), visarr_.SizeY());
for(size_t k=0; k<wsz_; k++) avar += visarr_(Range::all(), Range::all(), Range((sa_size_t)k));
avar /= complex<r_4>((float)wsz_, 0.);
avar /= complex<r_4>((float)nbreads_, 0.);
TMatrix< complex<r_4> > rvmx(avar);
tu = getAverageTimeTU();
if (!fgcor) return rvmx;
......
......@@ -79,12 +79,13 @@ public:
inline TimeStamp getTimeTU(size_t k) { return vtu_[k]; }
//! Return the average TU time of the window
TimeStamp getAverageTimeTU();
inline size_t getNbReads(){return nbreads_ ;}
protected:
size_t wsz_;
VisiP4ReaderBase * p4vreaderp_;
TArray< complex<r_4> > visarr_;
vector<TimeStamp> vtu_;
size_t nbreads_ ; // nombre de lectures ok
//---- corrections de gains et de phase
P4gnuGain * p4gnu_;
P4gvCor * p4gvf_;
......@@ -92,6 +93,7 @@ protected:
bool fgown_p4gnu_, fgown_p4gvf_, fgown_p4phc_; // true->the corresponding pointer is owned by the VisiP4WindowReader object
vector<bool> fggpcor_; // flag indicating if gain/phase correction have (true-> correction applied)
size_t cntfgcor_; // count of true in fggpcor_
};
......
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