// Utilisation de SOPHYA pour faciliter les tests ... #include "sopnamsp.h" #include "machdefs.h" /* ------------------------------------------------------------------ Programme de calcul de spectre moyenne a partir des fichiers fits d'acquisition de BAORadio - donnees brutes (non FFT) R. Ansari, C. Magneville V1 : Juillet 2008 , V2 : Avril 2009 ------------------------------------------------------------------ */ // include standard c/c++ #include #include #include #include #include "pexceptions.h" #include "tvector.h" #include "fioarr.h" #include "tarrinit.h" #include "timestamp.h" #include "fftpserver.h" #include "fftwserver.h" #include "FFTW/fftw3.h" // include sophya mesure ressource CPU/memoire ... #include "resusage.h" #include "ctimer.h" #include "timing.h" // include mini-fits lib , et structure paquet BAORadio #include "minifits.h" #include "brpaqu.h" //---- Declaration des fonctions de calcul ---- // Fonction d'analyse 1ere version, pas d'entete ds le fichier, 1 voie int ana_data_0(vector& infiles, string& outfile); // Fonction d'analyse 2eme version , 1 voie / paquet int ana_data_1(vector& infiles, string& oufile); // Fonction d'analyse 2eme version , 2 voies / paquet int ana_data_2(vector& infiles, string& oufile); //---------------------------------------------------- //---------------------------------------------------- int main(int narg, char* arg[]) { if (narg < 4) { cout << " ---Calcul spectres moyennes a partir de fits BAORadio " << endl; cout << " Usage: mfits2spec ACT OutPPF file1 [file2 file3 ...] " << endl; cout << " ACT=-0,-1,-2 ==> 0: Nancay-Juil2008, - 1,2 : 1/2 voies / paquet " << endl; cout << " OutPPF : Output PPF file name, file1,file2 ... Input FITS files " << endl; return 1; } TArrayInitiator _inia; int rc = 0; try { string act = arg[1]; string outppf = arg[2]; vector infiles; for(int i=3; i exit" << endl; cout << resu ; } catch (MiniFITSException& exc) { cerr << " mfits2spec.cc catched MiniFITSException " << exc.Msg() << endl; rc = 77; } catch (std::exception& sex) { cerr << "\n mfits2spec.cc std::exception :" << (string)typeid(sex).name() << "\n msg= " << sex.what() << endl; rc = 78; } catch (...) { cerr << " mfits2spec.cc catched unknown (...) exception " << endl; rc = 79; } cout << ">>>> mfits2spec.cc ------- FIN ----------- RC=" << rc << endl; return rc; } inline r_4 Zmod2(complex z) { return (z.real()*z.real()+z.imag()*z.imag()); } /*--Nouvelle-Fonction--*/ int ana_data_0(vector& infiles, string& outfile) { TVector spectre; sa_size_t nzm = 0; // Nb de spectres moyennes for(int ifile=0; ifile skipping " << endl; } size_t sx = mff.NAxis1(); size_t sy = mff.NAxis2(); Byte* data = new Byte[sx]; TVector vx(sx); TVector< complex > cfour; FFTPackServer ffts; for(int j=0; j& infiles, string& outfile) { TVector spectre; float freq0 = 0; int paqsz = 0; int nfileok; sa_size_t nzm = 0; // Nb de spectres moyennes Byte* data = NULL; FFTPackServer ffts; for(int ifile=0; ifile skipping " << endl; continue; } // Les fichier FITS contiennent l'entet (24 bytes), mais pas le trailer (16 bytes) ... if (paqsz == 0) { // premier passage, on fixe la taille de paquet et on alloue le buffer paqsz = mff.NAxis1()+16; data = new Byte[paqsz]; for(int ib=0; ib skipping " << endl; continue; } } size_t sx = mff.NAxis1(); size_t sy = mff.NAxis2(); BRPaquet paq(NULL, data, paqsz); TVector vx(paq.DataSize()); TVector< complex > cfour; for(int j=0; j& infiles, string& outfile) { TVector specV1, specV2; TVector< complex > cxspecV12; float freq0v1 = 0; float freq0v2 = 0; int paqsz = 0; int nfileok; sa_size_t nzm = 0; // Nb de spectres moyennes Byte* data = NULL; FFTPackServer ffts; for(int ifile=0; ifile skipping " << endl; continue; } // Les fichier FITS contiennent l'entet (24 bytes), mais pas le trailer (16 bytes) ... if (paqsz == 0) { // premier passage, on fixe la taille de paquet et on alloue le buffer paqsz = mff.NAxis1()+16; cout << " ana_data_2/ Allocating data , PaqSz=" << paqsz << endl; data = new Byte[paqsz]; for(int ib=0; ib skipping " << endl; continue; } } size_t sx = mff.NAxis1(); size_t sy = mff.NAxis2(); BRPaquet paq(NULL, data, paqsz); TVector vx1(paq.DataSize()/2); TVector vx2(paq.DataSize()/2); TVector< complex > cfour1,cfour2; for(int j=0; j((r_4)(nzm),0.); specV1.Info().Comment() = " SpectreMoyenne (Moyenne module^2) - Voie 1 (/2)"; specV2.Info().Comment() = " SpectreMoyenne (Moyenne module^2) - Voie 2 (/2)"; specV1.Info()["NMOY"] = specV2.Info()["NMOY"] = nzm; // Nombre de spectres moyennes specV1.Info()["Freq0"] = freq0v1; specV2.Info()["Freq0"] = freq0v2; POutPersist po(outfile); po << PPFNameTag("specV1") << specV1; po << PPFNameTag("specV2") << specV2; po << PPFNameTag("cxspecV12") << cxspecV12; return 0; }