Commit 1f1438ce authored by perdereau's avatar perdereau
Browse files
parents b7fd8034 fedc4581
......@@ -122,17 +122,17 @@ void VisiP4ReaderBase::SelectAll()
}
/* --Methode-- */
bool VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
int VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
TMatrix< complex<r_4> >* freqcxmtx, TimeStamp& dateobs, double& mttag)
{
if (paths_.size() != NBAND) {
cout << " VisiP4ReaderBase::Read_P() / ERROR: paths_.size() != NBAND ..."<<endl;
return false;
return 3;
}
if ((sernum < ser_first_) || (sernum > ser_last_) ) {
cout << "VisiP4ReaderBase::Read_P() VisibMatrix number out of selected range to be sernum="<<sernum
<< " first="<<ser_first_<<" last="<<ser_last_<<endl;
return false;
return 2;
}
bool fgwithmean = false;
......@@ -174,6 +174,8 @@ bool VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMat
fcxmtxp = &sfreqcxmtx;
}
}
int rca=0;
TMatrix< complex<r_4> > & myvismtx = (*vmtxp);
// loop over the files created by each VisCalculator (each file contains a set of visibilities)
for(int b=0; b<NBAND; b++) {
......@@ -192,44 +194,46 @@ 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;
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();
try {
int rcr=ReadVisMtx(b,g,sernum,vmtx,pmmtx,pfcxmtx);
if (rcr > 0) {
if ((rcr == 1)&&(rca < 2)) rca=1; // skip case
if (rcr > rca) rca=rcr; // largest error code
}
else {
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;
cerr << " visip4reader.cc catched PException sernum="<<sernum<<" masg="<<exc.Msg()<<endl;
return 2;
}
}
} // end-of-loop over visibility groups
} // end-of-loop over bands
......@@ -244,8 +248,7 @@ bool VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMat
if(fgwithfreqcx) ReorderFreqs(*fcxmtxp, *freqcxmtx);
}
return true ;
return rca ;
}
/* --Methode-- */
......@@ -313,7 +316,7 @@ VisiP4ReaderNoDB::VisiP4ReaderNoDB(vector<string> const& vpath, int first, int l
}
/* --Methode-- */
void VisiP4ReaderNoDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * pmmtx, TMatrix< complex<r_4> > * fxmtx)
int VisiP4ReaderNoDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * pmmtx, TMatrix< complex<r_4> > * fxmtx)
{
char filenamebuff[2048];
sprintf(filenamebuff,"%s/vismtx_%d_%ld.ppf",paths_[band].c_str(), visgrp, sernum);
......@@ -334,8 +337,7 @@ void VisiP4ReaderNoDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< co
pin>>vmtx;
}
return;
return 0;
}
/* --Methode-- */
......@@ -415,18 +417,21 @@ void VisiP4ReaderDB::Init()
string line;
size_t iv, nl;
int ms1,ms2,fs;
char date1[64], date2[64], tu1[64], tu2[64];
char date1[64], date2[64], tu1[64], tu2[64], sskip[32];
while (!is.eof()) {
line = "";
getline(is, line);
if ((is.good() || is.eof()) && (line.length()>0) && (line[0]!='#')) {
sscanf(line.c_str(),"%d %d %d %s %s UT %s %s", &fs, &ms1, &ms2, date1,tu1,date2,tu2);
sskip[0]=sskip[1]=sskip[2]=sskip[3]='\0';
sscanf(line.c_str(),"%d %d %d %s %s UT %s %s UT %s", &fs, &ms1, &ms2, date1,tu1,date2,tu2, sskip);
VDBEL dbel;
dbel.filenum = fs;
dbel.ser_start = ms1;
dbel.ser_end = ms2;
dbel.tu_start = TimeStamp(date1,tu1);
dbel.tu_end = TimeStamp(date2,tu2);
dbel.fgskip = false;
if (string(sskip)=="SKIP") dbel.fgskip = true; // skip this file
vdb_.push_back(dbel);
}
}
......@@ -436,21 +441,23 @@ void VisiP4ReaderDB::Init()
db_last_filenum_ = vdb_[vdb_.size()-1].filenum;
cout << "VisiP4ReaderDB::Init(): "<<vdb_.size()<<" lines read from VisMtxDBWriter data description file"<<filenamebuff<<endl;
/*
for (size_t k=0; k<vdb_.size(); k++) {
if (k != vdb_[k].filenum) cout << " Init*DBG*ERROR/BUG k!= vdb_[k].filenum" << endl;
cout << "Init*DBG["<<k<<"] "<<vdb_[k].filenum<<" "<<vdb_[k].ser_start<<" "<<vdb_[k].ser_end<<" "
<< vdb_[k].tu_start.ToString() << " " << vdb_[k].tu_end.ToString() << endl;
// cout << "Init*DBG["<<k<<"] "<<vdb_[k].filenum<<" "<<vdb_[k].ser_start<<" "<<vdb_[k].ser_end<<" "
// << vdb_[k].tu_start.ToString() << " " << vdb_[k].tu_end.ToString() << endl;
if (vdb_[k].fgskip)
cout << " Init*SKIP["<<k<<"] "<<vdb_[k].filenum<<" "<<vdb_[k].ser_start<<" "<<vdb_[k].ser_end<<" "
<< vdb_[k].tu_start.ToString() << " " << vdb_[k].tu_end.ToString() << " will be skipped"<<endl;
}
*/
return;
}
/* --Methode-- */
void VisiP4ReaderDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtxp, TMatrix< complex<r_4> > * fxmtx)
int VisiP4ReaderDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtxp, TMatrix< complex<r_4> > * fxmtx)
{
if ((sernum < vdb_[cur_vdb_index_].ser_start)||(sernum >= vdb_[cur_vdb_index_].ser_end)) {
if ((sernum < vdb_[cur_vdb_index_+1].ser_start)||(sernum >= vdb_[cur_vdb_index_+1].ser_end)) {
if ((cur_vdb_index_+1<vdb_.size())&&
(sernum >= vdb_[cur_vdb_index_+1].ser_start)&&(sernum < vdb_[cur_vdb_index_+1].ser_end)) {
cur_vdb_index_ ++ ; cur_filenum_ = vdb_[cur_vdb_index_].filenum;
}
else {
......@@ -464,7 +471,8 @@ void VisiP4ReaderDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< comp
}
fgopenok_ = false;
}
if (!fgopenok_) OpenFiles(cur_vdb_index_);
if (!fgopenok_ && (!vdb_[cur_vdb_index_].fgskip)) OpenFiles(cur_vdb_index_);
if (vdb_[cur_vdb_index_].fgskip) return 1;
char tagbuff[128];
// -- reading the visibility matrix
......@@ -478,7 +486,7 @@ void VisiP4ReaderDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< comp
sprintf(tagbuff,"cxfreq_%d_%ld",visgrp,sernum);
(*cur_filep_[band]) >> PPFNameTag(tagbuff) >> (*fxmtx);
}
return;
return 0;
}
/* --Methode-- */
......@@ -509,18 +517,20 @@ P4VisMtxDBDescReader::P4VisMtxDBDescReader(string const & path)
string line;
size_t iv, nl;
int ms1,ms2,fs;
char date1[64], date2[64], tu1[64], tu2[64];
char date1[64], date2[64], tu1[64], tu2[64], sskip[32];
while (!is.eof()) {
line = "";
getline(is, line);
if ((is.good() || is.eof()) && (line.length()>0) && (line[0]!='#')) {
sscanf(line.c_str(),"%d %d %d %s %s UT %s %s", &fs, &ms1, &ms2, date1,tu1,date2,tu2);
sscanf(line.c_str(),"%d %d %d %s %s UT %s %s UT %s", &fs, &ms1, &ms2, date1,tu1,date2,tu2,sskip);
VDBEL2 dbel;
dbel.filenum = fs;
dbel.ser_start = ms1;
dbel.ser_end = ms2;
dbel.tu_start = TimeStamp(date1,tu1);
dbel.tu_end = TimeStamp(date2,tu2);
dbel.fgskip = false;
if (string(sskip)=="SKIP") dbel.fgskip = true; // skip this file
vdb_.push_back(dbel);
}
}
......
......@@ -60,8 +60,13 @@ public:
fills also the corresponding TimeStamp (TU) and mean hardware time-tag. return true if OK, false otherwise. */
bool ReadNext(TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs, double& mttag)
{
bool readok = Read_P(cur_serialnum_, &vismtx, NULL, NULL, dateobs, mttag);
if (readok) cur_serialnum_+=ser_step_;
int rcr=1;
bool readok=false;
while (rcr==1) {
rcr = Read_P(cur_serialnum_, &vismtx, NULL, NULL, dateobs, mttag) ;
cur_serialnum_+=ser_step_;
if (rcr==0) readok=true;
}
return readok;
}
/*! \brief Read the next visibility matrix and mean Fourier coeff matrix in the selected visi matrix number range.
......@@ -69,8 +74,13 @@ public:
bool ReadNextMFFT(TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & meanmtx,
TimeStamp& dateobs, double& mttag)
{
bool readok = Read_P(cur_serialnum_, &vismtx, &meanmtx, NULL, dateobs, mttag);
if (readok) cur_serialnum_+=ser_step_;
int rcr=1;
bool readok=false;
while (rcr==1) {
rcr = Read_P(cur_serialnum_, &vismtx, &meanmtx, NULL, dateobs, mttag);
cur_serialnum_+=ser_step_;
if (rcr==0) readok=true;
}
return readok;
}
/*! \brief Read the next visibility matrix and cross-frequency correlation matrix in the selected visi matrix number range.
......@@ -78,8 +88,13 @@ public:
bool ReadNextCxFreq(TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & freqcx,
TimeStamp& dateobs, double& mttag)
{
bool readok = Read_P(cur_serialnum_, &vismtx, NULL, &freqcx, dateobs, mttag);
if (readok) cur_serialnum_+=ser_step_;
int rcr=1;
bool readok=false;
while (rcr==1) {
rcr = Read_P(cur_serialnum_, &vismtx, NULL, &freqcx, dateobs, mttag);
cur_serialnum_+=ser_step_;
if (rcr==0) readok=true;
}
return readok;
}
......@@ -89,7 +104,8 @@ public:
\warning : sernum should be in the selected range */
bool Read(long sernum, TMatrix< complex<r_4> > & vismtx, TimeStamp& dateobs, double& mttag)
{
return Read_P(sernum, &vismtx, NULL, NULL, dateobs, mttag);
int rcr=Read_P(sernum, &vismtx, NULL, NULL, dateobs, mttag);
return (rcr==0);
}
/*! \brief Read the next visibility matrix and mean Fourier coeff matrix identified by the serial number \b sernum.
fills also the corresponding TimeStamp (TU) and mean hardware time-tag. return true if OK, false otherwise.
......@@ -98,7 +114,8 @@ public:
bool ReadMFFT(long sernum, TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & meanmtx,
TimeStamp& dateobs, double& mttag)
{
return Read_P(sernum, &vismtx, &meanmtx, NULL, dateobs, mttag);
int rcr=Read_P(sernum, &vismtx, &meanmtx, NULL, dateobs, mttag);
return (rcr==0);
}
/*! \brief Read the next visibility matrix and cross frequency correlation matrix identified by the serial number \b sernum.
fills also the corresponding TimeStamp (TU) and mean hardware time-tag. return true if OK, false otherwise.
......@@ -108,7 +125,8 @@ public:
bool ReadCxFreq(long sernum, TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & freqcx,
TimeStamp& dateobs, double& mttag)
{
return Read_P(sernum, &vismtx, NULL, &freqcx, dateobs, mttag);
int rcr=Read_P(sernum, &vismtx, NULL, &freqcx, dateobs, mttag);
return (rcr==0);
}
//! perform the reordering of the different frequency components (for FFT firmware of the ADC board)
......@@ -148,10 +166,12 @@ public:
protected:
// vismtx : matrice de visibilite , meanmtx: pointeur matrice moyenne coeff de Fourier , freqcxmtx: pointeur matrice correlation en deux freq pour les V_ii
bool Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx, TMatrix< complex<r_4> >* freqcxmtx,
// return value : 0 -> OK , 1 -> skip , >=2 Errors
int Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx, TMatrix< complex<r_4> >* freqcxmtx,
TimeStamp& dateobs, double& mttag);
// vmtx : matrice de visibilite , mmtx pointeur matrice moyenne coeff de Fourier, fxmtx : pointeur matrice correlation entre deux freq pour les V_ii
virtual void ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx,
// return value : 0 -> OK , 1 -> skip , >=2 Errors
virtual int ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx,
TMatrix< complex<r_4> > * fxmtx) = 0;
vector<string> paths_; // path for visibility files produced for each BAO5,BAO6 (first,second frequency band)
......@@ -181,8 +201,8 @@ public:
VisiP4ReaderNoDB(vector<string> const& vpath, int first, int last, int step=1, bool reorderfreq=false,
bool fgrdtherm=false, int nvisgrp=0);
protected:
virtual void ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx,
TMatrix< complex<r_4> > * fxmtx);
virtual int ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx,
TMatrix< complex<r_4> > * fxmtx);
};
//------------------------------------------------------------------------------------------------
......@@ -205,14 +225,14 @@ public:
protected:
void Init();
virtual void ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx,
TMatrix< complex<r_4> > * fxmtx);
virtual int ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx,
TMatrix< complex<r_4> > * fxmtx);
void OpenFiles(size_t vdbidx);
long db_first_ser_, db_end_ser_; // first and last Matrix sequence number in directory
int db_first_filenum_, db_last_filenum_; // first and last file number in directory
typedef struct { int filenum, ser_start, ser_end; TimeStamp tu_start, tu_end; } VDBEL;
typedef struct { int filenum, ser_start, ser_end; TimeStamp tu_start, tu_end; bool fgskip; } VDBEL;
std::vector< VDBEL > vdb_;
int first_filenum_, last_filenum_;
int cur_filenum_;
......@@ -236,7 +256,7 @@ public:
//! return the file number
int getInfo(size_t k, int & ser_start, int & ser_end, TimeStamp & tmstart, TimeStamp & tmend);
protected:
typedef struct { int filenum, ser_start, ser_end; TimeStamp tu_start, tu_end; } VDBEL2;
typedef struct { int filenum, ser_start, ser_end; TimeStamp tu_start, tu_end; bool fgskip; } VDBEL2;
std::vector< VDBEL2 > vdb_;
};
#endif
......
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