Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDPol.cc
r426 r427 31 31 32 32 #include "SDPol.h" 33 #include "SDDefs.h" 33 34 34 35 #include <casa/Arrays/Array.h> … … 52 53 53 54 54 SDStokesEngine::SDStokesEngine (const String& sourceColumnName, 55 const String& targetColumnName) 56 57 : BaseMappedArrayEngine<Float,Float> (sourceColumnName, targetColumnName) 55 SDStokesEngine::SDStokesEngine (const String& outputColumnName, 56 const String& inputColumnName) 57 : BaseMappedArrayEngine<Float,Float> (outputColumnName, inputColumnName) 58 58 {} 59 59 … … 62 62 : BaseMappedArrayEngine<Float,Float> () 63 63 { 64 if (spec.isDefined(" SOURCENAME") && spec.isDefined("TARGETNAME")) {65 setNames (spec.asString(" SOURCENAME"), spec.asString("TARGETNAME"));64 if (spec.isDefined("OUTPUTNAME") && spec.isDefined("INPUTNAME")) { 65 setNames (spec.asString("OUTPUTNAME"), spec.asString("INPUTNAME")); 66 66 } 67 67 } … … 100 100 { 101 101 Record spec; 102 spec.define (" SOURCENAME", sourceName());103 spec.define (" TARGETNAME", targetName());102 spec.define ("OUTPUTNAME", sourceName()); // Ger uses opposite meaning for source/target 103 spec.define ("INPUTNAME", targetName()); 104 104 return spec; 105 105 } … … 136 136 137 137 138 void SDStokesEngine::getArray (uInt rownr, Array<Float>& array) 139 { 140 Array<Float> target(array.shape()); 141 roColumn().get(rownr, target); 142 // 143 computeOnGet (array, target); 144 } 145 146 void SDStokesEngine::putArray (uInt rownr, const Array<Float>& array) 138 void SDStokesEngine::getArray (uInt rownr, Array<Float>& output) 139 { 140 IPosition inputShape = findInputShape (output.shape()); 141 Array<Float> input(inputShape); 142 roColumn().get(rownr, input); 143 // 144 computeOnGet (output, input); 145 } 146 147 void SDStokesEngine::putArray (uInt rownr, const Array<Float>& input) 147 148 { 148 149 throw(AipsError("This Virtual Column is not writable")); … … 151 152 152 153 153 void SDStokesEngine::computeOnGet(Array<Float>& array, 154 const Array<Float>& target) 154 void SDStokesEngine::setShape (uInt rownr, const IPosition& outputShape) 155 { 156 BaseMappedArrayEngine<Float,Float>::setShape (rownr, findInputShape(outputShape)); 157 } 158 159 void SDStokesEngine::setShapeColumn (const IPosition& outputShape) 160 { 161 BaseMappedArrayEngine<Float,Float>::setShapeColumn (findInputShape(outputShape)); 162 } 163 164 165 IPosition SDStokesEngine::shape (uInt rownr) 166 { 167 IPosition inputShape = roColumn().shape (rownr); 168 return findOutputShape(inputShape); 169 } 170 171 172 173 void SDStokesEngine::computeOnGet(Array<Float>& output, 174 const Array<Float>& input) 155 175 // 156 176 // array of shape (nBeam,nIF,nPol,nChan) 157 177 // 158 178 { 159 DebugAssert(target.ndim()==4,AipsError); 179 180 // Checks 181 182 const uInt nDim = input.ndim(); 183 DebugAssert(nDim==4,AipsError); 160 184 DebugAssert(array.ndim()==4,AipsError); 185 const IPosition inputShape = input.shape(); 186 const uInt polAxis = asap::PolAxis; 187 const uInt nPol = inputShape(polAxis); 188 DebugAssert(nPol==1 || nPol==2 || nPol==3, AipsError); 161 189 162 190 // The silly Array slice operator does not give me back 163 191 // a const reference so have to caste it away 164 192 165 Array<Float>& target2 = const_cast<Array<Float>&>(target); 166 167 // uInt polAxis = asap::PolAxis; 168 uInt polAxis = 2; 169 // 170 const uInt nDim = target.ndim(); 193 Array<Float>& input2 = const_cast<Array<Float>&>(input); 194 195 // Slice coordnates 196 171 197 IPosition start(nDim,0); 172 IPosition end( target.shape()-1);173 174 // Input slices198 IPosition end(input.shape()-1); 199 200 // Generate Slices 175 201 176 202 start(polAxis) = 0; 177 203 end(polAxis) = 0; 178 Array<Float> C1 = target2(start,end); 204 Array<Float> C1 = input2(start,end); // Input : C1 205 // 206 start(polAxis) = 0; 207 end(polAxis) = 0; 208 Array<Float> I = output(start,end); // Output : I 209 // 210 if (nPol==1) { 211 I = C1; 212 return; 213 } 179 214 // 180 215 start(polAxis) = 1; 181 216 end(polAxis) = 1; 182 Array<Float> C2 = target2(start,end); 217 Array<Float> C2 = input2(start,end); // Input : C1 218 // 219 I = Float(0.5)*(C1 + C2); 220 if (nPol <= 2) return; 183 221 // 184 222 start(polAxis) = 2; 185 223 end(polAxis) = 2; 186 Array<Float> C3 = target2(start,end);224 Array<Float> C3 = input2(start,end); // Input : C3 187 225 // 188 226 start(polAxis) = 3; 189 227 end(polAxis) = 3; 190 Array<Float> C4 = target2(start,end); 191 192 // Compute Output slices 193 194 start(polAxis) = 0; 195 end(polAxis) = 0; 196 Array<Float> I = array(start,end); 197 I = Float(0.5)*(C1 + C2); 228 Array<Float> C4 = input2(start,end); // Input : C4 198 229 // 199 230 start(polAxis) = 1; 200 231 end(polAxis) = 1; 201 Array<Float> Q = array(start,end);232 Array<Float> Q = output(start,end); // Output : Q 202 233 Q = Float(0.5)*(C1 - C2); 203 234 // 204 235 start(polAxis) = 2; 205 236 end(polAxis) = 2; 206 Array<Float> U = array(start,end);237 Array<Float> U = output(start,end); // Output : U 207 238 U = C3; 208 239 // 209 240 start(polAxis) = 3; 210 241 end(polAxis) = 3; 211 Array<Float> V = array(start,end);242 Array<Float> V = output(start,end); // Output : V 212 243 V = C4; 213 244 } 214 245 246 247 248 IPosition SDStokesEngine::findInputShape (const IPosition& outputShape) const 249 // 250 // Don't know how to handle the degeneracy that both 251 // XX -> I 252 // XX,YY -> I 253 // 254 { 255 uInt axis = asap::PolAxis; 256 uInt nPol = outputShape(axis); 257 IPosition inputShape = outputShape; 258 if (nPol==1) { 259 inputShape(axis) = 2; // XX YY -> I 260 } else if (nPol==4) { 261 inputShape(axis) = 4; // XX YY R(XY) I(XY) -> I Q U V 262 } 263 return inputShape; 264 } 265 266 IPosition SDStokesEngine::findOutputShape (const IPosition& inputShape) const 267 { 268 uInt axis = 2; 269 uInt nPol = inputShape(axis); 270 IPosition outputShape = inputShape; 271 if (nPol==1) { 272 outputShape(axis) = 1; // XX -> I 273 } else if (nPol==2) { 274 outputShape(axis) = 1; // XX YY -> I 275 } else if (nPol==4) { 276 outputShape(axis) = 4; // XX YY R(XY) I(XY) -> I Q U V 277 } 278 return outputShape; 279 } 215 280 216 281 -
trunk/src/SDPol.h
r419 r427 69 69 70 70 public: 71 // Construct an engine to scale all arrays in a column with 72 // the given offset and scale factor. 73 // TargetColumnName is the name of the column where the scaled 74 // data will be put and must have data type Float. 75 // The source column using this engine must have data type Float. 76 SDStokesEngine (const casa::String& sourceColumnName, 77 const casa::String& targetColumnName); 71 // Construct engine. The sourveColumnName holds the XX,YY,R(XY),I(XY) 72 // correlations 73 SDStokesEngine (const casa::String& virtualColumnName, 74 const casa::String& sourceColumnName); 78 75 79 76 // Construct from a record specification as created by getmanagerSpec(). … … 131 128 void getArray (casa::uInt rownr, casa::Array<casa::Float>& array); 132 129 133 // Exc petion130 // Exception 134 131 void putArray (casa::uInt rownr, const casa::Array<casa::Float>& array); 135 132 136 // Compute S Tokes parameters133 // Compute Stokes parameters 137 134 void computeOnGet (casa::Array<casa::Float>& array, 138 135 const casa::Array<casa::Float>& target); 136 137 // Set shapes 138 virtual void setShape (casa::uInt rownr, const casa::IPosition& outputShape); 139 virtual void setShapeColumn (const casa::IPosition& outputShape); 140 virtual casa::IPosition shape (casa::uInt rownr); 141 142 // Convert input/output shapes 143 casa::IPosition findInputShape (const casa::IPosition& outputShape) const; 144 casa::IPosition findOutputShape (const casa::IPosition& inputShape) const; 145 139 146 140 147
Note:
See TracChangeset
for help on using the changeset viewer.