[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 ";
|
---|
[2355] | 25 | cout<<" Nsamples SN_begin SN_last Nring (all if 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 |
|
---|
[2355] | 41 | if(narg != 9) {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]);
|
---|
[2355] | 49 | int_8 Nring = atoi(arg[8]);
|
---|
[2329] | 50 | cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
|
---|
| 51 |
|
---|
[2316] | 52 |
|
---|
| 53 | cout<<">>>> tsttoi2ring:"<<endl
|
---|
| 54 | <<"Fits OutFile "<<fitsout_value<<endl
|
---|
| 55 | <<"Fits WOutFile "<<fitsout_weight<<endl;
|
---|
| 56 | cout<<"Fits Infile Value "<<fitsin_value<<endl
|
---|
| 57 | <<" ...label_bolomuv "<<label_bolomuv<<endl;
|
---|
| 58 | cout<<"Fits Infile Pointing "<<fitsin_phase<<endl
|
---|
| 59 | <<" ...label_phase "<<label_phase<<endl;
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | SophyaInit();
|
---|
| 63 | InitTim();
|
---|
| 64 |
|
---|
| 65 | //--------------------------------------------------------------------
|
---|
| 66 | try {
|
---|
| 67 | //--------------------------------------------------------------------
|
---|
| 68 |
|
---|
| 69 | CGT plombier(fgsegmented,wsize);
|
---|
| 70 | plombier.SetDebugLevel(99);
|
---|
| 71 |
|
---|
| 72 | // FITS reader et writer
|
---|
| 73 | FITSTOIReader rfitsp(fitsin_phase);
|
---|
| 74 | if(snimplicit) rfitsp.setImplicitSN();
|
---|
[2329] | 75 | if(sfin>=sdeb) rfitsp.setRequestedSample(sdeb,sfin);
|
---|
| 76 |
|
---|
[2316] | 77 | FITSTOIReader rfitsv(fitsin_value);
|
---|
| 78 | if(snimplicit) rfitsv.setImplicitSN();
|
---|
| 79 | cout << "fits reader created"<<endl;
|
---|
| 80 |
|
---|
| 81 | FITSRingWriter wfits(fitsout_value);
|
---|
[2331] | 82 | FITSRingWriter wwfits(fitsout_weight);
|
---|
[2316] | 83 | cout << "setAperture" << endl;
|
---|
| 84 | wfits.setAperture(85.);
|
---|
[2331] | 85 | wwfits.setAperture(85.);
|
---|
[2316] | 86 | cout << "setNSamples" << endl;
|
---|
| 87 | wfits.setNSamples(Nsamples);
|
---|
[2331] | 88 | wwfits.setNSamples(Nsamples);
|
---|
[2355] | 89 | wfits.setNRings(Nring);
|
---|
| 90 | wwfits.setNRings(Nring);
|
---|
[2316] | 91 |
|
---|
[2329] | 92 |
|
---|
[2316] | 93 |
|
---|
| 94 | // TOI Processor
|
---|
| 95 | Toi2RING m2ring(Nsamples);
|
---|
| 96 | cout<<"Toi2RING created"<<endl;
|
---|
| 97 |
|
---|
[2329] | 98 | if(sfin>=sdeb) m2ring.setRequestedSample(sdeb,sfin);
|
---|
| 99 |
|
---|
[2316] | 100 | // Definition des tuyaux
|
---|
| 101 | cout << label_phase <<endl;
|
---|
| 102 |
|
---|
[2319] | 103 | plombier.Connect(rfitsp,label_theta,m2ring,"Theta");
|
---|
| 104 | plombier.Connect(rfitsp,label_phi,m2ring,"Phi");
|
---|
[2316] | 105 | plombier.Connect(rfitsp,label_phase,m2ring,"Phase");
|
---|
| 106 | plombier.Connect(rfitsv,label_bolomuv,m2ring,"Value");
|
---|
| 107 | cout<<"file out "<<fitsout_value<< endl;
|
---|
[2319] | 108 |
|
---|
| 109 | plombier.Connect(m2ring,"CircTheta",wfits,"CircTheta");
|
---|
| 110 | plombier.Connect(m2ring,"CircPhi",wfits,"CircPhi");
|
---|
[2316] | 111 | plombier.Connect(m2ring,"Rvalue",wfits,"signal");
|
---|
[2319] | 112 |
|
---|
[2331] | 113 | plombier.Connect(m2ring,"WCircTheta",wwfits,"CircTheta");
|
---|
| 114 | plombier.Connect(m2ring,"WCircPhi",wwfits,"CircPhi");
|
---|
[2355] | 115 | plombier.Connect(m2ring,"WRvalue",wwfits,"signal");
|
---|
[2316] | 116 |
|
---|
| 117 | // Run
|
---|
| 118 | cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
|
---|
| 119 |
|
---|
| 120 | plombier.Start();
|
---|
| 121 | plombier.ListTOIs(cout, 1);
|
---|
| 122 | cout << "Joining ..." << endl;
|
---|
| 123 |
|
---|
| 124 | mgr->joinAll();
|
---|
| 125 | PrtTim("End threads");
|
---|
| 126 |
|
---|
| 127 | //--------------------------------------------------------------------
|
---|
| 128 | } catch (PThrowable & exc) {
|
---|
| 129 | cout<<"\ntsttoi2ring: Catched Exception \n"<<(string)typeid(exc).name()
|
---|
| 130 | <<" - Msg= "<<exc.Msg()<<endl;
|
---|
| 131 | } catch (const std::exception & sex) {
|
---|
| 132 | cout<<"\ntsttoi2ring: Catched std::exception \n"
|
---|
| 133 | <<(string)typeid(sex).name()<<endl;
|
---|
| 134 | } catch (...) {
|
---|
| 135 | cout<<"\ntsttoi2ring: some other exception was caught ! "<<endl;
|
---|
| 136 | }
|
---|
| 137 | //--------------------------------------------------------------------
|
---|
| 138 |
|
---|
| 139 | exit(0);
|
---|
| 140 | }
|
---|