Line data Source code
1 : //# BeamSquint.cc: Implementation for BeamSquint 2 : //# Copyright (C) 1996,1997,1998,1999,2000,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 adressed 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 : //# 27 : //# $Id$ 28 : 29 : #include <casacore/casa/aips.h> 30 : #include <casacore/casa/Logging/LogIO.h> 31 : #include <synthesis/TransformMachines/BeamSquint.h> 32 : 33 : 34 : 35 : using namespace casacore; 36 : namespace casa { //# NAMESPACE CASA - BEGIN 37 : 38 542 : BeamSquint::BeamSquint() 39 : { 40 1084 : squint_p = MDirection( Quantity(0.0, "deg"), Quantity(0.0, "deg"), 41 1626 : MDirection::Ref(MDirection::AZEL)); 42 542 : refFreq_p = 0.0; 43 542 : }; 44 : 45 : 46 2561 : BeamSquint::BeamSquint(const MDirection& squint, const Quantity& refFreq) : 47 : squint_p(squint), 48 2561 : refFreq_p(refFreq) 49 : { 50 2561 : }; 51 : 52 8423 : BeamSquint::BeamSquint(const BeamSquint& other) 53 : { 54 8423 : squint_p = other.squint_p; 55 8423 : refFreq_p = other.refFreq_p; 56 8423 : }; 57 : 58 : 59 1824 : BeamSquint& BeamSquint::operator=(const BeamSquint& other) 60 : { 61 1824 : if (this == &other) 62 0 : return *this; 63 : 64 1824 : squint_p = other.squint_p; 65 1824 : refFreq_p = other.refFreq_p; 66 1824 : return *this; 67 : }; 68 : 69 11508 : BeamSquint::~BeamSquint() 70 : { 71 11508 : }; 72 : 73 3 : void BeamSquint::show() 74 : { 75 6 : LogIO os(LogOrigin("BeamSquint", "show")); 76 : os << "Beam Squint in arcmin (AZ-EL): " 77 3 : << squint_p.getAngle().getValue("'") << LogIO::POST; 78 : os << "Beam Squint ref freq, GHz : " 79 3 : << refFreq_p.getValue("GHz") << LogIO::POST; 80 3 : }; 81 : 82 17 : Bool BeamSquint::isNonNull() 83 : { 84 17 : Double x = 0.0; x = squint_p.getAngle().getValue("'")(0); 85 17 : Double y = 0.0; y = squint_p.getAngle().getValue("'")(1); 86 17 : if (abs(x) > 1e-9 || abs(y) > 1e-9) { 87 3 : return true; 88 : } else { 89 14 : return false; 90 : } 91 : }; 92 : 93 0 : MDirection& BeamSquint::scale(const Quantity& newFreq) 94 : { 95 0 : Float fScale = 1.0; 96 0 : fScale = refFreq_p.getValue("GHz") / newFreq.getValue("GHz"); 97 0 : Quantity q0 = Quantity(fScale*(squint_p.getAngle().getValue("'")(0)), "'"); 98 0 : Quantity q1 = Quantity(fScale*(squint_p.getAngle().getValue("'")(1)), "'"); 99 : MDirection * mdp = new MDirection( q0, q1, 100 0 : MDirection::Ref(MDirection::AZEL)); 101 0 : return *mdp; 102 : }; 103 : 104 : 105 : void 106 5244 : BeamSquint::getPointingDirection (const MDirection& pointDir, 107 : const Quantity parAngle, 108 : const Quantity obsFreq, 109 : const SquintType doSquint, 110 : MDirection& newPointing) 111 : { 112 : // If there is a problem with the squint, look here first! 113 : // Our convention: for a source which transits south of zenith, 114 : // PA = 0 at its transit, and increases with time. We need to 115 : // rotate the beam by -PA on the sky 116 : 117 : 118 5244 : newPointing = MDirection(pointDir); 119 : 120 : // cout << "BS1: pre-original pointing: " << pointDir.getAngle().getValue("'") << endl; 121 : 122 5244 : if (doSquint != NONE) { 123 : 124 : // The sign convention here was incorrect, as determined on 125 : // VLA L-band observations of IC2233. I flipped it to obtain 126 : // the best V image after correction. - TJC 2003/06/18 127 5244 : Float fScale = -refFreq_p.getValue("GHz") / obsFreq.getValue("GHz"); 128 : 129 5244 : Double sx = fScale*(squint_p.getAngle().getValue()(0)); 130 5244 : Double sy = fScale*(squint_p.getAngle().getValue()(1)); 131 : 132 10488 : String RRorLL = "RR"; 133 : 134 5244 : if (doSquint == LL) { 135 2622 : RRorLL = "LL"; 136 2622 : sx = -sx; 137 2622 : sy = -sy; 138 : } 139 : 140 : // rotate by -ParAngle 141 5244 : Double pa = parAngle.getValue("rad"); 142 : 143 5244 : Double dx = sx * cos(-pa) + sy * sin(-pa); 144 5244 : Double dy = -sx * sin(-pa) + sy * cos(-pa); 145 : // but this is in an AZ-EL type frame; flip it for combining with RA/DEC 146 5244 : dx = -dx; 147 : 148 5244 : newPointing.shift(dx, dy, true); 149 : // cout << "BeamSquint: " << RRorLL << " sx: " << sx << " sy: " << sy 150 : // << " pa: " << pa << " dx: " << dx << " dy: " << dy << endl; 151 : } 152 : 153 : 154 : // cout << "BS2: new pointing: " << newPointing.getAngle().getValue("'") << endl; 155 : // cout << "BS3: post-original pointing: " << pointDir.getAngle().getValue("'") << endl; 156 : 157 : 158 5244 : }; 159 : 160 : } //# NAMESPACE CASA - END 161 :