Line data Source code
1 : //# CalDescBuffer.cc: Implementation of CalDescBuffer.h 2 : //# Copyright (C) 1996,1997,1998,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 addressed 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 : //# $Id$ 27 : //---------------------------------------------------------------------------- 28 : 29 : #include <synthesis/CalTables/CalDescBuffer.h> 30 : 31 : using namespace casacore; 32 : namespace casa { //# NAMESPACE CASA - BEGIN 33 : 34 : //---------------------------------------------------------------------------- 35 : 36 1 : CalDescBuffer::CalDescBuffer() : 37 1 : connectedToIter_p(false), calDescCol_p(NULL) 38 : { 39 : // Null constructor 40 : // Output to private data: 41 : // connectedToIter_p Bool true if connected to iterator 42 : // calDescCol_p CalDescColumns* Ptr to cal_desc col accessor 43 : // numSpw_p Vector<Int> No. spw 44 : // numChan_p Vector<Int> No. chan 45 : // numReceptors_p Vector<Int> No. receptors 46 : // nJones_p Vector<Int> Jones matrix size 47 : // spwId_p Matrix<Int> Spw. id.'s 48 : // chanFreqMeas_p Array<MFrequency> Chan. freq. as Measure 49 : // measFreqRef_p Vector<Int> Freq. measures ref. 50 : // chanWidthQuant_p Array<Quantity> Chan. width as Quanta 51 : // chanRange_p Array<Int> Chan. range 52 : // polznType_p Matrix<String> Polzn. type 53 : // jonesType_p Vector<String> Jones matrix type 54 : // msName_p Vector<String> MeasurementSet name 55 : // numSpwOK_p Bool No. spw cache ok 56 : // numChanOK_p Bool No. chan cache ok 57 : // numReceptorsOK_p Bool No. receptors cache ok 58 : // nJonesOK_p Bool Jones matrix size cache ok 59 : // spwIdOK_p Bool Spw. id.'s cache ok 60 : // chanFreqMeasOK_p Bool Chan. freq. as Measure cache ok 61 : // measFreqRefOK_p Bool Freq. measures ref. cache ok 62 : // chanWidthQuantOK_p Bool Chan. width as Quanta cache ok 63 : // chanRangeOK_p Bool Chan. range cache ok 64 : // polznTypeOK_p Bool Polzn. type cache ok 65 : // jonesTypeOK_p Bool Jones matrix type cache ok 66 : // msNameOK_p Bool MeasurementSet name cache ok 67 : // 68 : // Invalidate cache 69 1 : invalidate(); 70 1 : }; 71 : 72 : //---------------------------------------------------------------------------- 73 : 74 0 : CalDescBuffer::CalDescBuffer (CalIterBase& calIter) : 75 0 : connectedToIter_p(true), calDescCol_p(NULL) 76 : { 77 : // Construct from a calibration table iterator 78 : // Input: 79 : // calIter CalIterBase& Calibration table iterator 80 : // Output to private data: 81 : // connectedToIter_p Bool true if connected to iterator 82 : // calDescCol_p CalDescColumns* Ptr to cal_desc col accessor 83 : // numSpw_p Vector<Int> No. spw 84 : // numChan_p Vector<Int> No. chan 85 : // numReceptors_p Vector<Int> No. receptors 86 : // nJones_p Vector<Int> Jones matrix size 87 : // spwId_p Matrix<Int> Spw. id.'s 88 : // chanFreqMeas_p Array<MFrequency> Chan. freq. as Measure 89 : // measFreqRef_p Vector<Int> Freq. measures ref. 90 : // chanWidthQuant_p Array<Quantity> Chan. width as Quanta 91 : // chanRange_p Array<Int> Chan. range 92 : // polznType_p Matrix<String> Polzn. type 93 : // jonesType_p Vector<String> Jones matrix type 94 : // msName_p Vector<String> MeasurementSet name 95 : // numSpwOK_p Bool No. spw cache ok 96 : // numChanOK_p Bool No. chan cache ok 97 : // numReceptorsOK_p Bool No. receptors cache ok 98 : // nJonesOK_p Bool Jones matrix size cache ok 99 : // spwIdOK_p Bool Spw. id.'s cache ok 100 : // chanFreqMeasOK_p Bool Chan. freq. as Measure cache ok 101 : // measFreqRefOK_p Bool Freq. measures ref. cache ok 102 : // chanWidthQuantOK_p Bool Chan. width as Quanta cache ok 103 : // chanRangeOK_p Bool Chan. range cache ok 104 : // polznTypeOK_p Bool Polzn. type cache ok 105 : // jonesTypeOK_p Bool Jones matrix type cache ok 106 : // msNameOK_p Bool MeasurementSet name cache ok 107 : // 108 : // Invalidate cache 109 0 : invalidate(); 110 : 111 : // Construct the cal_desc column accessor 112 0 : calDescCol_p = newCalDescCol (calIter.subTable()); 113 0 : }; 114 : 115 : //---------------------------------------------------------------------------- 116 : 117 2 : CalDescBuffer::~CalDescBuffer() 118 : { 119 : // Destructor 120 : // Output to private data: 121 : // calDescCol_p CalDescColumns* Ptr to cal_desc col accessor 122 : // 123 1 : if (calDescCol_p) delete calDescCol_p; 124 2 : }; 125 : 126 : //---------------------------------------------------------------------------- 127 : 128 1 : void CalDescBuffer::invalidate() 129 : { 130 : // Invalidate the current cache 131 : // Output to private data: 132 : // numSpwOK_p Bool No. spw cache ok 133 : // numChanOK_p Bool No. chan cache ok 134 : // numReceptorsOK_p Bool No. receptors cache ok 135 : // nJonesOK_p Bool Jones matrix size cache ok 136 : // spwIdOK_p Bool Spw. id.'s cache ok 137 : // chanFreqMeasOK_p Bool Chan. freq. as Measure cache ok 138 : // measFreqRefOK_p Bool Freq. measures ref. cache ok 139 : // chanWidthQuantOK_p Bool Chan. width as Quanta cache ok 140 : // chanRangeOK_p Bool Chan. range cache ok 141 : // polznTypeOK_p Bool Polzn. type cache ok 142 : // jonesTypeOK_p Bool Jones matrix type cache ok 143 : // msNameOK_p Bool MeasurementSet name cache ok 144 : // 145 : // Set all cache flags to false 146 1 : numSpwOK_p = false; 147 1 : numChanOK_p = false; 148 1 : numReceptorsOK_p = false; 149 1 : nJonesOK_p = false; 150 1 : spwIdOK_p = false; 151 1 : chanFreqMeasOK_p = false; 152 1 : measFreqRefOK_p = false; 153 1 : chanWidthQuantOK_p = false; 154 1 : chanRangeOK_p = false; 155 1 : polznTypeOK_p = false; 156 1 : jonesTypeOK_p = false; 157 1 : msNameOK_p = false; 158 1 : }; 159 : 160 : //---------------------------------------------------------------------------- 161 : 162 0 : Vector<Int>& CalDescBuffer::numSpw() 163 : { 164 : // NUM_SPW data field accessor 165 : // Input from private data: 166 : // connectedToIter_p Bool true if connected to iterator 167 : // numSpw_p Vector<Int> No. spw 168 : // 169 : // Fill local cache for this column if cache not valid 170 0 : if (connectedToIter()) { 171 0 : if (!numSpwOK_p) { 172 0 : calDescCol()->numSpw().getColumn (numSpw_p); 173 0 : numSpwOK_p = true; 174 : }; 175 : }; 176 0 : return numSpw_p; 177 : }; 178 : 179 : //---------------------------------------------------------------------------- 180 : 181 0 : Vector<Int>& CalDescBuffer::numChan() 182 : { 183 : // NUM_CHAN data field accessor 184 : // Input from private data: 185 : // connectedToIter_p Bool true if connected to iterator 186 : // numChan_p Vector<Int> No. chan 187 : // 188 : // Fill local cache for this column if cache not valid 189 0 : if (connectedToIter()) { 190 0 : if (!numChanOK_p) { 191 0 : calDescCol()->numChan().getColumn (numChan_p); 192 0 : numChanOK_p = true; 193 : }; 194 : }; 195 0 : return numChan_p; 196 : }; 197 : 198 : //---------------------------------------------------------------------------- 199 : 200 0 : Vector<Int>& CalDescBuffer::numReceptors() 201 : { 202 : // NUM_RECEPTORS data field accessor 203 : // Input from private data: 204 : // connectedToIter_p Bool true if connected to iterator 205 : // numReceptors_p Vector<Int> No. receptors 206 : // 207 : // Fill local cache for this column if cache not valid 208 0 : if (connectedToIter()) { 209 0 : if (!numReceptorsOK_p) { 210 0 : calDescCol()->numReceptors().getColumn (numReceptors_p); 211 0 : numReceptorsOK_p = true; 212 : }; 213 : }; 214 0 : return numReceptors_p; 215 : }; 216 : 217 : //---------------------------------------------------------------------------- 218 : 219 0 : Vector<Int>& CalDescBuffer::nJones() 220 : { 221 : // N_JONES data field accessor 222 : // Input from private data: 223 : // connectedToIter_p Bool true if connected to iterator 224 : // nJones_p Vector<Int> No. spw 225 : // 226 : // Fill local cache for this column if cache not valid 227 0 : if (connectedToIter()) { 228 0 : if (!nJonesOK_p) { 229 0 : calDescCol()->nJones().getColumn (nJones_p); 230 0 : nJonesOK_p = true; 231 : }; 232 : }; 233 0 : return nJones_p; 234 : }; 235 : 236 : //---------------------------------------------------------------------------- 237 : 238 0 : Matrix<Int>& CalDescBuffer::spwId() 239 : { 240 : // NUM_SPW data field accessor 241 : // Input from private data: 242 : // connectedToIter_p Bool true if connected to iterator 243 : // spwId_p Vector<Int> Spw. id.'s 244 : // 245 : // Fill local cache for this column if cache not valid 246 0 : if (connectedToIter()) { 247 0 : if (!spwIdOK_p) { 248 0 : calDescCol()->spwId().getColumn (spwId_p); 249 0 : spwIdOK_p = true; 250 : }; 251 : }; 252 0 : return spwId_p; 253 : }; 254 : 255 : //---------------------------------------------------------------------------- 256 : 257 0 : Array<MFrequency>& CalDescBuffer::chanFreqMeas() 258 : { 259 : // CHAN_FREQ data field accessor 260 : // Input from private data: 261 : // connectedToIter_p Bool true if connected to iterator 262 : // chanFreqMeas_p Array<MFrequency> Chan. freq. as Measure 263 : // 264 : // Fill local cache for this column if cache not valid 265 0 : if (connectedToIter()) { 266 0 : if (!chanFreqMeasOK_p) { 267 0 : uInt nrow = calDescCol()->numSpw().nrow(); 268 : 269 : // Assume fixed shape for Array calibration columns 270 0 : Array<MFrequency> rowChanFreq; 271 0 : calDescCol()->chanFreqMeas().get (0, rowChanFreq); 272 0 : IPosition rowShape = rowChanFreq.shape(); 273 0 : rowShape.prepend (IPosition(1,nrow)); 274 0 : chanFreqMeas_p.resize(rowShape); 275 0 : IPosition start = rowShape; 276 : 277 0 : for (uInt row = 0; row < nrow; row++) { 278 0 : start(0) = row; 279 0 : calDescCol()->chanFreqMeas().get (row, rowChanFreq); 280 0 : chanFreqMeas_p(start,rowShape) = rowChanFreq.copy(); 281 : }; 282 0 : chanFreqMeasOK_p = true; 283 : }; 284 : }; 285 0 : return chanFreqMeas_p; 286 : }; 287 : 288 : //---------------------------------------------------------------------------- 289 : 290 0 : Vector<Int>& CalDescBuffer::measFreqRef() 291 : { 292 : // MEAS_FREQ_REF data field accessor 293 : // Input from private data: 294 : // connectedToIter_p Bool true if connected to iterator 295 : // measFreqRef_p Vector<Int> Measures freq. ref. 296 : // 297 : // Fill local cache for this column if cache not valid 298 0 : if (connectedToIter()) { 299 0 : if (!measFreqRefOK_p) { 300 0 : calDescCol()->measFreqRef().getColumn (measFreqRef_p); 301 0 : measFreqRefOK_p = true; 302 : }; 303 : }; 304 0 : return measFreqRef_p; 305 : }; 306 : 307 : //---------------------------------------------------------------------------- 308 : 309 0 : Array<Quantity>& CalDescBuffer::chanWidthQuant() 310 : { 311 : // CHAN_WIDTH data field accessor (as Quanta) 312 : // Input from private data: 313 : // connectedToIter_p Bool true if connected to iterator 314 : // chanWidthQuant_p Array<Quantity> Channel width as Quanta 315 : // 316 : // Fill local cache for this column if cache not valid 317 0 : if (connectedToIter()) { 318 0 : if (!chanWidthQuantOK_p) { 319 0 : uInt nrow = calDescCol()->numSpw().nrow(); 320 : 321 : // Assume fixed shape for Array calibration columns 322 0 : Array<Quantity> rowChanWidth; 323 0 : calDescCol()->chanWidthQuant().get (0, rowChanWidth); 324 0 : IPosition rowShape = rowChanWidth.shape(); 325 0 : rowShape.prepend (IPosition(1,nrow)); 326 0 : chanWidthQuant_p.resize(rowShape); 327 0 : IPosition start = rowShape; 328 : 329 0 : for (uInt row = 0; row < nrow; row++) { 330 0 : start(0) = row; 331 0 : calDescCol()->chanWidthQuant().get (row, rowChanWidth); 332 0 : chanWidthQuant_p(start,rowShape) = rowChanWidth.copy(); 333 : }; 334 0 : chanWidthQuantOK_p = true; 335 : }; 336 : }; 337 0 : return chanWidthQuant_p; 338 : }; 339 : 340 : //---------------------------------------------------------------------------- 341 : 342 0 : Array<Int>& CalDescBuffer::chanRange() 343 : { 344 : // CHAN_RANGE data field accessor 345 : // Input from private data: 346 : // connectedToIter_p Bool true if connected to iterator 347 : // chanRange_p Array<Int> Chan. range 348 : // 349 : // Fill local cache for this column if cache not valid 350 0 : if (connectedToIter()) { 351 0 : if (!chanRangeOK_p) { 352 0 : calDescCol()->chanRange().getColumn (chanRange_p); 353 0 : chanRangeOK_p = true; 354 : }; 355 : }; 356 0 : return chanRange_p; 357 : }; 358 : 359 : //---------------------------------------------------------------------------- 360 : 361 0 : Matrix<String>& CalDescBuffer::polznType() 362 : { 363 : // POLARIZATION_TYPE data field accessor 364 : // Input from private data: 365 : // connectedToIter_p Bool true if connected to iterator 366 : // polznType_p Vector<String> Polzn. type 367 : // 368 : // Fill local cache for this column if cache not valid 369 0 : if (connectedToIter()) { 370 0 : if (!polznTypeOK_p) { 371 0 : calDescCol()->polznType().getColumn (polznType_p); 372 0 : polznTypeOK_p = true; 373 : }; 374 : }; 375 0 : return polznType_p; 376 : }; 377 : 378 : //---------------------------------------------------------------------------- 379 : 380 0 : Vector<String>& CalDescBuffer::jonesType() 381 : { 382 : // JONES_TYPE data field accessor 383 : // Input from private data: 384 : // connectedToIter_p Bool true if connected to iterator 385 : // jonesType_p Vector<String> Jones matrix type 386 : // 387 : // Fill local cache for this column if cache not valid 388 0 : if (connectedToIter()) { 389 0 : if (!jonesTypeOK_p) { 390 0 : calDescCol()->jonesType().getColumn (jonesType_p); 391 0 : jonesTypeOK_p = true; 392 : }; 393 : }; 394 0 : return jonesType_p; 395 : }; 396 : 397 : //---------------------------------------------------------------------------- 398 : 399 0 : Vector<String>& CalDescBuffer::msName() 400 : { 401 : // MS_NAME data field accessor 402 : // Input from private data: 403 : // connectedToIter_p Bool true if connected to iterator 404 : // msName_p Vector<String> MeasurementSet name 405 : // 406 : // Fill local cache for this column if cache not valid 407 0 : if (connectedToIter()) { 408 0 : if (!msNameOK_p) { 409 0 : calDescCol()->msName().getColumn (msName_p); 410 0 : msNameOK_p = true; 411 : }; 412 : }; 413 0 : return msName_p; 414 : }; 415 : 416 : //---------------------------------------------------------------------------- 417 : 418 : } //# NAMESPACE CASA - END 419 :