Line data Source code
1 : //# EPointMBuf.cc: Implementation of EPointMBuf.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/EPointMBuf.h> 30 : #include <casacore/casa/Arrays/ArrayMath.h> 31 : #include <casacore/tables/Tables/RefRows.h> 32 : using namespace casacore; 33 : namespace casa { 34 : //---------------------------------------------------------------------------- 35 : 36 0 : EPointMBuf::EPointMBuf() : TimeVarVisJonesMBuf() 37 : { 38 : // Null constructor 39 : // Output to private data: 40 : // totalSolnOk_p Vector<Bool> Validity of total solution 41 : // totalFit_p Vector<Float> Total fit 42 : // totalFitWgt_p Vector<Float> Total fit weight 43 : // solnOk_p Array<Bool> Solution validity mask 44 : // fitOK_p Array<Float> Fit array 45 : // fitWgt_p Array<Float> Fit weight array 46 : // totalSolnOkOK_p Bool Total solution vailidity cache ok 47 : // totalFitOK_p Bool Total fit cache ok 48 : // totalFitWgtOK_p Bool Total fit weight cache ok 49 : // solnOkOK_p Bool Solution validity mask cache ok 50 : // fitOK_p Bool Fit array cache ok 51 : // fitWgtOK_p Bool Fit weight array cache ok 52 : // 53 : // Invalidate cache 54 0 : invalidate(); 55 0 : }; 56 : 57 : //---------------------------------------------------------------------------- 58 : 59 0 : EPointMBuf::EPointMBuf (const Vector<Int>& calIndices, 60 : const Block<Vector<Int> >& 61 0 : indexValues) : 62 0 : TimeVarVisJonesMBuf (calIndices, indexValues) 63 : { 64 : // Construct from a set of cal buffer indices and specified index values 65 : // Output to private data: 66 : // TimeVarVisJonesMBuf TimeVarVisJonesMBuf Parent class cal main 67 : // table buffer 68 : // Set local non-index columns to default values 69 0 : fillAttributes (calIndices); 70 0 : }; 71 : 72 : //---------------------------------------------------------------------------- 73 : 74 0 : EPointMBuf::EPointMBuf (CalIterBase& calIter) 75 0 : : TimeVarVisJonesMBuf (calIter) 76 : { 77 : // Construct from a calibration table iterator 78 : // Input: 79 : // calIter CalIterBase& Calibration table iterator 80 : // Output to private data: 81 : // totalSolnOk_p Vector<Bool> Validity of total solution 82 : // totalFit_p Vector<Float> Total fit 83 : // totalFitWgt_p Vector<Float> Total fit weight 84 : // solnOk_p Array<Bool> Solution validity mask 85 : // fitOK_p Array<Float> Fit array 86 : // fitWgt_p Array<Float> Fit weight array 87 : // totalSolnOkOK_p Bool Total solution vailidity cache ok 88 : // totalFitOK_p Bool Total fit cache ok 89 : // totalFitWgtOK_p Bool Total fit weight cache ok 90 : // solnOkOK_p Bool Solution validity mask cache ok 91 : // fitOK_p Bool Fit array cache ok 92 : // fitWgtOK_p Bool Fit weight array cache ok 93 : // 94 : // Invalidate cache 95 0 : invalidate(); 96 0 : }; 97 : 98 : //---------------------------------------------------------------------------- 99 : 100 0 : Int EPointMBuf::append (CalTable& calTable) 101 : { 102 : // Append the current calibration buffer to a calibration table 103 : // Input: 104 : // calTable CalTable& Calibration table 105 : // Output: 106 : // append Int No. of rows appended 107 : // 108 : // Extend the inherited parent method 109 0 : Int nAdded = CalMainBuffer::append(calTable); 110 : 111 : // Compute the rows added in the parent class 112 0 : Int endRow = calTable.nRowMain() - 1; 113 0 : Int startRow = endRow - nAdded + 1; 114 : 115 : // Attach a cal table columns accessor 116 : EPointMCol epointMainCol 117 0 : (dynamic_cast<EPointTable&>(calTable)); 118 : 119 : // Append the current cal buffer cal_main columns 120 0 : RefRows refRows(startRow, endRow); 121 0 : epointMainCol.pointingOffset().putColumnCells(refRows, pointingOffset()); 122 : 123 0 : return nAdded; 124 : }; 125 : 126 : //---------------------------------------------------------------------------- 127 : 128 0 : Int EPointMBuf::nRow() 129 : { 130 : // Return the maximum number of rows in the cal buffer 131 : // Input from private data: 132 : // totalSolnOk_p Vector<Bool> Validity of total solution 133 : // totalFit_p Vector<Float> Total fit 134 : // totalFitWgt_p Vector<Float> Total fit weight 135 : // solnOk_p Array<Bool> Solution validity mask 136 : // fitOK_p Array<Float> Fit array 137 : // fitWgt_p Array<Float> Fit weight array 138 : // totalSolnOkOK_p Bool Total solution vailidity cache ok 139 : // totalFitOK_p Bool Total fit cache ok 140 : // totalFitWgtOK_p Bool Total fit weight cache ok 141 : // solnOkOK_p Bool Solution validity mask cache ok 142 : // fitOK_p Bool Fit array cache ok 143 : // fitWgtOK_p Bool Fit weight array cache ok 144 : // Output: 145 : // nRow Int Max. no. of rows in the buffer 146 : // 147 : // Extend the inherited parent method 148 0 : Int nRowParent = CalMainBuffer::nRow(); 149 : 150 : // Process each local column individually 151 0 : Vector<Int> colLength(2); 152 0 : Int n = 0; 153 0 : colLength(n++) = nRowParent; 154 0 : colLength(n++) = pointingOffset().nelements(); 155 : 156 0 : return max(colLength); 157 : }; 158 : 159 : //---------------------------------------------------------------------------- 160 : 161 0 : Array<Float>& EPointMBuf::pointingOffset() 162 : { 163 : // TOTAL_SOLUTION_OK data field accessor 164 : // Input from private data: 165 : // totalSolnOk_p Vector<Bool> Validity of total solution 166 : // 167 : // Fill local cache for this column if cache not valid 168 0 : if (connectedToIter()) { 169 0 : if (!pointingOffsetOK_p) { 170 0 : calMainCol()->pointingOffset().getColumn (pointingOffset_p); 171 0 : pointingOffsetOK_p = true; 172 : }; 173 : }; 174 0 : return pointingOffset_p; 175 : }; 176 : 177 : 178 : //---------------------------------------------------------------------------- 179 : 180 0 : void EPointMBuf::invalidate() 181 : { 182 : // Invalidate the current cache 183 : // Output to private data: 184 : // totalSolnOkOK_p Bool Total solution vailidity cache ok 185 : // totalFitOK_p Bool Total fit cache ok 186 : // totalFitWgtOK_p Bool Total fit weight cache ok 187 : // solnOkOK_p Bool Solution validity mask cache ok 188 : // fitOK_p Bool Fit array cache ok 189 : // fitWgtOK_p Bool Fit weight array cache ok 190 : // 191 : // Invalidate parent class cache 192 0 : CalMainBuffer::invalidate(); 193 : 194 : // Set all cache flags to false 195 0 : pointingOffsetOK_p = false; 196 0 : }; 197 : 198 : //---------------------------------------------------------------------------- 199 : 200 0 : void EPointMBuf::fillAttributes (const Vector<Int>& /*calIndices*/) 201 : { 202 : // Resize all attribute columns and set to their default values 203 : // Input: 204 : // calIndices const Vector<Int.& Vector of cal indices, specified 205 : // as enums from class MSCalEnums, 206 : // to exclude 207 : // Output to private data: 208 : // pointingOffset_p Array<Float> Antenna pointing offsets 209 : 210 : // Use the maximum number of rows currently defined in the cal buffer 211 0 : uInt nrow = nRow(); 212 : 213 : // Process each local column separately 214 : // 215 : // TOTAL_SOLUTION_OK 216 0 : IPosition shape(2,2,nrow); 217 0 : pointingOffset().resize(shape); 218 0 : pointingOffset() = 0.0; 219 : 220 0 : return; 221 : }; 222 : }