Commit eab06fcd authored by Reza Ansari's avatar Reza Ansari
Browse files

Implementation calcul et sauvegarde des cartes temps-frequence des 8 AutoCorr. Reza 22/09/2017

parent df014160
......@@ -44,7 +44,8 @@
int Usage(void)
{
cout<<"--- rdvisip4.cc : Read PPF files produced by mfacq time-frequency\n"<<endl;
cout<<"Usage: visi2dtacx [-arguments] [-m]\n";
cout<<"Usage: rdvisip4 [-arguments] [-meanfft]\n";
cout<<" -meanfft : try to read mean FFT coeff and subtract it from visib. \n";
P4AnaParams::UsageOptions();
cout<<endl;
return 1;
......
......@@ -45,8 +45,11 @@ int Usage(void);
int Usage(void)
{
cout << " --- visi2dtacx.cc : Read PPF files produced by mfacq time-frequency\n" << endl;
cout << " Usage: visi2dtacx [-arguments] [OutPPFFile]\n"
<< " OutPPFFile: Output PPF file name\n";
cout << " Usage: visi2dtacx [-arguments] [-tfmac OR -tfmcx OR -tfmacx]\n"
<< " -tfmac : select Time-Frequency maps of the 8 Autocorrelations (default)\n"
<< " -tfmcx : select Time-Frequency maps of the 6 H-H Cross-correlations \n"
<< " -tfmacx : select Time-Frequency maps of the 8 Autocorrelations + 6 H-H Cross-correlations \n"
<< " Note: -tfm timebin,freqbin should be specified for -tfmac / -tfmcx / -tfmacx \n"<<endl;
P4AnaParams::UsageOptions();
cout<< endl;
return 1;
......@@ -60,12 +63,20 @@ int main(int narg, const char* arg[])
P4AnaParams params;
params.DecodeArgs(narg, arg);
string outfile = params.outfile_;
if (params.lastargs_.size()>0) outfile = params.lastargs_[0];
bool FgTFM = params.fgTFM_; // true -> create time-frequency maps of cross-correlations
if (outfile.length()<1) outfile = "acx.ppf";
int deltaIavg = params.TFMtimebin_;
sa_size_t TFMfbin = params.TFMfreqbin_;
int Imin = params.Imin_, Imax = params.Imax_, Istep = params.Istep_;
int prtlev = params.prtlev_;
bool FgTFMAC = false;
bool FgTFMCX = false;
string desctfmap;
bool FgTFM = params.fgTFM_; // true -> create time-frequency maps
if ((params.lastargs_.size()>0)&&FgTFM) {
if (params.lastargs_[0] == "-tfmcx") { FgTFMAC = false; FgTFMCX = true; desctfmap="CxH"; }
else if (params.lastargs_[0] == "-tfmacx") { FgTFMAC = true; FgTFMCX = true; desctfmap="Ac+CxH"; }
else { FgTFMAC = true; desctfmap="Ac"; }
}
params.Print(cout);
cout <<"visi2dtacx/Info: Path BAO5:"<<params.inpath5_<<" BAO6:"<<params.inpath6_<<"\n"
......@@ -79,7 +90,7 @@ int main(int narg, const char* arg[])
size_t l = outfile.length();
size_t pp = outfile.rfind('.');
if (pp<l) TFMoutfile = outfile.substr(0,pp) + "_tfm.ppf";
cout <<" visi2dtacx/Info: Time-Frequency maps of Xcor will be created and saved to file "<<TFMoutfile<<endl;
cout <<" visi2dtacx/Info: Time-Frequency maps ("<<desctfmap<<") will be created and saved to file "<<TFMoutfile<<endl;
}
// --- Calcul des index de bandes de frequences
......@@ -178,7 +189,9 @@ int main(int narg, const char* arg[])
}
vreader.setPrintLevel(prtlev);
Imin = vreader.getSerialFirst(); Imax = vreader.getSerialLast(); Istep = vreader.getSerialStep();
Imin = vreader.getSerialFirst(); Imax = vreader.getSerialLast(); Istep = vreader.getSerialStep();
cout << "visi2dtacx/Info: processing visibility matrix serial/sequence number range "
<<Imin<<" <= seq <= " << Imax << " with step="<<Istep<<endl;
bool fgok=true;
TMatrix< complex<r_4> > vismtx;
......@@ -192,8 +205,10 @@ int main(int narg, const char* arg[])
double mttag;
int cnt=0, cntnt=0, pcntnt=0;
int I=0;
//----- 6 TimeFrequency maps
//----- 6 H-H cross-cor TimeFrequency maps
vector< TArray< complex<r_4> > > vtfm;
//----- 8 auto-corr TimeFrequency maps
vector< TArray< r_4 > > vtfmac;
// Getting en empty row_ptr
DataTableRowPtr rowp = dt.EmptyRowPtr();
......@@ -208,10 +223,16 @@ int main(int narg, const char* arg[])
if (cnt==0) { //resizing matrices for sum of auto-correlations and sum of 6 cross-correlations
acsum.SetSize(8, vismtx.NCols());
cxsum.SetSize(6, vismtx.NCols());
if (FgTFM) { //allocating time-frequency maps
if (FgTFM) { // time-frequency maps size
tfmSX=(Imax-Imin)/Istep/deltaIavg;
tfmSY=vismtx.NCols()/TFMfbin;
cout<<"visi2dtacx/Info: allocating Time-Frequency maps : Time->NX="<<tfmSX<<" x Freq->NY="<<tfmSY<<endl;
}
if (FgTFMAC) { //allocating 8 Auto-Corr time-frequency maps
cout<<"visi2dtacx/Info: allocating 8 AutoCor Time-Frequency maps : Time->NX="<<tfmSX<<" x Freq->NY="<<tfmSY<<endl;
for(int k=0; k<8; k++) vtfmac.push_back( TArray< r_4 >(tfmSX, tfmSY) );
}
if (FgTFMCX) { //allocating 6 Cross-Corr H-H time-frequency maps
cout<<"visi2dtacx/Info: allocating H-H cross-cor Time-Frequency maps : Time->NX="<<tfmSX<<" x Freq->NY="<<tfmSY<<endl;
for(int k=0; k<6; k++) vtfm.push_back( TArray< complex<r_4> >(tfmSX, tfmSY) );
}
}
......@@ -239,8 +260,15 @@ int main(int narg, const char* arg[])
acdt[k] += vac(freqs).Sum(); // integration en bande 1
acdt[k+8] += vac(freqsB).Sum(); // integration en bande large B
acdt[k+16] += vac(freqs21_1).Sum(); // integration a +/- 1 MHz @ 1420 MHz
acdt[k+24] += vac(freqs21_5).Sum(); // integration a +/- 5 MHz @ 1420 MHz
}
acdt[k+24] += vac(freqs21_5).Sum(); // integration a +/- 5 MHz @ 1420 MHz
if (FgTFMAC && (TFMtmidx<tfmSX)) { //filling H-H cross-corr time-frequency maps
TArray< r_4 > & tfmap = vtfmac[k];
for(sa_size_t jy=0; jy<tfmSY; jy++) {
r_8 aa = vac( Range(jy*TFMfbin, (jy+1)*TFMfbin-1) ).Sum();
tfmap(TFMtmidx, jy) = (r_4)aa;
}
} //----- end of AutoCorr time-frequency maps filling
} //----- end of loop over the 8 AutoCor
//---- On s'occupe des cross-correlations 1H-2H ... 3H-4H
TVector< complex<r_8> > vcx(acsum.NCols());
for(int k=0; k<6; k++) { // loop over the 6 Xcor
......@@ -250,13 +278,13 @@ int main(int narg, const char* arg[])
cxdt[k+6] += vcx(freqsB).Sum(); // integration en bande large B
cxdt[k+12] += vcx(freqs21_1).Sum(); // integration a +/- 1 MHz @ 1420 MHz
if (FgTFM && (TFMtmidx<tfmSX)) { //filling time-frequency maps
if (FgTFMCX && (TFMtmidx<tfmSX)) { //filling H-H cross-corr time-frequency maps
TArray< complex<r_4> > & tfmap = vtfm[k];
for(sa_size_t jy=0; jy<tfmSY; jy++) {
complex<r_8> zz = vcx( Range(jy*TFMfbin, (jy+1)*TFMfbin-1) ).Sum();
tfmap(TFMtmidx, jy) = complex<r_4>(zz.real(), zz.imag());
}
} //----- end of time-frequency maps filling
} //----- end of Cx H-H time-frequency maps filling
} //----- end of loop over the 6 Xcor
TFMtmidx++;
......@@ -299,13 +327,24 @@ int main(int narg, const char* arg[])
POutPersist po(outfile);
po<<dt;
if (FgTFM) { // --- renormalizing and saving time-frequency maps
cout<<" visi2dtacx/Info: Saving time-frequency maps to PPF file "<<TFMoutfile<<endl;
if (FgTFMAC) { // --- renormalizing and saving AutoCorr time-frequency maps
cout<<" visi2dtacx/Info: Saving 8 AutoCorr time-frequency maps to PPF file "<<TFMoutfile<<endl;
POutPersist potfm(TFMoutfile);
const char* tfm_names[8]={"TFM_1H", "TFM_2H", "TFM_3H", "TFM_4H", "TFM_1V", "TFM_2V", "TFM_3V", "TFM_4V"};
for(int k=0; k<8; k++) { // loop over the 8 AutoCorr
TArray< r_4 > & tfmap = vtfmac[k];
tfmap *= (r_4)(1./((double)deltaIavg*(double)TFMfbin));
potfm << PPFNameTag(tfm_names[k]) << tfmap;
}
}
if (FgTFMCX) { // --- renormalizing and saving H-H Cross-Corr time-frequency maps
cout<<" visi2dtacx/Info: Saving 6 H-H cross-corr time-frequency maps to PPF file "<<TFMoutfile<<endl;
POutPersist potfm(TFMoutfile);
const char* tfm_names[6]={"TFM_1H2H", "TFM_1H3H", "TFM_1H4H", "TFM_2H3H", "TFM_2H4H", "TFM_3H4H"};
for(int k=0; k<6; k++) { // loop over the 6 Xcor
TArray< complex<r_4> > & tfmap = vtfm[k];
tfmap /= complex<r_4>((r_4)(1./(double)deltaIavg/(double)TFMfbin), 0.);
tfmap *= complex<r_4>((r_4)(1./((double)deltaIavg*(double)TFMfbin)), 0.);
potfm << PPFNameTag(tfm_names[k]) << tfmap;
}
}
......
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