Line data Source code
1 : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 2 : //# Associated Universities, Inc. Washington DC, USA. 3 : //# 4 : //# This library is free software; you can redistribute it and/or modify it 5 : //# under the terms of the GNU Library General Public License as published by 6 : //# the Free Software Foundation; either version 2 of the License, or (at your 7 : //# option) any later version. 8 : //# 9 : //# This library is distributed in the hope that it will be useful, but WITHOUT 10 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 12 : //# License for more details. 13 : //# 14 : //# You should have received a copy of the GNU Library General Public License 15 : //# along with this library; if not, write to the Free Software Foundation, 16 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 17 : //# 18 : //# Correspondence concerning AIPS++ should be addressed as follows: 19 : //# Internet email: aips2-request@nrao.edu. 20 : //# Postal address: AIPS++ Project Office 21 : //# National Radio Astronomy Observatory 22 : //# 520 Edgemont Road 23 : //# Charlottesville, VA 22903-2475 USA 24 : //# 25 : 26 : #include <imageanalysis/ImageAnalysis/LinearPolarizationCalculator.h> 27 : 28 : using namespace casacore; 29 : namespace casa { 30 : 31 : const String LinearPolarizationCalculator::CLASS_NAME = "LinearPolarizationCalculator"; 32 : 33 0 : LinearPolarizationCalculator::LinearPolarizationCalculator( 34 : const SPCIIF image, const String& outname, Bool overwrite 35 0 : ) : ImagePolTask(image, outname, overwrite) {} 36 : 37 0 : LinearPolarizationCalculator::~LinearPolarizationCalculator() {} 38 : 39 0 : SPIIF LinearPolarizationCalculator::compute() { 40 0 : *_getLog() << LogOrigin(CLASS_NAME, __func__, WHERE); 41 0 : auto q = _getStokesImage(Q); 42 0 : auto u = _getStokesImage(U); 43 0 : ThrowIf( 44 : ! q || ! u, 45 : "This image does not have Stokes Q and/or U so cannot compute linear polarization" 46 : ); 47 0 : _checkQUBeams(false); 48 0 : auto node = _makePolIntNode(_debias, _clip, _sigma, True, False); 49 : // Make expression 50 0 : LatticeExpr<Float> le(node); 51 0 : ImageExpr<Float> ie(le, String("LinearlyPolarizedIntensity")); 52 0 : ie.setUnits(_getImage()->units()); 53 0 : _setInfo(ie, Q); 54 : // Fiddle Stokes coordinate in ImageExpr 55 0 : _fiddleStokesCoordinate(ie, Stokes::Plinear); 56 0 : auto out = _prepareOutputImage(ie); 57 0 : if (_debias) { 58 0 : _maskAndZeroNaNs(out); 59 : } 60 0 : return out; 61 : } 62 : 63 0 : String LinearPolarizationCalculator::getClass() const { 64 0 : return CLASS_NAME; 65 : } 66 : 67 : 68 0 : void LinearPolarizationCalculator::setClip(Float clip) { 69 0 : _clip = clip; 70 0 : } 71 : 72 0 : void LinearPolarizationCalculator::setDebias(Bool debias) { 73 0 : _debias = debias; 74 0 : } 75 : 76 0 : void LinearPolarizationCalculator::setSigma(Float sigma) { 77 0 : _sigma = sigma; 78 0 : } 79 : 80 : }