Commit 4b5e7550 authored by Réza Ansari's avatar Réza Ansari
Browse files

Ajout methodes VisiP4ReaderBase::Read(long sernum...) en plus de ReadNext(),...

Ajout methodes VisiP4ReaderBase::Read(long sernum...) en plus de ReadNext(), pour pouvoir lire une matrice de visibilites specifiee par son numero de sequence, Reza 18/09/2017
parent 5636ca33
//----------------------------------------------------------------
// Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2015
// Classe(s) de lecture des fichiers de visibilites PAON4
//----------------------------------------------------------------
/* ----------------------------------------------------------
Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2017
Classes de lecture des fichiers de visibilites PAON4
R. Ansari 2015-2017
---------------------------------------------------------- */
#include <stdio.h>
#include <unistd.h>
......@@ -98,23 +100,24 @@ void VisiP4ReaderBase::SelectTimeFrame(TimeStamp const & tustart, TimeStamp cons
}
/* --Methode-- */
bool VisiP4ReaderBase::ReadNext_P(TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
bool VisiP4ReaderBase::Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
TimeStamp& dateobs, double& mttag)
{
if (paths_.size() != NBAND) {
cout << " VisiP4ReaderBase::ReadNext / ERROR: paths_.size() != NBAND ..."<<endl;
cout << " VisiP4ReaderBase::Read_P() / ERROR: paths_.size() != NBAND ..."<<endl;
return false;
}
if (cur_serialnum_ > ser_last_) {
cout << "VisiP4ReaderBase::ReadNext() passed last VisibMatrix to be read, cur_serialnum_="<<cur_serialnum_<< " last="<<ser_last_<<endl;
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;
}
bool fgwithmean = false;
if(meanmtx) fgwithmean = true;
if ( (prtlevel>1)||((prtlevel>0)&&(cur_serialnum_%20==0)) ) {
cout << "---- VisiP4ReaderBase::ReadNext() - cur_serialnum_= "<<cur_serialnum_<<" (LastNum="<<ser_last_<<")"
if ( (prtlevel>1)||((prtlevel>0)&&(sernum%20==0)) ) {
cout << "---- VisiP4ReaderBase::Read_P() - sernum= "<<sernum<<" (LastNum="<<ser_last_<<")"
<< (fgwithmean ? " Read also mean coef ":" ") <<endl;
}
......@@ -148,12 +151,12 @@ bool VisiP4ReaderBase::ReadNext_P(TMatrix< complex<r_4> >* vismtx, TMatrix< comp
//DBG cout << " *DBG* row range:"<<rvf<<","<<rvl<<endl;
if (prtlevel>2)
cout << " VisiP4ReaderBase::ReadNext() - Readding VisMtx with SerialNum= "<<cur_serialnum_
cout << " VisiP4ReaderBase::Read_P()() - Readding VisMtx with SerialNum= "<<sernum
<<" freqRange="<<cvf<<"-"<<cvl;
{
TMatrix< complex<r_4> > vmtx, mmtx;
TMatrix< complex<r_4> > * pmmtx=(fgwithmean && (g == 0) )?&mmtx:NULL;
ReadVisMtx(b,g,cur_serialnum_,vmtx,pmmtx);
ReadVisMtx(b,g,sernum,vmtx,pmmtx);
int npaq = vmtx.Info()["NPAQSUM"];
string sdate=vmtx.Info()["DATEOBS"];
......@@ -183,7 +186,6 @@ bool VisiP4ReaderBase::ReadNext_P(TMatrix< complex<r_4> >* vismtx, TMatrix< comp
if(fgwithmean) ReorderFreqs(*mmtxp, *meanmtx);
}
cur_serialnum_+=ser_step_;
return true;
}
......@@ -304,7 +306,7 @@ void VisiP4ReaderDB::SelectSerialNum(int first, int last, int step)
if ((ser_last_>=vdb_[k].ser_start)&&(ser_last_<vdb_[k].ser_end))
last_filenum_ = vdb_[k].filenum;
}
OpenFiles(cur_vdb_index_);
fgopenok_=false;
return;
}
......@@ -328,6 +330,7 @@ void VisiP4ReaderDB::Init()
cur_filenum_ = 0;
cur_vdb_index_ = 0;
for(size_t b=0; b<paths_.size(); b++) cur_filep_.push_back(NULL);
fgopenok_=false;
char filenamebuff[2048];
sprintf(filenamebuff,"%s/vmtxdbdesc.txt",paths_[0].c_str());
......@@ -377,8 +380,10 @@ void VisiP4ReaderDB::ReadVisMtx(int band, int visgrp, long sernum, TMatrix< comp
}
}
}
OpenFiles(cur_vdb_index_);
fgopenok_ = false;
}
if (!fgopenok_) OpenFiles(cur_vdb_index_);
char tagbuff[128];
sprintf(tagbuff,"vismtx_%d_%ld",visgrp,sernum);
(*cur_filep_[band]) >> PPFNameTag(tagbuff) >> vmtx;
......@@ -404,5 +409,6 @@ void VisiP4ReaderDB::OpenFiles(size_t vdbidx)
cur_filep_[b] = new PInPersist(filenamebuff);
}
cur_vdb_index_ = vdbidx;
fgopenok_=true;
return;
}
/* ----------------------------------------------------------
Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2017
Classes de lecture des fichiers de visibilites PAON4
R. Ansari 2015-2017
---------------------------------------------------------- */
#ifndef VISIP4READER_H_SEEN
#define VISIP4READER_H_SEEN
//----------------------------------------------------------------
// Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2017
// Classe(s) de lecture des fichiers de visibilites PAON4
//----------------------------------------------------------------
#include <string>
#include <vector>
......@@ -43,18 +45,46 @@ public:
inline void setFreqReordering(bool fg)
{ fgreorderfreq_ = fg; }
/*! \brief Read the next visibility matrix in the selected visi matrix number range.
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)
{
return ReadNext_P(&vismtx, NULL, dateobs, mttag);
bool readok = Read_P(cur_serialnum_, &vismtx, NULL, dateobs, mttag);
if (readok) cur_serialnum_+=ser_step_;
return readok;
}
/*! \brief Read the next visibility matrix and mean Fourier coeff matrix in the selected visi matrix number range.
fills also the corresponding TimeStamp (TU) and mean hardware time-tag. return true if OK, false otherwise. */
bool ReadNext(TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & meanmtx,
TimeStamp& dateobs, double& mttag)
{
return ReadNext_P(&vismtx, &meanmtx, dateobs, mttag);
bool readok = Read_P(cur_serialnum_, &vismtx, &meanmtx, dateobs, mttag);
if (readok) cur_serialnum_+=ser_step_;
return readok;
}
/*! \brief Read the visibility 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.
\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, dateobs, mttag);
}
/*! \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.
\warning : sernum should be in the selected range */
bool Read(long sernum, TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & meanmtx,
TimeStamp& dateobs, double& mttag)
{
return Read_P(sernum, &vismtx, &meanmtx, dateobs, mttag);
}
//! perform the reordering of the different frequency components (for FFT firmware of the ADC board)
void ReorderFreqs(TMatrix< complex<r_4> > & svismtx, TMatrix< complex<r_4> > & vismtx);
//! Correcting for offset due to non zero mean fourier coeff matrix from visibilities
TMatrix< complex<r_4> > SubtractOffset(TMatrix< complex<r_4> > & vismtx, TMatrix< complex<r_4> > & meanmtx);
......@@ -87,8 +117,8 @@ public:
protected:
bool ReadNext_P(TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
TimeStamp& dateobs, double& mttag);
bool Read_P(long sernum, TMatrix< complex<r_4> >* vismtx, TMatrix< complex<r_4> >* meanmtx,
TimeStamp& dateobs, double& mttag);
virtual void ReadVisMtx(int band, int visgrp, long sernum, TMatrix< complex<r_4> > & vmtx, TMatrix< complex<r_4> > * mmtx) = 0;
......@@ -148,6 +178,7 @@ protected:
int cur_filenum_;
size_t cur_vdb_index_;
std::vector<PInPersist *> cur_filep_;
bool fgopenok_;
};
// For compatibility for old code
......
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