Commit 2bb7419e authored by Reza  ANSARI's avatar Reza ANSARI
Browse files

Optimisation de la classe VisiP4WindowReader, avec correction gain/phase, Reza 28/01/2018

parent 3acbd9f5
......@@ -9,24 +9,25 @@
/* --Methode-- */
VisiP4WindowReader::VisiP4WindowReader(vector<string> const& vpath, size_t wsz)
: wsz_(wsz) , p4vreaderp_(NULL), vtu_(wsz),
p4gnu_(NULL), p4gvf_(NULL), p4phc_(NULL),
fgown_p4gnu_(false), fgown_p4gvf_(false), fgown_p4phc_(false)
: wsz_(wsz) , p4vreaderp_(NULL), vtu_(wsz),
p4gnu_(NULL), p4gvf_(NULL), p4phc_(NULL),
fgown_p4gnu_(false), fgown_p4gvf_(false), fgown_p4phc_(false), fggpcor_(wsz)
{
cout << " VisiP4WindowReader - Creating Reader with window size= " << wsz_ << endl;
BaseArray::SetDefaultMemoryMapping(BaseArray::CMemoryMapping);
for(size_t ii=0; ii<wsz_; ii++) fggpcor_[ii]=false; cntfgcor_=0;
p4vreaderp_ = VisiP4ReaderBase::getReader(vpath);
}
/* --Methode-- */
VisiP4WindowReader::VisiP4WindowReader(P4AnaParams & params)
: wsz_(params.inwsz_) , p4vreaderp_(NULL), vtu_(params.inwsz_),
p4gnu_(NULL), p4gvf_(NULL), p4phc_(NULL),
fgown_p4gnu_(false), fgown_p4gvf_(false), fgown_p4phc_(false)
: wsz_(params.inwsz_) , p4vreaderp_(NULL), vtu_(params.inwsz_),
p4gnu_(NULL), p4gvf_(NULL), p4phc_(NULL),
fgown_p4gnu_(false), fgown_p4gvf_(false), fgown_p4phc_(false), fggpcor_(params.inwsz_)
{
cout << " VisiP4WindowReader(P4AnaParams & params) - Creating Reader with window size= " << wsz_ << endl;
BaseArray::SetDefaultMemoryMapping(BaseArray::CMemoryMapping);
for(size_t ii=0; ii<wsz_; ii++) fggpcor_[ii]=false; cntfgcor_=0;
vector<string> paths;
paths.push_back(params.inpath5_);
paths.push_back(params.inpath6_);
......@@ -105,6 +106,7 @@ void VisiP4WindowReader::setPhaseCorrector(P4PhaseCor& phc)
/* --Methode-- */
bool VisiP4WindowReader::Shift()
{
for(size_t ii=0; ii<wsz_; ii++) fggpcor_[ii]=false; cntfgcor_=0;
size_t k0 = 0;
TimeStamp dateobs;
double mttag;
......@@ -134,22 +136,26 @@ TMatrix< complex<r_4> > VisiP4WindowReader::getVisMtx(size_t k, bool fgcor)
if (k >= wsz_) throw RangeCheckError("VisiP4WindowReader::getVisMtx(k) k >= WindowSize");
TMatrix< complex<r_4> > vismtx = visarr_(Range::all(), Range::all(), Range((sa_size_t)k));
if (!fgcor || (!p4gnu_ && !p4gvf_ && !p4phc_)) return vismtx;
TMatrix< complex<r_4> > rvmx(vismtx, false); // copy the visibility matrix to avoid changing the array
if (p4gnu_) p4gnu_->applyGain(rvmx);
if (p4gvf_) p4gvf_->applyGain(rvmx,vtu_[k]);
if (p4phc_) p4phc_->applyPhase(rvmx);
return rvmx;
if (fggpcor_[k]) return vismtx;
if (p4gnu_) p4gnu_->applyGain(vismtx);
if (p4gvf_) p4gvf_->applyGain(vismtx,vtu_[k]);
if (p4phc_) p4phc_->applyPhase(vismtx);
fggpcor_[k]=true; cntfgcor_++;
return vismtx;
}
/* --Methode-- */
TMatrix< complex<r_4> > VisiP4WindowReader::getAverageVisMtx(TimeStamp& tu, bool fgcor)
{
if ((cntfgcor_ > 0) && (cntfgcor_ != wsz_))
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.);
TMatrix< complex<r_4> > rvmx(avar);
tu = getAverageTimeTU();
if (!fgcor) return rvmx;
if (cntfgcor_ == wsz_) return rvmx;
if (p4gnu_) p4gnu_->applyGain(rvmx);
if (p4gvf_) p4gvf_->applyGain(rvmx, tu);
if (p4phc_) p4phc_->applyPhase(rvmx);
......
......@@ -90,7 +90,8 @@ protected:
P4gvCor * p4gvf_;
P4PhaseCor * p4phc_;
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