Line data Source code
1 : //# PBMath1DIPoly.cc: Implementation for PBMath1DIPoly
2 : //# Copyright (C) 1996,1997,1998,1999,2003
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: casa-feedback@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 : #include <casacore/casa/aips.h>
30 : #include <casacore/casa/BasicSL/Complex.h>
31 : #include <casacore/casa/BasicMath/Math.h>
32 : #include <synthesis/TransformMachines/PBMath1DIPoly.h>
33 : #include <casacore/casa/Quanta.h>
34 : #include <casacore/measures/Measures.h>
35 :
36 :
37 :
38 : using namespace casacore;
39 : namespace casa { //# NAMESPACE CASA - BEGIN
40 :
41 0 : PBMath1DIPoly::PBMath1DIPoly(const Vector<Double>& coeff, Quantity maxRad,
42 : Quantity refFreq,
43 : Bool isThisVP,
44 : BeamSquint squint,
45 0 : Bool useSymmetricBeam) :
46 : PBMath1D(maxRad, refFreq, isThisVP, squint, useSymmetricBeam),
47 0 : coeff_p(coeff)
48 : {
49 0 : fillPBArray();
50 :
51 0 : if (useSymmetricBeam) {
52 0 : symmetrizeSquintedBeam();
53 : }
54 0 : };
55 :
56 0 : PBMath1DIPoly::PBMath1DIPoly(const Matrix<Double>& coeff,
57 : const Vector<Double>& freqs, Quantity maxRad,
58 : Quantity refFreq,
59 : Bool isThisVP,
60 : BeamSquint squint,
61 0 : Bool useSymmetricBeam) :
62 : PBMath1D(maxRad, refFreq, isThisVP, squint, useSymmetricBeam),
63 0 : wbcoeff_p(coeff)
64 : {
65 0 : wFreqs_p=freqs;
66 0 : wideFit_p = true;
67 0 : if (coeff.ncolumn()!=freqs.nelements()) {
68 0 : throw(AipsError("PBMath1DIPoly:: - coeff and freqs arguments do not match"));
69 : }
70 0 : fillPBArray();
71 :
72 0 : if (useSymmetricBeam) {
73 0 : symmetrizeSquintedBeam();
74 : }
75 0 : };
76 :
77 :
78 :
79 0 : PBMath1DIPoly::~PBMath1DIPoly()
80 : {
81 0 : };
82 :
83 :
84 0 : PBMath1DIPoly& PBMath1DIPoly::operator=(const PBMath1DIPoly& other)
85 : {
86 0 : if (this == &other)
87 0 : return *this;
88 :
89 0 : PBMath1D::operator=(other);
90 0 : coeff_p = other.coeff_p;
91 0 : wbcoeff_p = other.wbcoeff_p;
92 0 : return *this;
93 : };
94 :
95 :
96 :
97 :
98 0 : void PBMath1DIPoly::fillPBArray()
99 : {
100 :
101 0 : LogIO os(LogOrigin("PBMath1DIPoly", "fillPBArray"));
102 0 : uInt nSamples=10000;
103 0 : vp_p.resize(nSamples);
104 0 : Int nfreq = wFreqs_p.nelements();
105 0 : bool wide = nfreq>0;
106 0 : if (wide) wbvp_p.resize(nSamples,nfreq);
107 0 : if (wide) os << "Using wideband interpolated beam pattern"<<LogIO::NORMAL;
108 :
109 0 : inverseIncrementRadius_p=Double(nSamples-1)/maximumRadius_p.getValue("'");
110 : Double x2; Double y;
111 : Double taper;
112 0 : for(Int n=0; n<max(1,nfreq); n++) {
113 0 : for(uInt i=0;i<nSamples;i++) {
114 0 : taper = 0.0;
115 0 : x2 = square( (Double(i)/inverseIncrementRadius_p) );
116 0 : y = 1;
117 0 : if (wide) {
118 0 : for (uInt j=0; j<wbcoeff_p.nrow(); j++) {
119 0 : taper += y * wbcoeff_p(j,n);
120 0 : y *= x2;
121 : }
122 : } else {
123 0 : for (uInt j=0;j<coeff_p.nelements();j++) {
124 0 : taper += y * coeff_p(j);
125 0 : y *= x2;
126 : }
127 : }
128 0 : if (taper != 0.0) {
129 0 : if (isThisVP_p) {
130 0 : taper = 1.0/taper;
131 : } else {
132 0 : taper = 1.0/sqrt(taper);
133 : }
134 : }
135 0 : if (wide) {
136 0 : wbvp_p(i,n) = taper;
137 : } else {
138 0 : vp_p(i) = taper;
139 : }
140 : }
141 : }
142 0 : };
143 :
144 :
145 : // Bool PBMath1DIPoly::flushToTable(Table& beamSubTable, Int iRow)
146 : // {};
147 :
148 :
149 : void
150 0 : PBMath1DIPoly::summary(Int nValues)
151 : {
152 0 : PBMath1D::summary(nValues);
153 0 : LogIO os(LogOrigin("PBMath1DIPoly", "summary"));
154 0 : Int nfreq = wFreqs_p.nelements();
155 0 : if (nfreq==0) {
156 0 : os << "Even Powered Coefficients: " << coeff_p << LogIO::POST;
157 : } else {
158 0 : for (Int i=0; i<nfreq; i++) {
159 0 : os << " Even Powered Coefficients for "<<wFreqs_p(i)/1e9<<" GHz: "<<wbcoeff_p.column(i)
160 0 : << endl;
161 : }
162 0 : os << LogIO::POST;
163 : }
164 0 : };
165 :
166 : } //# NAMESPACE CASA - END
167 :
|