Commit 7767859b authored by OP's avatar OP
Browse files

try to set up a fits output

parent e803cef8
......@@ -179,7 +179,7 @@ P4AnaParams::P4AnaParams()
: inpath5_("bao5/"), inpath6_("bao6/"), Imin_(0), Imax_(10), Istep_(1),
fgserall_(false), fgtmsel_(false),
fgreorderfreq_(false), gain_gnu_file_("gain.ppf"),
fitsoutfile_("p4a.fits"),outfile_("p4a.ppf"), Nmean_(10), prtlev_(0), prtmodulo_(1),
fitsoutfile_(""),outfile_("p4a.ppf"), Nmean_(10), prtlev_(0), prtmodulo_(1),
fgTFM_(false), TFMtimebin_(30), TFMfreqbin_(4), fgdtable_(false)
{
......@@ -248,6 +248,10 @@ int P4AnaParams::DecodeArgs(int narg, const char* arg[])
if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; }
outfile_=arg[2]; arg+=2; narg-=2; lastargs_.clear();
}
else if (fbo=="-fo") {
if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; }
fitsoutfile_=arg[2]; arg+=2; narg-=2; lastargs_.clear();
}
else if (fbo=="-tfm") {
if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; }
int ja,jb;
......@@ -284,6 +288,7 @@ int P4AnaParams::UsageOptions()
<< " -inseltm date_timeTU duration : define set of visibility matrices to be processed as time interval \n"
<< " centered at date_timeTU (YYYY-MM-DDThh:mm:ss) and duration in minutes \n"
<< " -o outfilename : specify output file name \n"
<< " -fo outfilename : specify output fits name \n"
<< " -gnu gain_filename: gain g(nu) file name \n"
<< " -nmean N: compute average (and sigma...) using N visibility matrices \n"
<< " -reorderfreq: activate frequency reordering in VisiP4Reader, suitable for FFT firmware \n"
......
......@@ -66,10 +66,10 @@ int main(int narg, const char* arg[])
string outfile = params.outfile_;
if (outfile.length()<1) outfile = "visavg.ppf";
//string fitsoutfile = params.fitsoutfile_;
//if (fitsoutfile.length()>=1) {
// fitsoutfile = "!"+fitsoutfile ; // adds '!' ?
//}
string fitsoutfile = params.fitsoutfile_;
if (fitsoutfile.length()>=1) {
fitsoutfile = "!"+fitsoutfile ; // adds '!' ?
}
int deltaIavg = params.TFMtimebin_;
sa_size_t TFMfbin = params.TFMfreqbin_;
int Imin = params.Imin_, Imax = params.Imax_, Istep = params.Istep_;
......@@ -142,6 +142,8 @@ int main(int narg, const char* arg[])
<<Imin<<" <= seq <= " << Imax << " with step="<<Istep<<endl;
bool fgok=true;
// vecteur de noms
vector <string> ext_names;
// un vecteur avec les temps
TVector< double > timevec((Imax-Imin)/Istep/deltaIavg);
TVector< double > ravec((Imax-Imin)/Istep/deltaIavg);
......@@ -289,13 +291,22 @@ int main(int narg, const char* arg[])
cout<<"visiavg/Info: count="<<cnt<<" visimtx read "<<endl;
// --- Sauvegarde cartes temps-frequence en fits
//if (fitsoutfile.length()>=1){
//cout << " fitsoutfile" <<fitsoutfile<< endl;
// FitsInOutFile fos(fitsoutfile, FitsInOutFile::Fits_Create);
//}
// DataTable dt;
//FitsABTWriter * fbtw = NULL;
FitsInOutFile * fos = NULL ;
if (fitsoutfile.length()>=1){
//cout<<">>>>> Creating a new fits file with FitsABTWriter"<<endl;
//fbtw = new FitsABTWriter(fitsoutfile,BINARY_TBL,3);
//fbtw->SetExtName("Test fits table 1");
//i1 = fbtw.AddCol("Time",NULL,"unit1",TDOUBLE);
cout << " fitsoutfile" <<fitsoutfile<< endl;
fos = new FitsInOutFile(fitsoutfile, FitsInOutFile::Fits_Create);
}
POutPersist potfm(outfile);
char bufnam[10];
int numkey =0;
// --- renormalizing and saving AutoCorr time-frequency maps
cout<<" visiavg/Info: Saving 8 AutoCorr time-frequency maps to PPF file "<<outfile<<endl;
const char* tfm_names[8]={"TFM_1H", "TFM_2H", "TFM_3H", "TFM_4H", "TFM_1V", "TFM_2V", "TFM_3V", "TFM_4V"};
......@@ -308,6 +319,12 @@ int main(int narg, const char* arg[])
tfmapsq = tfmapsq - tfmap.MulElt(tfmap,tfmap) ;
potfm << PPFNameTag(tfm_names[k]) << tfmap;
potfm << PPFNameTag(tfmsq_names[k]) << tfmapsq;
if (fos != NULL) {
ext_names.push_back(tfm_names[k]);
(*fos)<< tfmap;
ext_names.push_back(tfmsq_names[k]);
(*fos)<< tfmap;
}
}
// --- renormalizing and saving H-H Cross-Corr time-frequency maps
......@@ -335,6 +352,16 @@ int main(int narg, const char* arg[])
potfm << PPFNameTag(tfmCC_names[k]) << tfmap;
potfm << PPFNameTag(vrtfmCC_names[k]) << tfmap_sqpr;
potfm << PPFNameTag(vitfmCC_names[k]) << tfmap_sqpi;
if (fos != NULL) {
ext_names.push_back(string(tfmCC_names[k])+"_real");
(*fos)<< real(tfmap);
ext_names.push_back(string(tfmCC_names[k])+"_imag");
(*fos)<< imag(tfmap);
ext_names.push_back(vrtfmCC_names[k]);
(*fos)<< tfmap_sqpr;
ext_names.push_back(vitfmCC_names[k]);
(*fos)<< tfmap_sqpi;
}
}
potfm << PPFNameTag("TimeVec") << timevec ;
......@@ -348,10 +375,21 @@ int main(int narg, const char* arg[])
for (int kf=0 ; kf< myp4fre.getP4NbFreqChannels()/TFMfbin ; kf++,frbase +=myp4fre.getP4FreqResolution() )
avg_freqs(kf) = frbase ;
potfm << PPFNameTag("FreqVec") << avg_freqs;
if (fos != NULL) {
ext_names.push_back("Frequences");
(*fos)<< avg_freqs ;
ext_names.push_back("RAs");
(*fos)<< ravec;
ext_names.push_back("Times");
(*fos)<< timevec;
cout << " number of objs in fits "<< ext_names.size() << endl;
cout << ext_names << endl;
delete(fos);
}
cout << resu; // Update est fait lors du print
}
catch (PException& exc) {
cerr << " visiavg.cc catched PException " << exc.Msg() << endl;
......
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