[3787] | 1 | /* ------------------------ Projet BAORadio --------------------
|
---|
| 2 | Programme de convolution avec le lobe d'un cube 3D (angles,freq)
|
---|
| 3 | R. Ansari , C. Magneville - Juin 2010
|
---|
| 4 |
|
---|
[3789] | 5 | Usage: applobe In3DPPFName Out3DPPFName [ResmapleFactor=0.5,0.333...] [TargetBeamArcmin]
|
---|
[3787] | 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) {
|
---|
[3789] | 52 | cout << "Usage: applobe In3DPPFName Out3DPPFName [ResmapleFactor=0.5,0.333...] [TargetBeamArcmin]\n" << endl;
|
---|
[3787] | 53 | return 1;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | // decodage arguments
|
---|
| 57 | string outname = arg[2];
|
---|
| 58 | string inname = arg[1];
|
---|
[3789] | 59 | bool fgresample=false;
|
---|
| 60 | double fresamp=1.;
|
---|
| 61 | if (narg>3) {
|
---|
| 62 | fresamp=atof(arg[3]);
|
---|
| 63 | if ((fabs(fresamp)>1.e-2)&&(fabs(fresamp-1.)>1.e-2)) fgresample=true;
|
---|
| 64 | }
|
---|
| 65 | bool fgcorrbeam=false;
|
---|
| 66 | double tbeamarcmin=15.;
|
---|
| 67 | if (narg>4) {
|
---|
| 68 | tbeamarcmin=atof(arg[4]);
|
---|
| 69 | if (tbeamarcmin>1.e-3) fgcorrbeam=true;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
[3787] | 72 | int rc = 91;
|
---|
| 73 |
|
---|
| 74 | cout << " ====== applobe : Input NVSS catalog name= " << inname << " OutName=" << outname;
|
---|
| 75 | bool fginmap=true;
|
---|
| 76 | try {
|
---|
| 77 | TArray<r_4> incube;
|
---|
| 78 | cout << "applobe[1]: reading input 3D map (cube) from file " << inname << endl;
|
---|
| 79 | {
|
---|
| 80 | PInPersist pin(inname);
|
---|
| 81 | pin >> incube;
|
---|
| 82 | }
|
---|
[3788] | 83 | incube.Show();
|
---|
[3787] | 84 |
|
---|
| 85 | double dxdeg = ThetaSizeDegre/(double)NTheta;
|
---|
| 86 | double dydeg = PhiSizeDegre/(double)NPhi;
|
---|
| 87 | double dx = DegreeToRadian(dxdeg);
|
---|
| 88 | double dy = DegreeToRadian(dydeg);
|
---|
| 89 | double dfreq = FreqSizeMHz/(double)NFreq;
|
---|
| 90 |
|
---|
| 91 | cout << " X,Y map size in degrees , X/Phi=" << PhiSizeDegre << " Y/Theta=" << ThetaSizeDegre
|
---|
| 92 | << " \n dx=" << dxdeg << " dy=" << dydeg << " degres ( dx_rad=" << dx << " dy_rad=" << dy << ")"
|
---|
| 93 | << " FreqSize=" << FreqSizeMHz << " dfreq=dz= " << dfreq << " MHz" << endl;
|
---|
| 94 |
|
---|
| 95 | double mean, sigma;
|
---|
| 96 | MeanSigma(incube, mean, sigma);
|
---|
| 97 | cout << " InCube 3D- : Mean=" << mean << " Sigma=" << sigma << endl;
|
---|
| 98 |
|
---|
| 99 | cout << "applobe[2]: creating Four2DResponse and BeamEffect objects..." << endl;
|
---|
| 100 | H21Conversions conv;
|
---|
| 101 | conv.setFrequency(Freq0MHz);
|
---|
| 102 | double lambda = conv.getLambda();
|
---|
[3789] | 103 | Four2DResponse fresp(2, InterfArrayDiametre/lambda, InterfArrayDiametre/lambda, lambda);
|
---|
[3787] | 104 | BeamEffect beam(fresp);
|
---|
| 105 |
|
---|
[3789] | 106 | if (fgcorrbeam) {
|
---|
| 107 | double DoL = 1.22/ArcminToRadian(tbeamarcmin);
|
---|
| 108 | Four2DResponse tbeam(2, DoL, DoL );
|
---|
| 109 | cout << "applobe[3]: calling Correct2RefLobe() with target beam:" << tbeamarcmin
|
---|
| 110 | << " arcmin -> D/Lambda=" << DoL << endl;
|
---|
| 111 | beam.Correct2RefLobe(tbeam, incube, dx, dy, Freq0MHz, dfreq);
|
---|
| 112 | }
|
---|
| 113 | else {
|
---|
| 114 | cout << "applobe[3]: calling ApplyLobe3D() ... " << endl;
|
---|
| 115 | beam.ApplyLobe3D(incube, dx, dy, Freq0MHz, dfreq);
|
---|
| 116 | }
|
---|
| 117 | TArray< r_4 > outcube;
|
---|
| 118 | if (fgresample) {
|
---|
| 119 | cout << "applobe[4]: calling ReSample(incube," << fresamp << "," << ",1.) ... " << endl;
|
---|
| 120 | outcube.Share(beam.ReSample(incube, fresamp, fresamp, 1.));
|
---|
| 121 | }
|
---|
| 122 | else outcube.Share(incube);
|
---|
[3787] | 123 |
|
---|
[3788] | 124 | outcube.Show();
|
---|
[3787] | 125 | MeanSigma(outcube, mean, sigma);
|
---|
| 126 | cout << " OutCube 3D- : Mean=" << mean << " Sigma=" << sigma << endl;
|
---|
| 127 |
|
---|
| 128 | // On sauve le cube de sortie
|
---|
| 129 | {
|
---|
| 130 | cout << " applobe[5]: Saving output cube to -> " << outname << endl;
|
---|
| 131 | POutPersist poc(outname);
|
---|
| 132 | poc << outcube;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | rc = 0;
|
---|
| 136 | }
|
---|
| 137 | catch (PThrowable& exc) {
|
---|
| 138 | cerr << " applobe.cc catched SOPHYA Exception " << exc.Msg() << endl;
|
---|
| 139 | rc = 77;
|
---|
| 140 | }
|
---|
| 141 | catch (std::exception& sex) {
|
---|
| 142 | cerr << "\n applobe.cc std::exception :"
|
---|
| 143 | << (string)typeid(sex).name() << "\n msg= "
|
---|
| 144 | << sex.what() << endl;
|
---|
| 145 | }
|
---|
| 146 | catch (...) {
|
---|
| 147 | cerr << " applobe.cc catched unknown (...) exception " << endl;
|
---|
| 148 | rc = 78;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | cout << ">>>> applobe[9] ------- FIN ----------- Rc=" << rc << endl;
|
---|
| 152 | return rc;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 |
|
---|