/* ---------------------------------------------------------- Projet BAORadio/PAON4 - (C) LAL/IRFU 2008-2017 Classes et fonctions utilitaires pour les programmes d'analyse PAON4 R. Ansari Fevrier 2017 ---------------------------------------------------------- */ #include #include #include "p4autils.h" P4AnaParams::P4AnaParams() : inpath5_("bao5/"), inpath6_("bao6/"), Imin_(0), Imax_(10), Istep_(1), fgreorderfreq_(false), gain_gnu_file_("gain.ppf"), outfile_("p4a.ppf"), Nmean_(10), prtlev_(0), fgTFM_(false), TFMtimebin_(30), TFMfreqbin_(4), fgdtable_(false) { } P4AnaParams::P4AnaParams(P4AnaParams const & a) : inpath5_(a.inpath5_), inpath6_(a.inpath6_), Imin_(a.Imin_), Imax_(a.Imax_), Istep_(a.Istep_), fgreorderfreq_(a.fgreorderfreq_), gain_gnu_file_(a.gain_gnu_file_), outfile_(a.outfile_), Nmean_(a.Nmean_), prtlev_(a.prtlev_), fgTFM_(a.fgTFM_), TFMtimebin_(a.TFMtimebin_), TFMfreqbin_(a.TFMfreqbin_), fgdtable_(a.fgdtable_), fbands_(a.fbands_), lastargs_(a.lastargs_) { } P4AnaParams& P4AnaParams::operator = (P4AnaParams const & a) { inpath5_=a.inpath5_; inpath6_=a.inpath6_; Imin_=a.Imin_; Imax_=a.Imax_; Istep_=a.Istep_; fgreorderfreq_=a.fgreorderfreq_; gain_gnu_file_=a.gain_gnu_file_; outfile_=a.outfile_; Nmean_=a.Nmean_; prtlev_=a.prtlev_; fgTFM_=a.fgTFM_; TFMfreqbin_=a.TFMfreqbin_; TFMtimebin_=a.TFMtimebin_; fgdtable_=a.fgdtable_; fbands_=a.fbands_; lastargs_=a.lastargs_; return *this; } int P4AnaParams::DecodeArgs(int narg, const char* arg[]) { // decodage arguments optionnel while (narg>1) { string fbo = arg[1]; if (fbo=="-inrange") { // specification numeros de fichiers de visi a traiter if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } sscanf(arg[2],"%d,%d,%d",&Imin_,&Imax_,&Istep_); arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-in5") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } inpath5_=arg[2]; arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-in6") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } inpath6_=arg[2]; arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-gnu") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } gain_gnu_file_=arg[2]; arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-nmean") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } Nmean_=atoi(arg[2]); arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-reorderfreq") { fgreorderfreq_=true; arg++; narg--; lastargs_.clear(); } else if (fbo=="-o") { 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=="-tfm") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } int ja,jb; sscanf(arg[2],"%d,%d",&ja,&jb); TFMtimebin_=ja; TFMfreqbin_=jb; fgTFM_=true; arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-freq") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } double f0,df; sscanf(arg[2],"%lg,%lg",&f0,&df); fbands_.push_back(P4FreqBand(f0,df)); fgdtable_=true; arg+=2; narg-=2; lastargs_.clear(); } else if (fbo=="-prt") { if (narg<2) { cout << "P4AnaParams::DecodeArgs missing/bad argument, -h for help " << endl; return -1; } prtlev_=atoi(arg[2]); arg+=2; narg-=2; lastargs_.clear(); } else { arg++; narg--; lastargs_.push_back(fbo); } } // les arguments qui restent a la fin de la ligne de commande sont dans lastargs_ return 0; } int P4AnaParams::UsageOptions() { cout<< " P4AnaParams::UsageOptions(): -inrange -in5 -in6 -gnu -o -nmean -tfm -freq -prt \n" << " [-inrange Imin,Imax[,Istep] ] [-in5 InputPath_BAO5] [-in6 InputPath_BAO6] \n" << " [-o outfilename] [-gnu gain_filename] [-nmean N] [-reorderfreq] \n" << " [-tfm timebin,freqbin] [-freq f0,df] [-prt level] \n" << " -inrange Imin,Imax[,Istep] define range of visibilite matrices to be processed (Imin<=I<=Imax with step Istep) \n" << " -in5/6 InputPath_BAO5/6 : input file path for BAO5 and BAO6 \n" << " -o outfilename : specify output file 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" << " -tfm timebin,freqbin : time-frequency maps, averaging timebin=nb of visi matrices, freqbin frequency components \n" << " -freq f0,df : definition of a frequency band centered on f0, with total width df (in MHz) \n" << " several frequency bands can be specified by mutiple -freq options \n" << " -prt level: define print level \n" << endl; return 0; } ostream& P4AnaParams::Print(ostream& os) const { os<<" In5 path="<