00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SYNTHESIS_BEAMCALC_H
00030 #define SYNTHESIS_BEAMCALC_H
00031
00032
00033 #include <images/Images/TempImage.h>
00034 #include <casa/Exceptions.h>
00035 #include <casa/Logging/LogIO.h>
00036
00037 namespace casa
00038 {
00039
00040 #define MAXGEOM 2000
00041
00042 typedef struct
00043 {
00044 char name[16];
00045 Double sub_h;
00046 Double feedpos[3];
00047 Double subangle;
00048 Double legwidth;
00049 Double legfoot;
00050 Double legapex;
00051 Double Rhole;
00052 Double Rant;
00053 Double reffreq;
00054 Double taperpoly[5];
00055 Int ntaperpoly;
00056
00057 Double astigm_0;
00058 Double astigm_45;
00059
00060
00061
00062
00063
00064
00065 } BeamCalcGeometry;
00066
00067 typedef struct
00068 {
00069 Int oversamp;
00070 TempImage<Complex> *aperture;
00071 Double x0, y0;
00072 Double dx, dy;
00073 Int nx, ny;
00074
00075
00076
00077
00078 Double pa;
00079 Double freq;
00080 Int band;
00081 } ApertureCalcParams;
00082
00083
00084
00085
00086 typedef struct
00087 {
00088 Double sub_h;
00089 Double feed[3];
00090 Double feeddir[3];
00091 Double pfeeddir[3];
00092 Double radius;
00093 Double K;
00094 Double deltar;
00095 Double zedge;
00096 Double bestparabola;
00097 Double ftaper;
00098 Double thmax;
00099 Double fa2pi;
00100 Double legwidth;
00101 Double legfoot, legfootz;
00102 Double legapex;
00103 Double legthick;
00104 Double hole_radius;
00105 Double freq, lambda;
00106 Double astigm_0;
00107 Double astigm_45;
00108 Double dir[3];
00109 Double hhat[3], vhat[3];
00110 Double z[MAXGEOM];
00111 Double m[MAXGEOM];
00112 Double k[3];
00113 Int ngeom;
00114 char name[16];
00115 Int gridsize;
00116 } calcAntenna;
00117
00118 typedef struct
00119 {
00120 Double subrot[3][3];
00121 Double feedrot[3][3];
00122 Double subshift[3];
00123 Double feedshift[3];
00124 Double subrotpoint[3];
00125 Double az_offset;
00126 Double el_offset;
00127 Double phase_offset;
00128 Double focus;
00129 } Pathology;
00130
00131 typedef struct
00132 {
00133 Double aper[6];
00134 Double dish[6];
00135 Double sub[6];
00136 Double feed[3];
00137 } Ray;
00138
00139
00140 enum VLABeamCalcBandCode{
00141 BeamCalc_VLA_L = 0,
00142 BeamCalc_VLA_C,
00143 BeamCalc_VLA_X,
00144 BeamCalc_VLA_U,
00145 BeamCalc_VLA_K,
00146 BeamCalc_VLA_Q,
00147 BeamCalc_VLA_4,
00148
00149 VLABeamCalc_NumBandCodes
00150 };
00151
00152 enum EVLABeamCalcBandCode{
00153 BeamCalc_EVLA_L = 0,
00154 BeamCalc_EVLA_S,
00155 BeamCalc_EVLA_C,
00156 BeamCalc_EVLA_X,
00157 BeamCalc_EVLA_U,
00158 BeamCalc_EVLA_K,
00159 BeamCalc_EVLA_A,
00160 BeamCalc_EVLA_Q,
00161 BeamCalc_EVLA_4,
00162
00163 EVLABeamCalc_NumBandCodes
00164 };
00165
00166 enum ALMABeamCalcBandCode{
00167 BeamCalc_ALMA_1 = 0,
00168 BeamCalc_ALMA_2,
00169 BeamCalc_ALMA_3,
00170 BeamCalc_ALMA_4,
00171 BeamCalc_ALMA_5,
00172 BeamCalc_ALMA_6,
00173 BeamCalc_ALMA_7,
00174 BeamCalc_ALMA_8,
00175 BeamCalc_ALMA_9,
00176 BeamCalc_ALMA_10,
00177
00178 ALMABeamCalc_NumBandCodes
00179 };
00180
00181 extern Double VLABandMinFreqDefaults[VLABeamCalc_NumBandCodes];
00182 extern Double VLABandMaxFreqDefaults[VLABeamCalc_NumBandCodes];
00183 extern BeamCalcGeometry VLABeamCalcGeometryDefaults[VLABeamCalc_NumBandCodes];
00184 extern Double EVLABandMinFreqDefaults[EVLABeamCalc_NumBandCodes];
00185 extern Double EVLABandMaxFreqDefaults[EVLABeamCalc_NumBandCodes];
00186 extern BeamCalcGeometry EVLABeamCalcGeometryDefaults[EVLABeamCalc_NumBandCodes];
00187 extern Double ALMABandMinFreqDefaults[ALMABeamCalc_NumBandCodes];
00188 extern Double ALMABandMaxFreqDefaults[ALMABeamCalc_NumBandCodes];
00189 extern BeamCalcGeometry ALMABeamCalcGeometryDefaults[ALMABeamCalc_NumBandCodes];
00190
00191 class BeamCalc
00192 {
00193 public:
00194
00195
00196 static BeamCalc* Instance();
00197
00198 void setBeamCalcGeometries(const String& obsName,
00199 const String& antennaType = "STANDARD",
00200 const MEpoch& obsTime = MEpoch(Quantity(50000., "d")),
00201 const String& otherAntRayPath="");
00202
00203 Int getBandID(const Double freq,
00204 const String& obsname,
00205 const String& antennaType="STANDARD",
00206 const MEpoch& obsTime = MEpoch(Quantity(50000., "d")),
00207 const String& otherAntRayPath="");
00208
00209 Int calculateAperture(ApertureCalcParams *ap);
00210 Int calculateAperture(ApertureCalcParams *ap, const Int& whichStokes);
00211 Int calculateApertureLinPol(ApertureCalcParams *ap, const Int& whichStokes);
00212
00213 protected:
00214 BeamCalc();
00215
00216 private:
00217
00218 void computePixelValues(const ApertureCalcParams *ap, const calcAntenna *a, const Pathology *p,
00219 const Double &L0, Complex *Er, Complex *El,
00220 const Int &i, const Int &j);
00221 void computePixelValues(const ApertureCalcParams *ap,
00222 const calcAntenna *a, const Pathology *p,
00223 const Double &L0,
00224 Complex *Er, Complex *El,
00225 const Int &i, const Int &j,
00226 const Int& whichStokes);
00227 void computePixelValuesLinPol(const ApertureCalcParams *ap,
00228 const calcAntenna *a, const Pathology *p,
00229 const Double &L0,
00230 Complex *Ex, Complex *Ey,
00231 const Int &i, const Int &j,
00232 const Int& whichStokes);
00233
00234 inline void norm3(Double *v)
00235 {
00236 Double s;
00237 s = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
00238 v[0] /= s;
00239 v[1] /= s;
00240 v[2] /= s;
00241 }
00242
00243 calcAntenna *newAntenna(Double sub_h, Double feed_x, Double feed_y, Double feed_z,
00244 Double ftaper, Double thmax, const char *geomfile);
00245
00246 void deleteAntenna(calcAntenna *a);
00247
00248 void Antennasetfreq(calcAntenna *a, Double freq);
00249
00250 void Antennasetdir(calcAntenna *a, const Double *dir);
00251
00252
00253 void alignfeed(calcAntenna *a, const Pathology *p);
00254
00255 void getfeedbasis(const calcAntenna *a, Double B[3][3]);
00256
00257 void Efield(const calcAntenna *a, const Complex *pol, Complex *E);
00258
00259 Int Antennasetfeedpattern(calcAntenna *a, const char *filename, Double scale);
00260
00261 calcAntenna *newAntennafromApertureCalcParams(ApertureCalcParams *ap);
00262
00263 Int dishvalue(const calcAntenna *a, Double r, Double *z, Double *m);
00264
00265 Int astigdishvalue(const calcAntenna *a, Double x, Double y, Double *z, Double *m);
00266
00267
00268
00269 Int subfromdish(const calcAntenna *a, Double x, Double y, Double *subpoint);
00270
00271 Int dishfromsub(const calcAntenna *a, Double x, Double y, Double *dishpoint);
00272
00273 void printAntenna(const calcAntenna *a);
00274
00275 Ray* newRay(const Double *sub);
00276
00277 void deleteRay(Ray *ray);
00278
00279 Pathology* newPathology();
00280
00281 Pathology* newPathologyfromApertureCalcParams(ApertureCalcParams *ap);
00282
00283 void deletePathology(Pathology *P);
00284
00285 void normvec(const Double *a, const Double *b, Double *c);
00286
00287 Double dAdOmega(const calcAntenna *a, const Ray *ray1, const Ray *ray2,
00288 const Ray *ray3, const Pathology *p);
00289
00290 Double dOmega(const calcAntenna *a, const Ray *ray1, const Ray *ray2,
00291 const Ray *ray3, const Pathology *p);
00292
00293 Double Raylen(const Ray *ray);
00294
00295 void Pathologize(Double *sub, const Pathology *p);
00296
00297 void applyPathology(Pathology *P, calcAntenna *a);
00298
00299 void intersectdish(const calcAntenna *a, const Double *sub, const Double *unitdir,
00300 Double *dish, Int niter);
00301
00302 void intersectaperture(const calcAntenna *a, const Double *dish,
00303 const Double *unitdir, Double *aper);
00304
00305 Double feedfunc(const calcAntenna *a, Double theta);
00306
00307 Double feedgain(const calcAntenna *a, const Ray *ray, const Pathology *p);
00308
00309 Ray* trace(const calcAntenna *a, Double x, Double y, const Pathology *p);
00310
00311 void tracepol(Complex *E0, const Ray *ray, Complex *E1);
00312
00313 Int legplanewaveblock(const calcAntenna *a, Double x, Double y);
00314
00315 Int legplanewaveblock2(const calcAntenna *a, const Ray *ray);
00316
00317 Int legsphericalwaveblock(const calcAntenna *a, const Ray *ray);
00318
00319 void copyBeamCalcGeometry(BeamCalcGeometry* to, BeamCalcGeometry* from);
00320
00321 static BeamCalc* instance_p;
00322
00323 String obsName_p;
00324 String antType_p;
00325 MEpoch obsTime_p;
00326 uInt BeamCalc_NumBandCodes_p;
00327 Vector<BeamCalcGeometry> BeamCalcGeometries_p;
00328 Vector<Double> bandMinFreq_p;
00329 Vector<Double> bandMaxFreq_p;
00330 String antRespPath_p;
00331
00332 static const Double METER_INCH;
00333 static const Double INCH_METER;
00334 static const Double NS_METER;
00335 static const Double METER_NS;
00336 static const Double DEG_RAD;
00337 static const Double RAD_DEG;
00338
00339 };
00340
00341 };
00342
00343 #endif