Line data Source code
1 : //# PhaseShiftingTVI.h: This file contains the interface definition of the MSTransformManager class. 2 : //# 3 : //# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/) 4 : //# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved. 5 : //# Copyright (C) European Southern Observatory, 2011-2024, All rights reserved. 6 : //# 7 : //# This library is free software; you can redistribute it and/or 8 : //# modify it under the terms of the GNU Lesser General Public 9 : //# License as published by the Free software Foundation; either 10 : //# version 2.1 of the License, or (at your option) any later version. 11 : //# 12 : //# This library is distributed in the hope that it will be useful, 13 : //# but WITHOUT ANY WARRANTY, without even the implied warranty of 14 : //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 : //# Lesser General Public License for more details. 16 : //# 17 : //# You should have received a copy of the GNU Lesser General Public 18 : //# License along with this library; if not, write to the Free Software 19 : //# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 : //# MA 02111-1307 USA 21 : //# $Id: $ 22 : 23 : #ifndef PhaseShiftingTVI_H_ 24 : #define PhaseShiftingTVI_H_ 25 : 26 : #include <unordered_map> 27 : 28 : // Base class 29 : #include <mstransform/TVI/FreqAxisTVI.h> 30 : 31 : // To handle variant parameters 32 : #include <stdcasa/StdCasa/CasacSupport.h> 33 : 34 : // CAS-12706 To access directly the MS columns to get initial 35 : // time and position for wide-field phase shifting algorithm 36 : #include <casacore/ms/MeasurementSets/MSColumns.h> 37 : 38 : // CAS-12706 UVWMachine for wide-field phase shifting algorithm 39 : #include <casacore/measures/Measures/UVWMachine.h> 40 : #include <casacore/measures/Measures/MeasFrame.h> 41 : 42 : 43 : namespace casa { //# NAMESPACE CASA - BEGIN 44 : 45 : namespace vi { //# NAMESPACE VI - BEGIN 46 : 47 : ////////////////////////////////////////////////////////////////////////// 48 : // PhaseShiftingTVI class 49 : ////////////////////////////////////////////////////////////////////////// 50 : 51 : class PhaseShiftingTVI : public FreqAxisTVI 52 : { 53 : 54 : public: 55 : 56 : PhaseShiftingTVI( ViImplementation2 * inputVii, 57 : const casacore::Record &configuration); 58 : 59 : // Report the the ViImplementation type 60 0 : virtual casacore::String ViiType() const { return casacore::String("PhaseShifting( ")+getVii()->ViiType()+" )"; }; 61 : 62 : // Navigation methods 63 : virtual void origin (); 64 : virtual void next (); 65 : 66 : virtual void visibilityObserved (casacore::Cube<casacore::Complex> & vis) const; 67 : virtual void visibilityCorrected (casacore::Cube<casacore::Complex> & vis) const; 68 : virtual void visibilityModel (casacore::Cube<casacore::Complex> & vis) const; 69 : virtual void uvw (casacore::Matrix<double> & uvw) const; 70 : 71 : protected: 72 : 73 : void parseConfiguration(const casacore::Record &configuration); 74 : void parsePhasecenter(const casacore::Record &configuration); 75 : void parsePhasecenterDict(const casacore::Record &configuration); 76 : casacore::MDirection checkPhaseCenterStr(const casacore::String &phasecenter, 77 : const std::string &fieldInfo = ""); 78 : casacore::rownr_t getMaxMSFieldID() const; 79 : std::pair<bool, casacore::MDirection> findConvertedPhaseCenter() const; 80 : void initialize(); 81 : void shiftUVWPhases(); 82 : 83 : // only used when not using wide-field algorithm (not wideFieldMode_p) 84 : casacore::Double dx_p, dy_p; 85 : 86 : std::unordered_map<int, casacore::MDirection> phaseCenterSpec_p; 87 : // CAS-12706 Members wide-field phase shifting algorithm 88 : bool wideFieldMode_p; 89 : 90 : // Set once from Vii/MS at init time, if wideFieldMode_p 91 : casacore::MPosition observatoryPosition_p; 92 : casacore::MEpoch referenceTime_p; 93 : casacore::String referenceTimeUnits_p; 94 : 95 : // buffer to pass shift from shiftUVWPhases() => TVI uvw/data cols 96 : casacore::Matrix<casacore::Double> newUVW_p; 97 : casacore::Vector<casacore::Double> phaseShift_p; 98 : }; 99 : 100 : ////////////////////////////////////////////////////////////////////////// 101 : // PhaseShiftingTVIFactory class 102 : ////////////////////////////////////////////////////////////////////////// 103 : 104 : class PhaseShiftingTVIFactory : public ViFactory 105 : { 106 : 107 : public: 108 : 109 : PhaseShiftingTVIFactory(casacore::Record &configuration,ViImplementation2 *inputVII); 110 : 111 : protected: 112 : 113 : vi::ViImplementation2 * createVi (VisibilityIterator2 *) const; 114 : vi::ViImplementation2 * createVi () const; 115 : 116 : casacore::Record configuration_p; 117 : ViImplementation2 *inputVii_p;; 118 : }; 119 : 120 : ////////////////////////////////////////////////////////////////////////// 121 : // PhaseShiftingTVILayerFactory class (for _recursive_ layering) 122 : ////////////////////////////////////////////////////////////////////////// 123 : 124 : class PhaseShiftingTVILayerFactory : public ViiLayerFactory 125 : { 126 : 127 : public: 128 : 129 : PhaseShiftingTVILayerFactory(casacore::Record &configuration); 130 : 131 0 : virtual ~PhaseShiftingTVILayerFactory() {}; 132 : 133 : protected: 134 : 135 : 136 : virtual ViImplementation2 * createInstance(ViImplementation2* vii0) const; 137 : 138 : const casacore::Record configuration_p; 139 : 140 : }; 141 : 142 : ////////////////////////////////////////////////////////////////////////// 143 : // PhaseShiftingTransformEngine class 144 : ////////////////////////////////////////////////////////////////////////// 145 : 146 : template<class T> class PhaseShiftingTransformEngine : public FreqAxisTransformEngine2<T> 147 : { 148 : using FreqAxisTransformEngine2<T>::inputData_p; 149 : using FreqAxisTransformEngine2<T>::outputData_p; 150 : using FreqAxisTransformEngine2<T>::rowIndex_p; 151 : using FreqAxisTransformEngine2<T>::corrIndex_p; 152 : 153 : public: 154 : 155 : PhaseShiftingTransformEngine(casacore::Double dx, casacore::Double dy, 156 : casacore::Matrix<casacore::Double> *uvw, 157 : casacore::Vector<casacore::Double> *frequencies, 158 : DataCubeMap *inputData, 159 : DataCubeMap *outputData); 160 : 161 : void transform(); 162 : 163 : void transformCore(DataCubeMap *inputData,DataCubeMap *outputData); 164 : 165 : protected: 166 : 167 : casacore::Double dx_p, dy_p; 168 : casacore::Matrix<casacore::Double> *uvw_p; 169 : casacore::Vector<casacore::Double> *frequencies_p; 170 : }; 171 : 172 : ////////////////////////////////////////////////////////////////////////// 173 : // WideFieldPhaseShiftingTransformEngine class 174 : ////////////////////////////////////////////////////////////////////////// 175 : 176 : template<class T> class WideFieldPhaseShiftingTransformEngine : public FreqAxisTransformEngine2<T> 177 : { 178 : using FreqAxisTransformEngine2<T>::inputData_p; 179 : using FreqAxisTransformEngine2<T>::outputData_p; 180 : using FreqAxisTransformEngine2<T>::rowIndex_p; 181 : using FreqAxisTransformEngine2<T>::corrIndex_p; 182 : 183 : public: 184 : 185 : WideFieldPhaseShiftingTransformEngine(const casacore::Vector<casacore::Double> &phaseShift, 186 : casacore::Matrix<casacore::Double> *uvw, 187 : casacore::Vector<casacore::Double> *frequencies, 188 : DataCubeMap *inputData, 189 : DataCubeMap *outputData); 190 : 191 : void transform(); 192 : 193 : void transformCore(DataCubeMap *inputData,DataCubeMap *outputData); 194 : 195 : protected: 196 : 197 : casacore::Vector<casacore::Double> phaseShift_p; 198 : casacore::Matrix<casacore::Double> *uvw_p; 199 : casacore::Vector<casacore::Double> *frequencies_p; 200 : }; 201 : 202 : 203 : 204 : } //# NAMESPACE VI - END 205 : 206 : } //# NAMESPACE CASA - END 207 : 208 : #endif /* PhaseShiftingTVI_H_ */ 209 :