| [1666] | 1 | // Test des classes FitsBoloRead
 | 
|---|
 | 2 | /*
 | 
|---|
 | 3 | set DIR = $PLANCK/Kiruna_2001_01_29/TOI/Full_sampling
 | 
|---|
 | 4 | ln -sf $DIR/PointingABv8/gLatLonAB_143k05_104000000_108465000.fits pointing.fits
 | 
|---|
 | 5 | ln -sf $DIR/Bolo_etc/b143k05_104000000_108465000.fits bolo.fits
 | 
|---|
 | 6 | cmvboloread -L 1000,1 -m 100000 \
 | 
|---|
 | 7 |            -a gLonBolo_27 -d gLatBolo_27 -b boloMuV_27  -s sampleNum \
 | 
|---|
 | 8 |            -A pointing.fits -1 0 -B bolo.fits -3 0
 | 
|---|
 | 9 | */
 | 
|---|
| [2615] | 10 | #include "sopnamsp.h"
 | 
|---|
| [1666] | 11 | #include "machdefs.h"
 | 
|---|
 | 12 | #include <typeinfo>
 | 
|---|
 | 13 | #include <stdio.h>
 | 
|---|
 | 14 | #include <stdlib.h>
 | 
|---|
| [2322] | 15 | #include <iostream>
 | 
|---|
| [2828] | 16 | // #include <values.h>
 | 
|---|
| [1666] | 17 | #include <string.h>
 | 
|---|
 | 18 | #include <string>
 | 
|---|
 | 19 | #include <unistd.h>
 | 
|---|
 | 20 | #include "sophyainit.h"
 | 
|---|
 | 21 | #include "pexceptions.h"
 | 
|---|
 | 22 | #include "fboloread.h"
 | 
|---|
 | 23 | #include "fabtwriter.h"
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | //#define NO_VECTOR
 | 
|---|
 | 26 | #define USE_EXCEPT
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | int main(int narg,char *arg[])
 | 
