| 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) {
|
|---|
| 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;
|
|---|
| 26 | return;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | ////////////////////////////////////////////////////////////////
|
|---|
| 30 | int main(int narg, char** arg) {
|
|---|
| 31 |
|
|---|
| 32 | TOIManager* mgr = TOIManager::getManager();
|
|---|
| 33 |
|
|---|
| 34 | //-- Decodage arguments
|
|---|
| 35 | bool fgsegmented = true;
|
|---|
| 36 | int wsize = 512;
|
|---|
| 37 | char *label_phase = "PHASE", *label_bolomuv = "BOLOMUVC_26";
|
|---|
| 38 | char *label_theta = "THETA", *label_phi = "PHI";
|
|---|
| 39 | bool snimplicit = false;
|
|---|
| 40 |
|
|---|
| 41 | if(narg != 8) {usage(); exit(2);}
|
|---|
| 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]);
|
|---|
| 47 | int_8 sdeb = atoi(arg[6]);
|
|---|
| 48 | int_8 sfin = atoi(arg[7]);
|
|---|
| 49 | cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
|
|---|
| 50 |
|
|---|
| 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();
|
|---|
| 74 | if(sfin>=sdeb) rfitsp.setRequestedSample(sdeb,sfin);
|
|---|
| 75 |
|
|---|
| 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);
|
|---|
| 88 | wfits.setNRings(1);
|
|---|
| 89 | wwfits.setNRings(1);
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | cout << "fits writer created"<<endl;
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | // TOI Processor
|
|---|
| 97 | Toi2RING m2ring(Nsamples);
|
|---|
| 98 | cout<<"Toi2RING created"<<endl;
|
|---|
| 99 |
|
|---|
| 100 | if(sfin>=sdeb) m2ring.setRequestedSample(sdeb,sfin);
|
|---|
| 101 |
|
|---|
| 102 | // Definition des tuyaux
|
|---|
| 103 | cout << label_phase <<endl;
|
|---|
| 104 |
|
|---|
| 105 | plombier.Connect(rfitsp,label_theta,m2ring,"Theta");
|
|---|
| 106 | plombier.Connect(rfitsp,label_phi,m2ring,"Phi");
|
|---|
| 107 | plombier.Connect(rfitsp,label_phase,m2ring,"Phase");
|
|---|
| 108 | plombier.Connect(rfitsv,label_bolomuv,m2ring,"Value");
|
|---|
| 109 | cout<<"file out "<<fitsout_value<< endl;
|
|---|
| 110 |
|
|---|
| 111 | plombier.Connect(m2ring,"CircTheta",wfits,"CircTheta");
|
|---|
| 112 | plombier.Connect(m2ring,"CircPhi",wfits,"CircPhi");
|
|---|
| 113 | plombier.Connect(m2ring,"Rvalue",wfits,"signal");
|
|---|
| 114 |
|
|---|
| 115 | plombier.Connect(m2ring,"WCircTheta",wwfits,"CircTheta");
|
|---|
| 116 | plombier.Connect(m2ring,"WCircPhi",wwfits,"CircPhi");
|
|---|
| 117 | plombier.Connect(m2ring,"WRvalue",wwfits,"signal");
|
|---|
| 118 |
|
|---|
| 119 | // Run
|
|---|
| 120 | cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
|
|---|
| 121 |
|
|---|
| 122 | plombier.Start();
|
|---|
| 123 | plombier.ListTOIs(cout, 1);
|
|---|
| 124 | cout << "Joining ..." << endl;
|
|---|
| 125 |
|
|---|
| 126 | mgr->joinAll();
|
|---|
| 127 | PrtTim("End threads");
|
|---|
| 128 |
|
|---|
| 129 | //--------------------------------------------------------------------
|
|---|
| 130 | } catch (PThrowable & exc) {
|
|---|
| 131 | cout<<"\ntsttoi2ring: Catched Exception \n"<<(string)typeid(exc).name()
|
|---|
| 132 | <<" - Msg= "<<exc.Msg()<<endl;
|
|---|
| 133 | } catch (const std::exception & sex) {
|
|---|
| 134 | cout<<"\ntsttoi2ring: Catched std::exception \n"
|
|---|
| 135 | <<(string)typeid(sex).name()<<endl;
|
|---|
| 136 | } catch (...) {
|
|---|
| 137 | cout<<"\ntsttoi2ring: some other exception was caught ! "<<endl;
|
|---|
| 138 | }
|
|---|
| 139 | //--------------------------------------------------------------------
|
|---|
| 140 |
|
|---|
| 141 | exit(0);
|
|---|
| 142 | }
|
|---|