Commit 4982a23a authored by Reza Ansari's avatar Reza Ansari
Browse files

Ajout methode application des gain a une matrice d'AutoCorrelation (pour...

Ajout methode application des gain a une matrice d'AutoCorrelation (pour CrossFreq matrix) et ajout option utilisation de gain ds rdvisip4.cc , Reza 17/10/2017
parent dc528623
......@@ -86,6 +86,17 @@ P4gnuGain::P4gnuGain(string const & gainfilename, double gthr)
return;
}
void P4gnuGain::applyGainAutoCor(SOPHYA::TMatrix< complex<r_4> > & acvismtx)
{
std::vector<sa_size_t> kvac = P4AVisiNumEncoder::getAllAutoCor();
if (((sa_size_t)kvac.size() != acvismtx.NRows()) || vmtxgains_.NCols() != acvismtx.NCols())
throw SzMismatchError("P4gnuGain::applyGainAutoCor() - WRONG acvismtx.NRows() / NCols() ");
for(size_t i=0; i<kvac.size(); i++) {
acvismtx.Row((sa_size_t)i).Mul(vmtxgains_.Row(kvac[i]));
}
}
// ----- adaptation de la fonction de calcul de gain, ecrit par cmv pour l'analyse Amas (Aout 2013)
/* --- fonction de calcul de gain avec fit de spline qui flag tout seul
les mauvais points du spectre - calcule la moyenne par fenetre (en
......
......@@ -35,6 +35,9 @@ public:
inline void applyGain(SOPHYA::TMatrix< complex<r_4> > & vismtx)
{ vismtx.Mul(vmtxgains_); }
//! apply the gain correction factor to the submatrix corresponding to the AutoCorrelation part (useful for CrossFrequency Visib matrix)
void applyGainAutoCor(SOPHYA::TMatrix< complex<r_4> > & acvismtx);
//! return the multiplicative gain_ matrix, g(ia, nu) with 0 <= ia < 8 , for the 8 auto-correlation signals
inline SOPHYA::Matrix const & getGainMatrix() const { return gains_; }
......
......@@ -44,7 +44,7 @@
int Usage(void)
{
cout<<"--- rdvisip4.cc : Read PPF files produced by mfacq time-frequency\n"<<endl;
cout<<"Usage: rdvisip4 [-options] [meanfft] [cxfreq] \n";
cout<<"Usage: rdvisip4 [-options] [usegain] [meanfft] [cxfreq] \n";
cout<<" meanfft : try to read mean FFT coeff and subtract it from visib. \n";
cout<<" cxfreq : try to read cross-frequency correlation matrix and compute mean of it \n";
cout<<" WARNING: Only one of the two options (meanfft , cxfreq) can be specified \n";
......@@ -70,9 +70,11 @@ int main(int narg, const char* arg[])
bool fgreorderfreq = params.fgreorderfreq_;
bool fgrdmean = false;
bool fgrdcxfreq = false;
bool fgusegain = false;
for (size_t i=0; i<params.lastargs_.size(); i++) {
if ( params.lastargs_[i]==string("meanfft") ) fgrdmean = true;
if ( params.lastargs_[i]==string("cxfreq") ) fgrdcxfreq = true;
if ( params.lastargs_[i]==string("usegain") ) fgusegain = true;
}
params.Print(cout);
cout<<"rdvisip4/Info: Path BAO5:"<<path5<<" BAO6:"<<path6<<"\n"
......@@ -81,7 +83,9 @@ int main(int narg, const char* arg[])
<<"PrtLev="<<prtlev<<" OutFile:"<<outfile<<endl;
if(fgrdmean) cout<<"Trying to read also the FFT mean coef matrix"<<endl;
if(fgrdcxfreq) cout<<"Trying to read also the Cross-Frequency correlation "<<endl;
if(fgusegain) cout<<" Using gain correction file: "<< params.gain_gnu_file_ << endl;
else cout<<" Gains will be computed and saved to file: "<< params.gain_gnu_file_ << endl;
P4AVisiNumEncoder vencod;
cout << vencod;
// ---
......@@ -89,6 +93,11 @@ int main(int narg, const char* arg[])
int rc = 0;
try {
ResourceUsage resu;
// Gain correction class
P4gnuGain *p4gp;
if (fgusegain) p4gp = new P4gnuGain(params.gain_gnu_file_);
vector<string> paths;
paths.push_back(path5);
paths.push_back(path6);
......@@ -127,13 +136,22 @@ int main(int narg, const char* arg[])
while (fgok) {
if (fgrdcxfreq) {
fgok=vreader.ReadNextCxFreq(vismtx, cxfreqmtx, dateobs, mttag);
if (fgusegain) {
p4gp->applyGain(vismtx);
p4gp->applyGainAutoCor(cxfreqmtx);
}
}
else if (fgrdmean) {
fgok=vreader.ReadNextMFFT(vismtx, meanmtx, dateobs, mttag);
vismtx_center = vreader.SubtractOffset(vismtx, meanmtx);
if (fgusegain) {
p4gp->applyGain(vismtx);
p4gp->applyGain(vismtx_center);
}
}
else {
fgok=vreader.ReadNext(vismtx, dateobs, mttag);
if (fgusegain) p4gp->applyGain(vismtx);
}
if (fgok) {
if (cnt==0) vismtx_mean=vismtx;
......@@ -155,8 +173,10 @@ int main(int narg, const char* arg[])
cout<<"rdvisip4/Info: count="<<cnt<<" visimtx read "<<endl;
if (cnt>0) {
vismtx_mean /= complex<r_4>((r_4)cnt, (r_4)0.);
cout<<" rdvisip4/Info: computing gains ..."<<endl;
P4gnuGain::computeSaveGain(vismtx_mean, gainfile);
if (!fgusegain) {
cout<<" rdvisip4/Info: computing gains ..."<<endl;
P4gnuGain::computeSaveGain(vismtx_mean, gainfile);
}
cout<<" rdvisip4/Info: Saving vismtx_mean to PPF file "<<outfile<<endl;
POutPersist po(outfile);
po<<PPFNameTag("visimean")<<vismtx_mean;
......
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