Line data Source code
1 : //# SimpComponentGridMachine.cc: Implementation of SimpComponentGridMachine class 2 : //# Copyright (C) 1997,1998,1999 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: 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 : //# $Id$ 27 : 28 : #include <synthesis/TransformMachines/SimpComponentGridMachine.h> 29 : #include <casacore/scimath/Mathematics/RigidVector.h> 30 : #include <components/ComponentModels/ComponentShape.h> 31 : #include <components/ComponentModels/ComponentType.h> 32 : #include <components/ComponentModels/Flux.h> 33 : #include <components/ComponentModels/SkyComponent.h> 34 : #include <components/ComponentModels/SpectralModel.h> 35 : #include <msvis/MSVis/VisBuffer.h> 36 : #include <casacore/casa/Arrays/ArrayMath.h> 37 : #include <casacore/casa/Arrays/Cube.h> 38 : #include <casacore/casa/Arrays/Matrix.h> 39 : #include <casacore/casa/Arrays/Vector.h> 40 : #include <casacore/casa/Arrays/IPosition.h> 41 : #include <casacore/casa/BasicSL/Complex.h> 42 : #include <casacore/casa/BasicSL/Constants.h> 43 : 44 : using namespace casacore; 45 : namespace casa { //# NAMESPACE CASA - BEGIN 46 : 47 0 : void SimpComponentGridMachine::get(VisBuffer& vb, SkyComponent& component, 48 : Int row) 49 : { 50 : // If row is -1 then we pass through all rows 51 : uInt startRow, endRow; 52 0 : if (row < 0) { 53 0 : startRow = 0; 54 0 : endRow = vb.nRow() - 1; 55 : } else { 56 0 : startRow = row; 57 0 : endRow = row; 58 : } 59 0 : const uInt nRow = endRow - startRow + 1; 60 : 61 0 : const uInt npol=vb.visCube().shape()(0); 62 0 : const uInt nChan=vb.visCube().shape()(1); 63 0 : const IPosition blc(3, 0, 0, startRow); 64 0 : const IPosition trc(3, npol-1, nChan-1, endRow); 65 0 : const IPosition inc(3, 1); 66 0 : Cube<Complex> modelData = vb.modelVisCube()(blc, trc, inc); 67 0 : Vector<Double> xyPos(2); 68 0 : Vector<Complex> visibility(4); 69 0 : const Vector<Double> & frequency = vb.frequency(); 70 : 71 : // Find the offsets in polarization. 72 : Int startPol, offPol; 73 0 : Vector<Int> corrType(vb.corrType()); 74 0 : startPol=corrType(0); 75 0 : if((startPol>4)&&(startPol<9)) { 76 0 : offPol=5; 77 : } 78 0 : else if((startPol>8)&&(startPol<13)) { 79 0 : offPol=9; 80 : } 81 : else { 82 0 : offPol=startPol; 83 : } 84 : 85 0 : Bool constantSpectrum = false; 86 0 : if (component.spectrum().type() == ComponentType::CONSTANT_SPECTRUM) { 87 0 : constantSpectrum = true; 88 : } 89 0 : Bool pointShape = false; 90 0 : if (component.shape().type() == ComponentType::POINT) { 91 0 : pointShape = true; 92 : } 93 : 94 : // Loop over all rows 95 0 : Vector<Double> uvValue(3); 96 0 : uvValue=0.0; 97 0 : for (uInt r = 0; r < nRow; r++) { 98 0 : for (uInt chn = 0; chn < nChan; chn++) { 99 0 : if (chn == 0 || !(pointShape && constantSpectrum)) { 100 : Vector<DComplex> fluxValue = 101 0 : component.visibility(uvValue, frequency(chn)).value(); 102 0 : convertArray(visibility, fluxValue); 103 0 : } 104 0 : for (uInt pol=0; pol < npol; pol++) { 105 0 : modelData(pol, chn, r) = visibility(corrType(pol)-offPol); 106 : } 107 : } 108 : } 109 0 : } 110 : 111 : } //# NAMESPACE CASA - END 112 :