| 1 | /*  ------------------------ Projet BAORadio -------------------- 
 | 
|---|
| 2 |   Programme de convolution avec le lobe d'un cube 3D (angles,freq) 
 | 
|---|
| 3 |     R. Ansari , C. Magneville - Juin 2010 
 | 
|---|
| 4 | 
 | 
|---|
| 5 |   Usage: applobe In3DPPFName Out3DPPFName
 | 
|---|
| 6 | ---------------------------------------------------------------  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #include "sopnamsp.h"
 | 
|---|
| 9 | #include "machdefs.h"
 | 
|---|
| 10 | #include <math.h>
 | 
|---|
| 11 | #include <iostream>
 | 
|---|
| 12 | #include <typeinfo>
 | 
|---|
| 13 | 
 | 
|---|
| 14 | #include "array.h"
 | 
|---|
| 15 | #include "histats.h"
 | 
|---|
| 16 | 
 | 
|---|
| 17 | #include "swfitsdtable.h"
 | 
|---|
| 18 | #include "fitshdtable.h"
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "randr48.h"
 | 
|---|
| 21 | #include "vector3d.h"
 | 
|---|
| 22 | 
 | 
|---|
| 23 | // #include "xastropack.h"     -- Pour faire les conversions de coordonnees celestes
 | 
|---|
| 24 | 
 | 
|---|
| 25 | #include "radutil.h"
 | 
|---|
| 26 | #include "lobe.h"
 | 
|---|
| 27 | 
 | 
|---|
| 28 | // Pour l'initialisation des modules 
 | 
|---|
| 29 | #include "tarrinit.h"
 | 
|---|
| 30 | #include "histinit.h"
 | 
|---|
| 31 | #include "fiosinit.h"     
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #include "timing.h"
 | 
|---|
| 34 | #include "ctimer.h"
 | 
|---|
| 35 | 
 | 
|---|
| 36 | #include "cubedef.h"
 | 
|---|
| 37 | 
 | 
|---|
| 38 | //----------------------------------------------------------------------------
 | 
|---|
| 39 | //----------------------------------------------------------------------------   
 | 
|---|
| 40 | int main(int narg, char* arg[])
 | 
|---|
| 41 | {
 | 
|---|
| 42 |   // Sophya modules initialization
 | 
|---|
| 43 |   TArrayInitiator  _inia;
 | 
|---|
| 44 |   HiStatsInitiator  _inih;
 | 
|---|
| 45 |   FitsIOServerInitiator  _inif;
 | 
|---|
| 46 |   //------- AU LIEU DE ------>  SophyaInit();  
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   InitTim();   // Initializing the CPU timer
 | 
|---|
| 49 |   Timer tm("applobe");
 | 
|---|
| 50 | 
 | 
|---|
| 51 |   if (narg < 3) {
 | 
|---|
| 52 |     cout << "Usage: applobe In3DPPFName Out3DPPFName \n" << endl;
 | 
|---|
| 53 |     return 1;
 | 
|---|
| 54 |   }
 | 
|---|
| 55 | 
 | 
|---|
| 56 |   // decodage arguments 
 | 
|---|
| 57 |   string outname = arg[2];
 | 
|---|
| 58 |   string inname = arg[1];
 | 
|---|
| 59 |   int rc = 91;
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   cout << " ====== applobe :   Input NVSS catalog name= " << inname << " OutName=" << outname;
 | 
|---|
| 62 |   bool fginmap=true;
 | 
|---|
| 63 |   try {
 | 
|---|
| 64 |     TArray<r_4> incube;
 | 
|---|
| 65 |     cout << "applobe[1]: reading input 3D map (cube) from file " << inname << endl;
 | 
|---|
| 66 |     {
 | 
|---|
| 67 |       PInPersist pin(inname);
 | 
|---|
| 68 |       pin >> incube;
 | 
|---|
| 69 |     }
 | 
|---|
| 70 |     incube.Show(); 
 | 
|---|
| 71 | 
 | 
|---|
| 72 |     double dxdeg = ThetaSizeDegre/(double)NTheta;
 | 
|---|
| 73 |     double dydeg = PhiSizeDegre/(double)NPhi;
 | 
|---|
| 74 |     double dx = DegreeToRadian(dxdeg);
 | 
|---|
| 75 |     double dy = DegreeToRadian(dydeg);
 | 
|---|
| 76 |     double dfreq = FreqSizeMHz/(double)NFreq;
 | 
|---|
| 77 | 
 | 
|---|
| 78 |     cout << " X,Y map size in degrees , X/Phi=" << PhiSizeDegre << " Y/Theta=" << ThetaSizeDegre
 | 
|---|
| 79 |          << " \n dx=" << dxdeg << " dy=" << dydeg << " degres ( dx_rad=" << dx << " dy_rad=" << dy << ")" 
 | 
|---|
| 80 |          << " FreqSize=" << FreqSizeMHz << " dfreq=dz= " << dfreq << " MHz" << endl;
 | 
|---|
| 81 | 
 | 
|---|
| 82 |     double mean, sigma;
 | 
|---|
| 83 |     MeanSigma(incube, mean, sigma);
 | 
|---|
| 84 |     cout << " InCube 3D- : Mean=" << mean << " Sigma=" << sigma <<  endl;
 | 
|---|
| 85 | 
 | 
|---|
| 86 |     cout << "applobe[2]: creating Four2DResponse and BeamEffect objects..." << endl;
 | 
|---|
| 87 |     H21Conversions conv;
 | 
|---|
| 88 |     conv.setFrequency(Freq0MHz);
 | 
|---|
| 89 |     double lambda = conv.getLambda();
 | 
|---|
| 90 |     Four2DResponse fresp(2, InterfArrayDiametre/lambda, InterfArrayDiametre/lambda);
 | 
|---|
| 91 |     BeamEffect beam(fresp);
 | 
|---|
| 92 | 
 | 
|---|
| 93 |     cout << "applobe[3]: calling ApplyLobe3D() ... " << endl;
 | 
|---|
| 94 |     beam.ApplyLobe3D(incube, dx, dy, Freq0MHz, dfreq);
 | 
|---|
| 95 | 
 | 
|---|
| 96 |     cout << "applobe[4]: calling ReSample(incube, 0.5, 0.5, 1.) ... " << endl;
 | 
|---|
| 97 |     TArray< r_4 > outcube = beam.ReSample(incube, 0.5, 0.5, 1.);
 | 
|---|
| 98 |     
 | 
|---|
| 99 |     outcube.Show(); 
 | 
|---|
| 100 |     MeanSigma(outcube, mean, sigma);
 | 
|---|
| 101 |     cout << " OutCube 3D- : Mean=" << mean << " Sigma=" << sigma <<  endl;
 | 
|---|
| 102 | 
 | 
|---|
| 103 |     // On sauve le cube de sortie
 | 
|---|
| 104 |     {
 | 
|---|
| 105 |       cout << " applobe[5]: Saving output cube to -> " << outname << endl;
 | 
|---|
| 106 |       POutPersist poc(outname);
 | 
|---|
| 107 |       poc << outcube;
 | 
|---|
| 108 |     }
 | 
|---|
| 109 | 
 | 
|---|
| 110 |     rc = 0;
 | 
|---|
| 111 |   }
 | 
|---|
| 112 |   catch (PThrowable& exc) {
 | 
|---|
| 113 |     cerr << " applobe.cc catched SOPHYA Exception " << exc.Msg() << endl;
 | 
|---|
| 114 |     rc = 77;
 | 
|---|
| 115 |   }  
 | 
|---|
| 116 |   catch (std::exception& sex) {
 | 
|---|
| 117 |     cerr << "\n applobe.cc std::exception :" 
 | 
|---|
| 118 |          << (string)typeid(sex).name() << "\n msg= " 
 | 
|---|
| 119 |          << sex.what() << endl;
 | 
|---|
| 120 |   }
 | 
|---|
| 121 |   catch (...) {
 | 
|---|
| 122 |     cerr << " applobe.cc catched unknown (...) exception  " << endl; 
 | 
|---|
| 123 |     rc = 78; 
 | 
|---|
| 124 |   } 
 | 
|---|
| 125 | 
 | 
|---|
| 126 |   cout << ">>>> applobe[9] ------- FIN ----------- Rc=" << rc << endl;
 | 
|---|
| 127 |   return rc;
 | 
|---|
| 128 | }
 | 
|---|
| 129 | 
 | 
|---|
| 130 | 
 | 
|---|