|---|
 | 29 | {
 | 
|---|
 | 30 |  SophyaInit();
 | 
|---|
| [3572] | 31 |  const char *label_alpha = "", *label_delta = "",
 | 
|---|
| [1666] | 32 |       *label_bolo  = "", *label_flag  = "",
 | 
|---|
 | 33 |       *label_snum  = "";
 | 
|---|
| [3572] | 34 |  const char *fits_alpha  = "", *fits_delta  = "",
 | 
|---|
| [1666] | 35 |       *fits_bolo   = "", *fits_flag   = "",
 | 
|---|
 | 36 |       *fits_snum   = "";
 | 
|---|
 | 37 |  int hdu_alpha=0, hdu_delta=0, hdu_bolo=0, hdu_flag=0, hdu_snum=0;
 | 
|---|
 | 38 |  long blen = 100, bsens = 1, lpmod=1;
 | 
|---|
 | 39 |  char c;
 | 
|---|
 | 40 |  while((c = getopt(narg,arg,"ha:d:s:b:f:A:D:S:B:F:1:2:3:4:5:L:m:")) != -1) {
 | 
|---|
 | 41 |    switch (c) {
 | 
|---|
 | 42 |    case 'a' :
 | 
|---|
 | 43 |      label_alpha = optarg;
 | 
|---|
 | 44 |      break;
 | 
|---|
 | 45 |    case 'd' :
 | 
|---|
 | 46 |      label_delta = optarg;
 | 
|---|
 | 47 |      break;
 | 
|---|
 | 48 |    case 'b' :
 | 
|---|
 | 49 |      label_bolo = optarg;
 | 
|---|
 | 50 |      break;
 | 
|---|
 | 51 |    case 'f' :
 | 
|---|
 | 52 |      label_flag = optarg;
 | 
|---|
 | 53 |      break;
 | 
|---|
 | 54 |    case 's' :
 | 
|---|
 | 55 |      label_snum = optarg;
 | 
|---|
 | 56 |      break;
 | 
|---|
 | 57 |    case 'A' :
 | 
|---|
 | 58 |      fits_alpha = optarg;
 | 
|---|
 | 59 |      break;
 | 
|---|
 | 60 |    case 'D' :
 | 
|---|
 | 61 |      fits_delta = optarg;
 | 
|---|
 | 62 |      break;
 | 
|---|
 | 63 |    case 'B' :
 | 
|---|
 | 64 |      fits_bolo = optarg;
 | 
|---|
 | 65 |      break;
 | 
|---|
 | 66 |    case 'F' :
 | 
|---|
 | 67 |      fits_flag = optarg;
 | 
|---|
 | 68 |      break;
 | 
|---|
 | 69 |    case 'S' :
 | 
|---|
 | 70 |      fits_snum = optarg;
 | 
|---|
 | 71 |      break;
 | 
|---|
 | 72 |    case '1' :
 | 
|---|
 | 73 |      sscanf(optarg,"%d",&hdu_alpha);
 | 
|---|
 | 74 |      break;
 | 
|---|
 | 75 |    case '2' :
 | 
|---|
 | 76 |      sscanf(optarg,"%d",&hdu_delta);
 | 
|---|
 | 77 |      break;
 | 
|---|
 | 78 |    case '3' :
 | 
|---|
 | 79 |      sscanf(optarg,"%d",&hdu_bolo);
 | 
|---|
 | 80 |      break;
 | 
|---|
 | 81 |    case '4' :
 | 
|---|
 | 82 |      sscanf(optarg,"%d",&hdu_flag);
 | 
|---|
 | 83 |      break;
 | 
|---|
 | 84 |    case '5' :
 | 
|---|
 | 85 |      sscanf(optarg,"%d",&hdu_snum);
 | 
|---|
 | 86 |      break;
 | 
|---|
 | 87 |    case 'L' :
 | 
|---|
 | 88 |      sscanf(optarg,"%ld,%ld",&blen,&bsens);
 | 
|---|
 | 89 |      break;
 | 
|---|
 | 90 |    case 'm' :
 | 
|---|
 | 91 |      sscanf(optarg,"%ld",&lpmod);
 | 
|---|
 | 92 |      if(lpmod<=0) lpmod = 1;
 | 
|---|
 | 93 |      break;
 | 
|---|
 | 94 |    case 'h' :
 | 
|---|
 | 95 |    default :
 | 
|---|
 | 96 |      cout<<"cmvcolread -L buflen,sens -m print_modulo"
 | 
|---|
 | 97 |          <<"\n           -a label_alpha -d label_delta"
 | 
|---|
 | 98 |          <<"\n           -b label_bolo  -f label_flag"
 | 
|---|
 | 99 |          <<"\n           -s label_snum"
 | 
|---|
 | 100 |          <<"\n           -A fits_alpha  -D fits_delta"
 | 
|---|
 | 101 |          <<"\n           -B fits_bolo   -F fits_flag"
 | 
|---|
 | 102 |          <<"\n           -S fits_snum"
 | 
|---|
 | 103 |          <<"\n           -1 hdu_alpha  -2 hdu_delta"
 | 
|---|
 | 104 |          <<"\n           -3 hdu_bolo   -4 hdu_flag"
 | 
|---|
 | 105 |          <<"\n           -5 hdu_snum"
 | 
|---|
 | 106 |          <<endl;
 | 
|---|
 | 107 |      return -1;
 | 
|---|
 | 108 |    }
 | 
|---|
 | 109 |  }
 | 
|---|
 | 110 | 
 | 
|---|
 | 111 |  cout<<"alpha: "<<label_alpha<<" ("<<fits_alpha<<") hdu="<<hdu_alpha<<endl;
 | 
|---|
 | 112 |  cout<<"delta: "<<label_delta<<" ("<<fits_delta<<") hdu="<<hdu_delta<<endl;
 | 
|---|
 | 113 |  cout<<"bolo : "<<label_bolo <<" ("<<fits_bolo<<") hdu="<<hdu_bolo<<endl;
 | 
|---|
 | 114 |  cout<<"flag : "<<label_flag <<" ("<<fits_flag<<") hdu="<<hdu_flag<<endl;
 | 
|---|
 | 115 |  cout<<"snum : "<<label_snum <<" ("<<fits_snum<<") hdu="<<hdu_snum<<endl;
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 | #ifdef USE_EXCEPT
 | 
|---|
 | 118 | try {
 | 
|---|
 | 119 | #endif
 | 
|---|
 | 120 | 
 | 
|---|
 | 121 |   FitsBoloRead fbr(blen,bsens);
 | 
|---|
 | 122 |   fbr.SetDebug(3);
 | 
|---|
 | 123 |   fbr.Print(3);
 | 
|---|
 | 124 | 
 | 
|---|
 | 125 |   if(strlen(label_bolo)>0)
 | 
|---|
 | 126 |     fbr.SetBolo(label_bolo,fits_bolo,hdu_bolo);
 | 
|---|
 | 127 |   if(strlen(label_flag)>0)
 | 
|---|
 | 128 |     fbr.SetFlag(label_flag,fits_flag,hdu_flag);
 | 
|---|
 | 129 |   if(strlen(label_snum)>0)
 | 
|---|
 | 130 |     fbr.SetSNum(label_snum,fits_snum,hdu_snum);
 | 
|---|
 | 131 |   if(strlen(label_alpha)>0)
 | 
|---|
 | 132 |     fbr.SetAlpha(label_alpha,fits_alpha,hdu_alpha);
 | 
|---|
 | 133 |   if(strlen(label_delta)>0)
 | 
|---|
 | 134 |     fbr.SetDelta(label_delta,fits_delta,hdu_delta);
 | 
|---|
 | 135 |   int col1=-1;
 | 
|---|
 | 136 |   if(strlen(label_snum)>0 && strlen(fits_alpha)>0)
 | 
|---|
 | 137 |     col1 = fbr.AddCol(label_snum,fits_alpha,hdu_alpha);
 | 
|---|
 | 138 | 
 | 
|---|
 | 139 |   fbr.Print(3);
 | 
|---|
 | 140 |   cout<<"NRows= "<<fbr.GetNbLine()<<endl;
 | 
|---|
 | 141 |   if(fbr.IsSNum()) fbr.SetNbLine(FitsBoloRead::ColSNum);
 | 
|---|
 | 142 |   cout<<"fbr.SetNbLine(ColSNum): NRows= "<<fbr.GetNbLine()<<endl;
 | 
|---|
 | 143 |   fbr.SetNbLine(-1);
 | 
|---|
 | 144 |   cout<<"fbr.SetNbLine(): NRows= "<<fbr.GetNbLine()<<endl;
 | 
|---|
 | 145 | 
 | 
|---|
 | 146 | #ifdef NO_VECTOR
 | 
|---|
 | 147 |   cout<<"Reading element by elements"<<endl;
 | 
|---|
 | 148 |   for(long i=0; i<fbr.GetNbLine(); i++) {
 | 
|---|
 | 149 |     double a=-1.,d=-1.,b=-1.,f=-1.,s=-1.,c1=-1.;
 | 
|---|
 | 150 |     if(fbr.IsAlpha())   a  = fbr.GetAlpha(i);
 | 
|---|
 | 151 |     if(fbr.IsDelta())   d  = fbr.GetDelta(i);
 | 
|---|
 | 152 |     if(fbr.IsBolo())    b  = fbr.GetBolo(i);
 | 
|---|
 | 153 |     if(fbr.IsSNum())    s  = fbr.GetSNum(i);
 | 
|---|
 | 154 |     if(fbr.IsFlag())    f  = fbr.GetFlag(i);
 | 
|---|
 | 155 |     if(col1>=0) if(fbr.IsCol(col1)) c1 = fbr.GetCol(col1,i);
 | 
|---|
 | 156 |     if(i%lpmod==0)
 | 
|---|
 | 157 |       cout<<i<<" s="<<(long long)s
 | 
|---|
 | 158 |           <<" b="<<b<<" f="<<f
 | 
|---|
 | 159 |           <<" a="<<a<<" d="<<d<<" c1="<<(long long)c1<<endl;
 | 
|---|
 | 160 |   }
 | 
|---|
 | 161 | #else
 | 
|---|
 | 162 |   cout<<"Reading with vectors"<<endl;
 | 
|---|
 | 163 |   long istep = lpmod;
 | 
|---|
 | 164 |   TVector<double> s,a,d,b,f,c1;
 | 
|---|
 | 165 |   TVector<int_4> si4,fi4;
 | 
|---|
 | 166 |   for(long i=0; i<fbr.GetNbLine(); i+=istep) {
 | 
|---|
 | 167 |     long i2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1;
 | 
|---|
 | 168 |     if(fbr.IsSNum())   {fbr.GetSNum(i,i2,s); fbr.GetSNum(i,i2,si4);}
 | 
|---|
 | 169 |     if(fbr.IsBolo())    fbr.GetBolo(i,i2,b);
 | 
|---|
 | 170 |     if(fbr.IsFlag())   {fbr.GetFlag(i,i2,f); fbr.GetFlag(i,i2,fi4);}
 | 
|---|
 | 171 |     if(fbr.IsAlpha())   fbr.GetAlpha(i,i2,a);
 | 
|---|
 | 172 |     if(fbr.IsDelta())   fbr.GetDelta(i,i2,d);
 | 
|---|
 | 173 |     if(col1>=0) if(fbr.IsCol(col1)) fbr.GetCol(col1,i,i2,c1);
 | 
|---|
 | 174 |     for(int j=0; j<2; j++) {
 | 
|---|
 | 175 |       int ii = 0; if(j==1) ii=i2-i;
 | 
|---|
 | 176 |       cout<<i<<"("<<ii<<") ";
 | 
|---|
 | 177 |       if(fbr.IsSNum())    cout<<" s=("<<s(ii)<<","<<si4(ii)<<")";
 | 
|---|
 | 178 |       if(fbr.IsBolo())    cout<<" b="<<b(ii);
 | 
|---|
 | 179 |       if(fbr.IsFlag())    cout<<" f=("<<f(ii)<<","<<fi4(ii)<<")";
 | 
|---|
 | 180 |       if(fbr.IsAlpha())   cout<<" a="<<a(ii);
 | 
|---|
 | 181 |       if(fbr.IsDelta())   cout<<" d="<<d(ii);
 | 
|---|
 | 182 |       if(col1>=0) if(fbr.IsCol(col1)) cout<<" c1="<<c1(ii);
 | 
|---|
 | 183 |       cout<<endl;
 | 
|---|
 | 184 |     }
 | 
|---|
 | 185 |   }
 | 
|---|
 | 186 | #endif
 | 
|---|
 | 187 | 
 | 
|---|
 | 188 | #ifdef USE_EXCEPT
 | 
|---|
 | 189 | } catch (PThrowable & exc) {
 | 
|---|
 | 190 |   cout<<"Exception : "<<(string)typeid(exc).name()
 | 
|---|
 | 191 |       <<" - Msg= "<<exc.Msg()<<endl;
 | 
|---|
 | 192 |   return -2;
 | 
|---|
 | 193 | 
 | 
|---|
 | 194 | } catch (...) {
 | 
|---|
 | 195 |   cout<<" some other exception was caught !"<<endl;
 | 
|---|
 | 196 |   return -2;
 | 
|---|
 | 197 | }
 | 
|---|
 | 198 | #endif
 | 
|---|
 | 199 | 
 | 
|---|
 | 200 |  return 0;
 | 
|---|
 | 201 | }
 | 
|---|