[2094] | 1 | //#define TOISEQBUFFERED
|
---|
| 2 |
|
---|
| 3 | #include <unistd.h>
|
---|
| 4 | #include <stdlib.h>
|
---|
| 5 | #include <stdio.h>
|
---|
| 6 | #include "toi.h"
|
---|
| 7 | #include "cgt.h"
|
---|
| 8 | #include "toiprocessor.h"
|
---|
| 9 | #include "fitstoirdr.h"
|
---|
| 10 | #include "fitstoiwtr.h"
|
---|
| 11 | #include "toimanager.h"
|
---|
| 12 | #ifdef TOISEQBUFFERED
|
---|
| 13 | #include "toiseqbuff.h"
|
---|
| 14 | #else
|
---|
| 15 | #include "toisegment.h"
|
---|
| 16 | #endif
|
---|
| 17 |
|
---|
| 18 | #include "sambainit.h"
|
---|
| 19 | #include "toi2toi_addsp.h"
|
---|
| 20 | #include "timing.h"
|
---|
| 21 |
|
---|
| 22 | #include <stdexcept>
|
---|
| 23 |
|
---|
| 24 | void usage(void);
|
---|
| 25 | void usage(void) {
|
---|
| 26 | cout<<"tsttoi2toi_addsp [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
|
---|
| 27 | <<" [-a label_coord1] [-d label_coord2] [-b label_bolomuv]"<<endl
|
---|
| 28 | <<" [-n nlat] [-i c,h] [-o c,h]"<<endl
|
---|
| 29 | <<" [-m vmin] [-M vmax] [-f flag]"<<endl
|
---|
| 30 | <<" fitsin_point fitsin_bolo fitsphout [fitsphwout]"<<endl
|
---|
| 31 | <<" -p lp : print level (def=0)"<<endl
|
---|
| 32 | <<" -s samplemin,samplemax : sample range to be treated (def=all)"<<endl
|
---|
| 33 | <<" -w data_window_size : window size for pipe (def=8192)"<<endl
|
---|
| 34 | <<" -a label_coord1 : label fits for alpha/gLong (def=coord1)"<<endl
|
---|
| 35 | <<" -d label_coord2 : label fits for delta/gLat (def=coord2)"<<endl
|
---|
| 36 | <<" coord1 = alpha or gLong ; coord2 = delta or gLat"<<endl
|
---|
| 37 | <<" -b label_bolomuv : label fits for bolo value (def=boloMuV)"<<endl
|
---|
| 38 | <<" -m vmin : samples are good if sample value >= vmin"<<endl
|
---|
| 39 | <<" -M vmax : samples are good if sample value <= vmax"<<endl
|
---|
| 40 | <<" -f flag : samples are bad if match flag"<<endl
|
---|
| 41 | <<" -I : sampleNum are implicit in fits files (def=no)"<<endl
|
---|
| 42 | <<" fitsin_point : fits file for pointing"<<endl
|
---|
| 43 | <<" fitsin_bolo : fits file for bolo values"<<endl
|
---|
| 44 | <<" fitsout_bolo : fits file for output bolo value"<<endl
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | ////////////////////////////////////////////////////////////////
|
---|
| 48 | int main(int narg, char** arg) {
|
---|
| 49 |
|
---|
| 50 | TOIManager* mgr = TOIManager::getManager();
|
---|
| 51 |
|
---|
| 52 | //-- Decodage arguments
|
---|
| 53 | int lp = 0, width = 8192;
|
---|
| 54 | bool tflg=false, tmin=false, tmax=false;
|
---|
| 55 | r_8 vmin=-1.e30, vmax=1.e30; uint_8 badflg=0;
|
---|
| 56 | char *label_coord1 = "coord1", *label_coord2 = "coord2"
|
---|
| 57 | , *label_bolomuv = "boloMuV";
|
---|
| 58 | double equi=2000.;
|
---|
| 59 | char *tcoorin="gdcdl", *tcoormap="g";
|
---|
| 60 | long sdeb,sfin;
|
---|
| 61 | bool snimplicit = false;
|
---|
| 62 | int c;
|
---|
| 63 | while((c = getopt(narg,arg,"hIp:s:w:a:d:b:n:i:o:m:M:f:e:")) != -1) {
|
---|
| 64 | switch (c) {
|
---|
| 65 | case 's' :
|
---|
| 66 | sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
|
---|
| 67 | cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
|
---|
| 68 | if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
|
---|
| 69 | //else {cout<<"Bad sample interval "<<endl; exit(2);}
|
---|
| 70 | break;
|
---|
| 71 | case 'w' :
|
---|
| 72 | sscanf(optarg,"%d",&width);
|
---|
| 73 | if(width<=0) width=8192;
|
---|
| 74 | cout<<"Data window size "<<width<<endl;
|
---|
| 75 | break;
|
---|
| 76 | case 'p' :
|
---|
| 77 | sscanf(optarg,"%d",&lp);
|
---|
| 78 | if(lp<0) lp=0;
|
---|
| 79 | break;
|
---|
| 80 | case 'a' :
|
---|
| 81 | label_coord1 = optarg;
|
---|
| 82 | break;
|
---|
| 83 | case 'd' :
|
---|
| 84 | label_coord2 = optarg;
|
---|
| 85 | break;
|
---|
| 86 | case 'b' :
|
---|
| 87 | label_bolo_in = optarg;
|
---|
| 88 | break;
|
---|
| 89 | case 'n' :
|
---|
| 90 | label_bolo_out = optarg;
|
---|
| 91 | break;
|
---|
| 92 | case 'u' :
|
---|
| 93 | label_utc = optarg;
|
---|
| 94 | break;
|
---|
| 95 | case 'l' :
|
---|
| 96 | label_lon = optarg;
|
---|
| 97 | break;
|
---|
| 98 | case 'L' :
|
---|
| 99 | label_lat = optarg;
|
---|
| 100 | break;
|
---|
| 101 | case 'i' :
|
---|
| 102 | tcoorin=optarg;
|
---|
| 103 | break;
|
---|
| 104 | case 'o' :
|
---|
| 105 | tcoormap=optarg;
|
---|
| 106 | break;
|
---|
| 107 | case 'e' :
|
---|
| 108 | sscanf(optarg,"%lf",&equi);
|
---|
| 109 | break;
|
---|
| 110 | case 'm' :
|
---|
| 111 | sscanf(optarg,"%lf",&vmin);
|
---|
| 112 | tmin = true;
|
---|
| 113 | break;
|
---|
| 114 | case 'M' :
|
---|
| 115 | sscanf(optarg,"%lf",&vmax);
|
---|
| 116 | tmax = true;
|
---|
| 117 | break;
|
---|
| 118 | case 'f' :
|
---|
| 119 | sscanf(optarg,"%ul",&badflg);
|
---|
| 120 | tflg = true;
|
---|
| 121 | break;
|
---|
| 122 | case 'I' :
|
---|
| 123 | snimplicit = true;
|
---|
| 124 | break;
|
---|
| 125 | case 'h' :
|
---|
| 126 | default:
|
---|
| 127 | usage(); exit(1);
|
---|
| 128 | break;
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | if(optind+5>=narg) {usage(); exit(3);}
|
---|
| 132 |
|
---|
| 133 | char * fitsin_point = arg[optind];
|
---|
| 134 | char * fitsin_bolo = arg[optind+1];
|
---|
| 135 | char * fitsin_utc = arg[optind+2];
|
---|
| 136 | char * fitsin_lon = arg[optind+3];
|
---|
| 137 | char * fitsin_lat = arg[optind+4];
|
---|
| 138 | char * fitsout_bolo = arg[optind+5];
|
---|
| 139 |
|
---|
| 140 | cout<<">>>> tsttoi2toi_addsp:"<<endl
|
---|
| 141 | <<"Pipe Window Size "<<width<<endl
|
---|
| 142 | <<"Fits Infile Bolo "<<fitsin_bolo<<endl
|
---|
| 143 | <<" ...label_bolo_in "<<label_bolo_in<<endl;
|
---|
| 144 | cout<<"Fits Infile Pointing "<<fitsin_point<<endl
|
---|
| 145 | <<" ...label_coord1 "<<label_coord1<<endl
|
---|
| 146 | <<" ...label_coord2 "<<label_coord2<<endl
|
---|
| 147 | <<" ...... ctype="<<tcoorin<<endl;
|
---|
| 148 | cout<<"Fits Outfile Bolo"<<fitsout_bolo<<endl
|
---|
| 149 | <<" ...label_bolo_out "<<label_bolo_out<<endl;
|
---|
| 150 |
|
---|
| 151 | SophyaInit();
|
---|
| 152 | InitTim();
|
---|
| 153 |
|
---|
| 154 | //--------------------------------------------------------------------
|
---|
| 155 | try {
|
---|
| 156 | //--------------------------------------------------------------------
|
---|
| 157 |
|
---|
| 158 | CGT plombier(fgsegmented,wsize);
|
---|
| 159 | plombier.SetDebugLevel(0);
|
---|
| 160 |
|
---|
| 161 | // FITS reader
|
---|
| 162 | FITSTOIReader rfitsb(fitsin_bolo);
|
---|
| 163 | if(snimplicit) rfitsb.setImplicitSN();
|
---|
| 164 | int ncolb = rfitsb.getNOut();
|
---|
| 165 | cout<<"Number of columns in fits Infile_bolo : "<<ncolb<<endl;
|
---|
| 166 | if(ncolb<1) exit(-4);
|
---|
| 167 |
|
---|
| 168 | FITSTOIReader rfitsp(fitsin_point);
|
---|
| 169 | if(snimplicit) rfitsp.setImplicitSN();
|
---|
| 170 | int ncolp = rfitsp.getNOut();
|
---|
| 171 | cout<<"Number of columns in fits Infile_point : "<<ncolp<<endl;
|
---|
| 172 | if(ncolp<2) exit(-5);
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | FITSTOIReader rfitsu(fitsin_utc);
|
---|
| 176 | FITSTOIReader rfitsl(fitsin_lon);
|
---|
| 177 | FITSTOIReader rfitsL(fitsin_lat);
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | // TOI Processor
|
---|
| 181 | Toi2toi_Addsp toi2t_sp();
|
---|
| 182 | cout<<"Toi2toi_Addsp created"<<endl;
|
---|
| 183 | toi2t_sp.SetEquinox(equi);
|
---|
| 184 | toi2t_sp.SetCoorIn(tcoorin);
|
---|
| 185 | toi2t_sp.SetCoorMap(tcoormap);
|
---|
| 186 | toi2t_sp.SetTestFlag(tflg,badflg);
|
---|
| 187 | toi2t_sp.SetTestMin(tmin,vmin);
|
---|
| 188 | toi2t_sp.SetTestMax(tmax,vmax);
|
---|
| 189 | toi2t_sp.Print(cout);
|
---|
| 190 |
|
---|
| 191 | // Definition des tuyaux
|
---|
| 192 | plombier.Connect(rfitsp,label_coord1,toi2t_sp,"Coord1In");
|
---|
| 193 | plombier.Connect(rfitsp,label_coord2,toi2t_sp,"Coord2In");
|
---|
| 194 | plombier.Connect(rfitsb,label_bolo_in,toi2t_sp,"BoloIn");
|
---|
| 195 |
|
---|
| 196 | plombier.Connect(rfitsu,label_utc,toi2t_sp,"utc");
|
---|
| 197 | plombier.Connect(rfitsl,label_lon,toi2t_sp,"lon");
|
---|
| 198 | plombier.Connect(rfitsL,label_lat,toi2t_sp,"lat");
|
---|
| 199 |
|
---|
| 200 | plombier.Connect(toi2t_sp,"BoloOut",wfits,label_bolo_out);
|
---|
| 201 |
|
---|
| 202 | // Run
|
---|
| 203 | cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
|
---|
| 204 |
|
---|
| 205 | plombier.Start();
|
---|
| 206 | plombier.ListTOIs(cout, 1);
|
---|
| 207 | cout << "Joining ..." << endl;
|
---|
| 208 | mgr->joinAll();
|
---|
| 209 | PrtTim("End threads");
|
---|
| 210 |
|
---|
| 211 |
|
---|
| 212 |
|
---|
| 213 | //--------------------------------------------------------------------
|
---|
| 214 | } catch (PThrowable & exc) {
|
---|
| 215 | cout<<"\ntsttoi2toi_addsp: Catched Exception \n"<<(string)typeid(exc).name()
|
---|
| 216 | <<" - Msg= "<<exc.Msg()<<endl;
|
---|
| 217 | } catch (const std::exception & sex) {
|
---|
| 218 | cout<<"\ntsttoi2toi_addsp: Catched std::exception \n"
|
---|
| 219 | <<(string)typeid(sex).name()<<endl;
|
---|
| 220 | } catch (...) {
|
---|
| 221 | cout<<"\ntsttoi2toi_addsp: some other exception was caught ! "<<endl;
|
---|
| 222 | }
|
---|
| 223 | //--------------------------------------------------------------------
|
---|
| 224 |
|
---|
| 225 | exit(0);
|
---|
| 226 | }
|
---|