[2316] | 1 | //#define TOISEQBUFFERED
|
---|
| 2 |
|
---|
| 3 | #include <unistd.h>
|
---|
| 4 | #include "toi.h"
|
---|
| 5 | #include "cgt.h"
|
---|
| 6 | #include "toiprocessor.h"
|
---|
| 7 | #include "fitstoirdr.h"
|
---|
| 8 | #include "fitsringwtr.h"
|
---|
| 9 | #include "toimanager.h"
|
---|
| 10 | #ifdef TOISEQBUFFERED
|
---|
| 11 | #include "toiseqbuff.h"
|
---|
| 12 | #else
|
---|
| 13 | #include "toisegment.h"
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "sambainit.h"
|
---|
| 17 | #include "toi2ring.h"
|
---|
| 18 | #include "timing.h"
|
---|
| 19 |
|
---|
| 20 | #include <stdexcept>
|
---|
| 21 |
|
---|
| 22 | void usage(void);
|
---|
| 23 | void usage(void) {
|
---|
[2329] | 24 | cout<<"tsttoi2ring fitsin_phase fitsin_value fitsout_value fitsout_weight ";
|
---|
| 25 | cout<<" Nsamples SN_begin SN_last (all -f SN_last<SN_begin)"<<endl;
|
---|
[2316] | 26 | return;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | ////////////////////////////////////////////////////////////////
|
---|
| 30 | int main(int narg, char** arg) {
|
---|
| 31 |
|
---|
| 32 | TOIManager* mgr = TOIManager::getManager();
|
---|
| 33 |
|
---|
| 34 | //-- Decodage arguments
|
---|
[2319] | 35 | bool fgsegmented = true;
|
---|
[2316] | 36 | int wsize = 512;
|
---|
[2319] | 37 | char *label_phase = "PHASE", *label_bolomuv = "BOLOMUVC_26";
|
---|
| 38 | char *label_theta = "THETA", *label_phi = "PHI";
|
---|
[2316] | 39 | bool snimplicit = false;
|
---|
| 40 |
|
---|
[2329] | 41 | if(narg != 8) {usage(); exit(2);}
|
---|
[2316] | 42 | char * fitsin_phase = arg[1];
|
---|
| 43 | char * fitsin_value = arg[2];
|
---|
| 44 | char * fitsout_value = arg[3];
|
---|
| 45 | char * fitsout_weight = arg[4];
|
---|
| 46 | int Nsamples = atoi(arg[5]);
|
---|
[2329] | 47 | int_8 sdeb = atoi(arg[6]);
|
---|
| 48 | int_8 sfin = atoi(arg[7]);
|
---|
| 49 | cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
|
---|
| 50 |
|
---|
[2316] | 51 |
|
---|
| 52 | cout<<">>>> tsttoi2ring:"<<endl
|
---|
| 53 | <<"Fits OutFile "<<fitsout_value<<endl
|
---|
| 54 | <<"Fits WOutFile "<<fitsout_weight<<endl;
|
---|
| 55 | cout<<"Fits Infile Value "<<fitsin_value<<endl
|
---|
| 56 | <<" ...label_bolomuv "<<label_bolomuv<<endl;
|
---|
| 57 | cout<<"Fits Infile Pointing "<<fitsin_phase<<endl
|
---|
| 58 | <<" ...label_phase "<<label_phase<<endl;
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | SophyaInit();
|
---|
| 62 | InitTim();
|
---|
| 63 |
|
---|
| 64 | //--------------------------------------------------------------------
|
---|
| 65 | try {
|
---|
| 66 | //--------------------------------------------------------------------
|
---|
| 67 |
|
---|
| 68 | CGT plombier(fgsegmented,wsize);
|
---|
| 69 | plombier.SetDebugLevel(99);
|
---|
| 70 |
|
---|
| 71 | // FITS reader et writer
|
---|
| 72 | FITSTOIReader rfitsp(fitsin_phase);
|
---|
| 73 | if(snimplicit) rfitsp.setImplicitSN();
|
---|
[2329] | 74 | if(sfin>=sdeb) rfitsp.setRequestedSample(sdeb,sfin);
|
---|
| 75 |
|
---|
[2316] | 76 | FITSTOIReader rfitsv(fitsin_value);
|
---|
| 77 | if(snimplicit) rfitsv.setImplicitSN();
|
---|
| 78 | cout << "fits reader created"<<endl;
|
---|
| 79 |
|
---|
| 80 | FITSRingWriter wfits(fitsout_value);
|
---|
| 81 | FITSRingWriter wwfits(fitsout_weight);
|
---|
| 82 | cout << "setAperture" << endl;
|
---|
| 83 | wfits.setAperture(85.);
|
---|
| 84 | wwfits.setAperture(85.);
|
---|
| 85 | cout << "setNSamples" << endl;
|
---|
| 86 | wfits.setNSamples(Nsamples);
|
---|
| 87 | wwfits.setNSamples(Nsamples);
|
---|
[2329] | 88 | wfits.setNRings(1);
|
---|
| 89 | wwfits.setNRings(1);
|
---|
| 90 |
|
---|
[2316] | 91 |
|
---|
[2329] | 92 |
|
---|
[2316] | 93 | cout << "fits writer created"<<endl;
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | // TOI Processor
|
---|
| 97 | Toi2RING m2ring(Nsamples);
|
---|
| 98 | cout<<"Toi2RING created"<<endl;
|
---|
| 99 |
|
---|
[2329] | 100 | if(sfin>=sdeb) m2ring.setRequestedSample(sdeb,sfin);
|
---|
| 101 |
|
---|
[2316] | 102 | // Definition des tuyaux
|
---|
| 103 | cout << label_phase <<endl;
|
---|
| 104 |
|
---|
[2319] | 105 | plombier.Connect(rfitsp,label_theta,m2ring,"Theta");
|
---|
| 106 | plombier.Connect(rfitsp,label_phi,m2ring,"Phi");
|
---|
[2316] | 107 | plombier.Connect(rfitsp,label_phase,m2ring,"Phase");
|
---|
| 108 | plombier.Connect(rfitsv,label_bolomuv,m2ring,"Value");
|
---|
| 109 | cout<<"file out "<<fitsout_value<< endl;
|
---|
[2319] | 110 |
|
---|
| 111 | plombier.Connect(m2ring,"CircTheta",wfits,"CircTheta");
|
---|
| 112 | plombier.Connect(m2ring,"CircPhi",wfits,"CircPhi");
|
---|
[2316] | 113 | plombier.Connect(m2ring,"Rvalue",wfits,"signal");
|
---|
[2319] | 114 |
|
---|
| 115 | // plombier.Connect(m2ring,"CircTheta",wwfits,"CircTheta");
|
---|
| 116 | // plombier.Connect(m2ring,"CircPhi",wwfits,"CircPhi");
|
---|
| 117 | // plombier.Connect(m2ring,"WRvalue",wwfits,"signal");
|
---|
[2316] | 118 |
|
---|
| 119 |
|
---|
| 120 | // Run
|
---|
| 121 | cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
|
---|
| 122 |
|
---|
| 123 | plombier.Start();
|
---|
| 124 | plombier.ListTOIs(cout, 1);
|
---|
| 125 | cout << "Joining ..." << endl;
|
---|
| 126 |
|
---|
| 127 | mgr->joinAll();
|
---|
| 128 | PrtTim("End threads");
|
---|
| 129 |
|
---|
| 130 | //--------------------------------------------------------------------
|
---|
| 131 | } catch (PThrowable & exc) {
|
---|
| 132 | cout<<"\ntsttoi2ring: Catched Exception \n"<<(string)typeid(exc).name()
|
---|
| 133 | <<" - Msg= "<<exc.Msg()<<endl;
|
---|
| 134 | } catch (const std::exception & sex) {
|
---|
| 135 | cout<<"\ntsttoi2ring: Catched std::exception \n"
|
---|
| 136 | <<(string)typeid(sex).name()<<endl;
|
---|
| 137 | } catch (...) {
|
---|
| 138 | cout<<"\ntsttoi2ring: some other exception was caught ! "<<endl;
|
---|
| 139 | }
|
---|
| 140 | //--------------------------------------------------------------------
|
---|
| 141 |
|
---|
| 142 | exit(0);
|
---|
| 143 | }
|
---|