Line data Source code
1 : //# VPSkyJones.cc: Implementation for VPSkyJones
2 : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,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 <synthesis/TransformMachines/PBMath.h>
32 : #include <synthesis/TransformMachines/VPSkyJones.h>
33 :
34 : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
35 : #include <casacore/tables/Tables.h>
36 : #include <casacore/tables/Tables/TableRecord.h>
37 : #include <casacore/ms/MeasurementSets/MSColumns.h>
38 :
39 : #include <casacore/measures/Measures/Stokes.h>
40 :
41 : #include <casacore/casa/BasicSL/Constants.h>
42 :
43 : #include <components/ComponentModels/Flux.h>
44 : #include <components/ComponentModels/ComponentShape.h>
45 :
46 : #include <msvis/MSVis/VisBuffer.h>
47 : #include <casacore/images/Images/ImageInterface.h>
48 : #include <casacore/lattices/Lattices/LatticeStepper.h>
49 : #include <casacore/lattices/Lattices/LatticeIterator.h>
50 :
51 : #include <casacore/coordinates/Coordinates/CoordinateSystem.h>
52 : #include <casacore/coordinates/Coordinates/DirectionCoordinate.h>
53 : #include <casacore/coordinates/Coordinates/SpectralCoordinate.h>
54 : #include <casacore/coordinates/Coordinates/StokesCoordinate.h>
55 : #include <casacore/coordinates/Coordinates/Projection.h>
56 :
57 : #include <casacore/casa/Utilities/Assert.h>
58 :
59 : using namespace casacore;
60 : namespace casa { //# NAMESPACE CASA - BEGIN
61 :
62 0 : VPSkyJones::VPSkyJones(const MSColumns& msc, Table& tab,
63 : const Quantity &parAngleInc,
64 : BeamSquint::SquintType doSquint,
65 0 : const Quantity &skyPositionThreshold)
66 0 : : BeamSkyJones(parAngleInc, doSquint,skyPositionThreshold)
67 : {
68 0 : LogIO os(LogOrigin("VPSkyJones", "VPSkyJones"));
69 :
70 0 : const uInt nrow = tab.nrow();
71 :
72 0 : ScalarColumn<String> telCol(tab, "telescope");
73 0 : ScalarColumn<Int> antCol(tab, "antenna");
74 0 : ScalarColumn<TableRecord> recCol(tab, "pbdescription");
75 :
76 :
77 0 : for (uInt i=0; i < nrow; ++i) {
78 : // if-operator condition checks that the names are not redundant
79 0 : if (indexTelescope(telCol(i))<0) {
80 :
81 :
82 :
83 :
84 0 : String name;
85 0 : String commonpb;
86 0 : if(recCol(i).isDefined("name") && (recCol(i).asString("name") != "REFERENCE")){
87 :
88 0 : const Int nameFieldNumber=recCol(i).fieldNumber("name");
89 0 : if (nameFieldNumber!=-1)
90 0 : recCol(i).get(nameFieldNumber,name);
91 :
92 0 : if (name == "COMMONPB") {
93 0 : const Int commonPBFieldNumber=recCol(i).fieldNumber("commonpb");
94 0 : AlwaysAssert(commonPBFieldNumber!=-1,AipsError);
95 0 : recCol(i).get(commonPBFieldNumber, commonpb );
96 : }
97 :
98 0 : if (commonpb == "DEFAULT") {
99 0 : String band;
100 : PBMath::CommonPB whichPB;
101 0 : String commonPBName;
102 0 : ScalarColumn<String> telescopesCol(msc.observation().telescopeName());
103 0 : Quantity freq( msc.spectralWindow().refFrequency()(0), "Hz");
104 0 : String tele = telCol(i);
105 0 : if(tele=="") {
106 : os << "Telescope name for row " << i << " of " << tab.tableName()
107 0 : << " is blank : cannot find correct primary beam model" << LogIO::EXCEPTION;
108 : }
109 : else {
110 0 : PBMath::whichCommonPBtoUse( tele, freq, band, whichPB, commonPBName );
111 : }
112 :
113 0 : PBMath myPBMath(tele, false, freq );
114 0 : setPBMath (telCol(i), myPBMath);
115 :
116 0 : } else {
117 0 : PBMath myPBMath( recCol(i));
118 0 : setPBMath (telCol(i), myPBMath);
119 0 : }
120 : }
121 :
122 0 : }
123 :
124 : }
125 0 : };
126 :
127 :
128 0 : VPSkyJones::VPSkyJones(const MSColumns& msc,
129 : Bool makePBs,
130 : const Quantity &parAngleInc,
131 : BeamSquint::SquintType doSquint,
132 0 : const Quantity &skyPositionThreshold)
133 0 : : BeamSkyJones(parAngleInc, doSquint, skyPositionThreshold)
134 : {
135 0 : LogIO os(LogOrigin("VPSkyJones", "VPSkyJones"));
136 :
137 0 : if (makePBs) {
138 0 : ScalarColumn<String> telescopesCol(msc.observation().telescopeName());
139 :
140 :
141 0 : for (uInt i=0; i < telescopesCol.nrow(); ++i) {
142 0 : telescope_p = telescopesCol(i);
143 : // if-operator condition checks that the names are not redundant
144 0 : if (indexTelescope(telescope_p)<0) {
145 : // Ultimately, we need to get the Beam parameters from the MS.beamSubTable,
146 : // but until then we will use this: figure it out from Telescope and Freq
147 0 : String band;
148 : PBMath::CommonPB whichPB;
149 0 : String commonPBName;
150 : // This frequency is ONLY required to determine which PB model to use:
151 : // The VLA, the ATNF, and WSRT have frequency - dependent PB models
152 0 : Quantity freq( msc.spectralWindow().refFrequency()(0), "Hz");
153 :
154 0 : if((telescope_p==" ") || (telescope_p=="")) {
155 0 : whichPB=PBMath::UNKNOWN;
156 : }
157 : else {
158 0 : PBMath::whichCommonPBtoUse( telescope_p, freq, band, whichPB, commonPBName );
159 : }
160 :
161 0 : if(whichPB != PBMath::UNKNOWN){
162 0 : String PBName;
163 : // close the circle and see if its getting the PB that was intended
164 0 : PBMath::nameCommonPB(whichPB,PBName);
165 0 : os << "PB used " << PBName << LogIO::POST;
166 0 : PBMath myPBMath(telescope_p, false, freq );
167 0 : setPBMath (telescope_p, myPBMath);
168 0 : }
169 : else{
170 : // lets do it by diameter
171 0 : Double diam=msc.antenna().dishDiameter()(0);
172 0 : os << "PB determined from first dish-diameter = "<<diam << LogIO::POST;
173 0 : PBMath myPBMath(diam, false, freq);
174 0 : setPBMath(telescope_p, myPBMath);
175 :
176 0 : }
177 :
178 0 : }
179 : }
180 0 : }
181 0 : };
182 :
183 :
184 0 : VPSkyJones::VPSkyJones(const String& telescope,
185 : PBMath::CommonPB commonPBType,
186 : const Quantity &parAngleInc,
187 : BeamSquint::SquintType doSquint,
188 0 : const Quantity &skyPositionThreshold)
189 0 : : BeamSkyJones(parAngleInc, doSquint,skyPositionThreshold)
190 : {
191 0 : LogIO os(LogOrigin("VPSkyJones", "VPSkyJones"));
192 :
193 :
194 : // we need a way to do this for multiple telescope cases
195 0 : String telescope_p = telescope;
196 0 : PBMath myPBMath(commonPBType);
197 0 : setPBMath (telescope_p, myPBMath);
198 :
199 0 : };
200 :
201 :
202 :
203 :
204 0 : VPSkyJones::VPSkyJones(const String& telescope,
205 : PBMath& myPBMath,
206 : const Quantity &parAngleInc,
207 : BeamSquint::SquintType doSquint,
208 0 : const Quantity &skyPositionThreshold)
209 0 : : BeamSkyJones(parAngleInc, doSquint,skyPositionThreshold)
210 : {
211 0 : LogIO os(LogOrigin("VPSkyJones", "VPSkyJones"));
212 :
213 :
214 : // we need a way to do this for multiple telescope cases
215 0 : String telescope_p = telescope;
216 0 : setPBMath (telescope_p, myPBMath);
217 :
218 0 : };
219 :
220 :
221 :
222 : } //# NAMESPACE CASA - END
223 :
|