Line data Source code
1 : //# VLAIlluminationConvFunc.h: Definition for VLAIlluminationConvFunc
2 : //# Copyright (C) 1996,1997,1998,1999,2000,2002
3 : //# Associated Universities, Inc. Washington DC, USA.
4 : //#
5 : //# This library is free software; you can redistribute it and/or modify it
6 : //# under the terms of the GNU Library General Public License as published by
7 : //# the Free Software Foundation; either version 2 of the License, or (at your
8 : //# option) any later version.
9 : //#
10 : //# This library is distributed in the hope that it will be useful, but WITHOUT
11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 : //# License for more details.
14 : //#
15 : //# You should have received a copy of the GNU Library General Public License
16 : //# along with this library; if not, write to the Free Software Foundation,
17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 : //#
19 : //# Correspondence concerning AIPS++ should be adressed as follows:
20 : //# Internet email: aips2-request@nrao.edu.
21 : //# Postal address: AIPS++ Project Office
22 : //# National Radio Astronomy Observatory
23 : //# 520 Edgemont Road
24 : //# Charlottesville, VA 22903-2475 USA
25 : //#
26 : //#
27 : //# $Id$
28 :
29 : #ifndef SYNTHESIS_BEAMCALC_H
30 : #define SYNTHESIS_BEAMCALC_H
31 :
32 : //#include <casa/complex.h>
33 : #include <casacore/images/Images/TempImage.h>
34 : #include <casacore/casa/Exceptions.h>
35 : #include <casacore/casa/Logging/LogIO.h>
36 :
37 : namespace casa
38 : {
39 :
40 : #define MAXGEOM 2000
41 :
42 : typedef struct /* all dimensions in meters, GHz */
43 : {
44 : char name[16]; /* name of antenna, e.g., VLA */
45 : char bandName[16];
46 : casacore::Double sub_h; /* subreflector vertex height above primary vertex */
47 : casacore::Double feedpos[3]; /* position of feed */
48 : casacore::Double subangle; /* angle subtended by the subreflector */
49 : casacore::Double legwidth; /* strut width */
50 : casacore::Double legfoot; /* distance from optic axis of leg foot */
51 : casacore::Double legapex; /* hight of leg intersection */
52 : casacore::Double Rhole; /* radius of central hole */
53 : casacore::Double Rant; /* antenna radius */
54 : casacore::Double reffreq; /* a reference frequency */
55 : casacore::Double taperpoly[5]; /* polynomial expanded about reffreq */
56 : casacore::Int ntaperpoly; /* number of terms in polynomial */
57 :
58 : casacore::Double astigm_0; /* astigmatism: coefficient of Zernike Polyn. Z6 a.k.a. 0-90 */
59 : casacore::Double astigm_45; /* astigmatism: coefficient of Zernike Polyn. Z5 a.k.a. 45-135 */
60 :
61 : /* to be added later
62 : casacore::Double focus;
63 : casacore::Double dfeedpos[3];
64 : casacore::Double dsub_z;
65 : */
66 : } BeamCalcGeometry;
67 :
68 : typedef struct
69 : {
70 : casacore::Int oversamp; /* average this many points per cell */
71 : casacore::TempImage<casacore::Complex> *aperture; /* Jones planes [Nx,Ny,NStokes,NFreq]*/
72 : casacore::Double x0, y0; /* center of cell 0, 0, meters */
73 : casacore::Double dx, dy; /* increment in meters */
74 : casacore::Int nx, ny; /* calculation plane size in cells */
75 : /* last cell is at coordinates:
76 : X = x0 + (nx-1)*dx
77 : Y = y0 + (ny-1)*dy
78 : */
79 : casacore::Double pa; /* Parallactic angle, radians */
80 : casacore::Double freq; /* GHz */
81 : casacore::Int band;
82 : } ApertureCalcParams;
83 :
84 : /*
85 : * calcAntenna parameters
86 : */
87 : typedef struct
88 : {
89 : casacore::Double sub_h; /* height of subreflector (on axis) */
90 : casacore::Double feed[3]; /* position of the feed */
91 : casacore::Double feeddir[3]; /* unit vector pointing along feed */
92 : casacore::Double pfeeddir[3]; /* same as above after pathology applied */
93 : casacore::Double radius; /* antenna radius (m) */
94 : casacore::Double K;
95 : casacore::Double deltar;
96 : casacore::Double zedge; /* height at the edge of the dish */
97 : casacore::Double bestparabola; /* best fit parabola quadratic coef */
98 : casacore::Double ftaper; /* taper of feed */
99 : casacore::Double thmax; /* maximum angle of feed */
100 : casacore::Double fa2pi;
101 : casacore::Double legwidth;
102 : casacore::Double legfoot, legfootz;
103 : casacore::Double legapex;
104 : casacore::Double legthick;
105 : casacore::Double hole_radius;
106 : casacore::Double freq, lambda;
107 : casacore::Double astigm_0; /* astigmatism: coefficient of Zernike Polyn. Z6 a.k.a. 0-90 */
108 : casacore::Double astigm_45; /* astigmatism: coefficient of Zernike Polyn. Z5 a.k.a. 45-135 */
109 : casacore::Double dir[3];
110 : casacore::Double hhat[3], vhat[3]; /* unit vectors orthogonal to dir */
111 : casacore::Double z[MAXGEOM];
112 : casacore::Double m[MAXGEOM];
113 : casacore::Double k[3];
114 : casacore::Int ngeom;
115 : char name[16];
116 : casacore::Int gridsize;
117 : } calcAntenna;
118 :
119 : typedef struct
120 : {
121 : casacore::Double subrot[3][3]; /* 3x3 matrix rotating x,y,z or nx,ny,nz */
122 : casacore::Double feedrot[3][3]; /* 3x3 matrix rotating x,y,z or nx,ny,nz */
123 : casacore::Double subshift[3]; /* 3 length vector */
124 : casacore::Double feedshift[3]; /* 3 length vector */
125 : casacore::Double subrotpoint[3]; /* 3 vector describing point to rotate sub. */
126 : casacore::Double az_offset; /* azimuth pointing offset (radians) */
127 : casacore::Double el_offset; /* elevation pointing offset (radians) */
128 : casacore::Double phase_offset; /* DC offset in phase (radians) */
129 : casacore::Double focus; /* meters out of focus toward subreflector */
130 : } Pathology;
131 :
132 : typedef struct
133 : {
134 : casacore::Double aper[6]; /* aperture x, y, z, nx, ny, nz */
135 : casacore::Double dish[6]; /* dish x, y, z, nx, ny, nz */
136 : casacore::Double sub[6]; /* subreflector x, y, z, nx, ny, nz */
137 : casacore::Double feed[3]; /* feed x, y, z */
138 : } Ray;
139 :
140 : enum VLABeamCalcBandCode{
141 : BeamCalc_VLA_L = 0,
142 : BeamCalc_VLA_C,
143 : BeamCalc_VLA_X,
144 : BeamCalc_VLA_U,
145 : BeamCalc_VLA_K,
146 : BeamCalc_VLA_Q,
147 : BeamCalc_VLA_4,
148 :
149 : VLABeamCalc_NumBandCodes /* this line last */
150 : };
151 :
152 : enum EVLABeamCalcBandCode{
153 : BeamCalc_EVLA_L = 0,
154 : BeamCalc_EVLA_S,
155 : BeamCalc_EVLA_C,
156 : BeamCalc_EVLA_X,
157 : BeamCalc_EVLA_U,
158 : BeamCalc_EVLA_K,
159 : BeamCalc_EVLA_A,
160 : BeamCalc_EVLA_Q,
161 : BeamCalc_EVLA_4,
162 :
163 : EVLABeamCalc_NumBandCodes /* this line last */
164 : };
165 :
166 :
167 : enum ALMABeamCalcBandCode{
168 : BeamCalc_ALMA_1 = 0,
169 : BeamCalc_ALMA_2,
170 : BeamCalc_ALMA_3,
171 : BeamCalc_ALMA_4,
172 : BeamCalc_ALMA_5,
173 : BeamCalc_ALMA_6,
174 : BeamCalc_ALMA_7,
175 : BeamCalc_ALMA_8,
176 : BeamCalc_ALMA_9,
177 : BeamCalc_ALMA_10,
178 :
179 : ALMABeamCalc_NumBandCodes /* this line last */
180 : };
181 :
182 : extern casacore::Double VLABandMinFreqDefaults[VLABeamCalc_NumBandCodes];
183 : extern casacore::Double VLABandMaxFreqDefaults[VLABeamCalc_NumBandCodes];
184 : extern BeamCalcGeometry VLABeamCalcGeometryDefaults[VLABeamCalc_NumBandCodes];
185 : extern casacore::Double EVLABandMinFreqDefaults[EVLABeamCalc_NumBandCodes];
186 : extern casacore::Double EVLABandMaxFreqDefaults[EVLABeamCalc_NumBandCodes];
187 : extern BeamCalcGeometry EVLABeamCalcGeometryDefaults[EVLABeamCalc_NumBandCodes];
188 : extern casacore::Double ALMABandMinFreqDefaults[ALMABeamCalc_NumBandCodes];
189 : extern casacore::Double ALMABandMaxFreqDefaults[ALMABeamCalc_NumBandCodes];
190 : extern BeamCalcGeometry ALMABeamCalcGeometryDefaults[ALMABeamCalc_NumBandCodes];
191 :
192 : class BeamCalc
193 : {
194 : public:
195 :
196 : // This is a SINGLETON class
197 : static BeamCalc* Instance();
198 :
199 : void setBeamCalcGeometries(const casacore::String& obsName, // (the observatory name, e.g. "ALMA" or "ACA")
200 : const casacore::String& antennaType = "STANDARD",
201 : const casacore::MEpoch& obsTime = casacore::MEpoch(casacore::Quantity(50000., "d")),
202 : const casacore::String& otherAntRayPath=""); // override the AntennaResponses casacore::Table in Observatories
203 :
204 : casacore::Int getBandID(const casacore::Double freq, // in Hz
205 : const casacore::String& obsname,
206 : const casacore::String& bandName,
207 : const casacore::String& antennaType="STANDARD",
208 : const casacore::MEpoch& obsTime = casacore::MEpoch(casacore::Quantity(50000., "d")),
209 : const casacore::String& otherAntRayPath=""); // override the AntennaResponses casacore::Table in Observatories
210 :
211 : casacore::Int calculateAperture(ApertureCalcParams *ap);
212 : casacore::Int calculateAperture(ApertureCalcParams *ap, const casacore::Int& whichStokes);
213 : casacore::Int calculateApertureLinPol(ApertureCalcParams *ap, const casacore::Int& whichStokes);
214 :
215 : protected:
216 : BeamCalc();
217 :
218 : private:
219 :
220 : void computePixelValues(const ApertureCalcParams *ap, const calcAntenna *a, const Pathology *p,
221 : const casacore::Double &L0, casacore::Complex *Er, casacore::Complex *El,
222 : const casacore::Int &i, const casacore::Int &j);
223 : void computePixelValues(const ApertureCalcParams *ap,
224 : const calcAntenna *a, const Pathology *p,
225 : const casacore::Double &L0,
226 : casacore::Complex *Er, casacore::Complex *El,
227 : const casacore::Int &i, const casacore::Int &j,
228 : const casacore::Int& whichStokes);
229 : void computePixelValuesLinPol(const ApertureCalcParams *ap,
230 : const calcAntenna *a, const Pathology *p,
231 : const casacore::Double &L0,
232 : casacore::Complex *Ex, casacore::Complex *Ey,
233 : const casacore::Int &i, const casacore::Int &j,
234 : const casacore::Int& whichStokes);
235 : //normalizes a "vector" of 3 Doubles in the vector sense
236 0 : inline void norm3(casacore::Double *v)
237 : {
238 : casacore::Double s;
239 0 : s = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
240 0 : v[0] /= s;
241 0 : v[1] /= s;
242 0 : v[2] /= s;
243 0 : }
244 :
245 : calcAntenna *newAntenna(casacore::Double sub_h, casacore::Double feed_x, casacore::Double feed_y, casacore::Double feed_z,
246 : casacore::Double ftaper, casacore::Double thmax, const char *geomfile);
247 :
248 : void deleteAntenna(calcAntenna *a);
249 :
250 : void Antennasetfreq(calcAntenna *a, casacore::Double freq);
251 :
252 : void Antennasetdir(calcAntenna *a, const casacore::Double *dir);
253 :
254 : // sets feeddir after pathology is considered
255 : void alignfeed(calcAntenna *a, const Pathology *p);
256 :
257 : void getfeedbasis(const calcAntenna *a, casacore::Double B[3][3]);
258 :
259 : void Efield(const calcAntenna *a, const casacore::Complex *pol, casacore::Complex *E);
260 :
261 : casacore::Int Antennasetfeedpattern(calcAntenna *a, const char *filename, casacore::Double scale);
262 :
263 : calcAntenna *newAntennafromApertureCalcParams(ApertureCalcParams *ap);
264 :
265 : casacore::Int dishvalue(const calcAntenna *a, casacore::Double r, casacore::Double *z, casacore::Double *m);
266 :
267 : casacore::Int astigdishvalue(const calcAntenna *a, casacore::Double x, casacore::Double y, casacore::Double *z, casacore::Double *m);
268 :
269 : // Returns position of subreflector piece (x, y, z) and
270 : // its normal (u, v, w)
271 : casacore::Int subfromdish(const calcAntenna *a, casacore::Double x, casacore::Double y, casacore::Double *subpoint);
272 :
273 : casacore::Int dishfromsub(const calcAntenna *a, casacore::Double x, casacore::Double y, casacore::Double *dishpoint);
274 :
275 : void printAntenna(const calcAntenna *a);
276 :
277 : Ray* newRay(const casacore::Double *sub);
278 :
279 : void deleteRay(Ray *ray);
280 :
281 : Pathology* newPathology();
282 :
283 : Pathology* newPathologyfromApertureCalcParams(ApertureCalcParams *ap);
284 :
285 : void deletePathology(Pathology *P);
286 :
287 : void normvec(const casacore::Double *a, const casacore::Double *b, casacore::Double *c);
288 :
289 : casacore::Double dAdOmega(const calcAntenna *a, const Ray *ray1, const Ray *ray2,
290 : const Ray *ray3, const Pathology *p);
291 :
292 : casacore::Double dOmega(const calcAntenna *a, const Ray *ray1, const Ray *ray2,
293 : const Ray *ray3, const Pathology *p);
294 :
295 : casacore::Double Raylen(const Ray *ray);
296 :
297 : void Pathologize(casacore::Double *sub, const Pathology *p);
298 :
299 : void applyPathology(Pathology *P, calcAntenna *a);
300 :
301 : void intersectdish(const calcAntenna *a, const casacore::Double *sub, const casacore::Double *unitdir,
302 : casacore::Double *dish, casacore::Int niter);
303 :
304 : void intersectaperture(const calcAntenna *a, const casacore::Double *dish,
305 : const casacore::Double *unitdir, casacore::Double *aper);
306 :
307 : casacore::Double feedfunc(const calcAntenna *a, casacore::Double theta);
308 :
309 : casacore::Double feedgain(const calcAntenna *a, const Ray *ray, const Pathology *p);
310 :
311 : Ray* trace(const calcAntenna *a, casacore::Double x, casacore::Double y, const Pathology *p);
312 :
313 : void tracepol(casacore::Complex *E0, const Ray *ray, casacore::Complex *E1);
314 :
315 : casacore::Int legplanewaveblock(const calcAntenna *a, casacore::Double x, casacore::Double y);
316 :
317 : casacore::Int legplanewaveblock2(const calcAntenna *a, const Ray *ray);
318 :
319 : casacore::Int legsphericalwaveblock(const calcAntenna *a, const Ray *ray);
320 :
321 : void copyBeamCalcGeometry(BeamCalcGeometry* to, BeamCalcGeometry* from);
322 :
323 : static BeamCalc* instance_p;
324 :
325 : casacore::String obsName_p;
326 : casacore::String antType_p;
327 : casacore::MEpoch obsTime_p;
328 : casacore::uInt BeamCalc_NumBandCodes_p;
329 : casacore::Vector<BeamCalcGeometry> BeamCalcGeometries_p;
330 : casacore::Vector<casacore::Double> bandMinFreq_p; // in Hz
331 : casacore::Vector<casacore::Double> bandMaxFreq_p; // in Hz
332 : casacore::String antRespPath_p;
333 :
334 : static const casacore::Double METER_INCH;
335 : static const casacore::Double INCH_METER;
336 : static const casacore::Double NS_METER;
337 : static const casacore::Double METER_NS;
338 : static const casacore::Double DEG_RAD;
339 : static const casacore::Double RAD_DEG;
340 :
341 : };
342 :
343 : };
344 :
345 : #endif
|