Line data Source code
1 : //# SimACoh.cc: Simulated additive errors 2 : //# Copyright (C) 1996,1997,1999,2000 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/BasicMath/Math.h> 30 : #include <synthesis/MeasurementComponents/SimACoh.h> 31 : #include <msvis/MSVis/VisBuffer.h> 32 : 33 : using namespace casacore; 34 : namespace casa { //# NAMESPACE CASA - BEGIN 35 : 36 : // Note: this simplistic implementation just generates a new random 37 : // noise value for every call of apply, it doesn't keep track of 38 : // time and antenna to return the same value if called with the same 39 : // coordinates. Thus applyInv will only work correctly if 40 : // called from a separate object in the exact same sequence as apply. 41 : 42 0 : SimACoh::SimACoh(Int seed, Double rms):rndGen_p(seed), 43 : //noiseDist_p(&rndGen_p, 0.0, square(rms/2.0)) 44 0 : noiseDist_p(&rndGen_p, 0.0, square(rms)) 45 : { 46 0 : } 47 0 : VisBuffer& SimACoh::apply(VisBuffer& vb) 48 : { 49 0 : Bool zeroSpacing = false; 50 0 : Complex c[4]; 51 0 : for (Int row=0; row<vb.nRow(); row++) { 52 0 : zeroSpacing = false; 53 0 : if (vb.uvw()(row)(0) == 0.0 && vb.uvw()(row)(1) == 0.0) { 54 0 : zeroSpacing = true; 55 : } 56 0 : for (Int chn=0; chn<vb.nChannel(); chn++) { 57 0 : if (zeroSpacing) { 58 0 : for (Int i=0; i<4; i++) c[i]=Complex(1.41421356*noiseDist_p(), 0.0); 59 : } else { 60 0 : for (Int i=0; i<4; i++) c[i]=Complex(noiseDist_p(),noiseDist_p()); 61 : } 62 0 : CStokesVector noiseCoh(c); 63 : 64 0 : vb.visibility()(chn,row)+=noiseCoh; 65 : 66 : } 67 : } 68 0 : return vb; 69 : } 70 : 71 0 : VisBuffer& SimACoh::applyInv(VisBuffer& vb) 72 : { 73 0 : Complex c[4]; 74 0 : for (Int row=0; row<vb.nRow(); row++) { 75 0 : for (Int chn=0; chn<vb.nChannel(); chn++) { 76 0 : for (Int i=0; i<4; i++) c[i]=Complex(noiseDist_p(),noiseDist_p()); 77 0 : CStokesVector noiseCoh(c); 78 0 : vb.visibility()(chn,row)-=noiseCoh; 79 : } 80 : } 81 0 : return vb; 82 : } 83 : 84 : } //# NAMESPACE CASA - END 85 :