Line data Source code
1 : //# VLAObsModeFilter.cc: 2 : //# Copyright (C) 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 addressed 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 : //# $Id$ 27 : 28 : #include <nrao/VLA/VLAObsModeFilter.h> 29 : #include <nrao/VLA/VLALogicalRecord.h> 30 : #include <casacore/casa/Exceptions/Error.h> 31 : #include <casacore/casa/Logging/LogOrigin.h> 32 : #include <casacore/casa/Logging/LogIO.h> 33 : #include <casacore/casa/Utilities/Assert.h> 34 : #include <casacore/casa/Arrays/ArrayLogical.h> 35 : 36 : 37 16 : VLAObsModeFilter::VLAObsModeFilter() 38 16 : :itsObsModes() 39 : { 40 : // itsObsModes is optionally user supplied - if empty, all supported modes are OK 41 16 : DebugAssert(ok(), AipsError); 42 16 : setModeInternals(); 43 16 : } 44 : 45 0 : VLAObsModeFilter::VLAObsModeFilter(const Vector<String>& obsModes) 46 0 : :itsObsModes(obsModes) 47 : { 48 : // any unsupported modes in obsModes will be skipped using itsSupportedModes as a check 49 0 : DebugAssert(ok(), AipsError); 50 0 : setModeInternals(); 51 0 : } 52 : 53 32 : VLAObsModeFilter::VLAObsModeFilter(const VLAObsModeFilter& other) 54 : : VLAFilter(), 55 32 : itsObsModes() 56 : { 57 32 : DebugAssert(ok(), AipsError); 58 32 : itsObsModes.resize(); 59 32 : itsObsModes = other.itsObsModes; 60 32 : setModeInternals(); 61 32 : } 62 : 63 80 : VLAObsModeFilter::~VLAObsModeFilter() { 64 48 : DebugAssert(ok(), AipsError); 65 80 : } 66 : 67 0 : VLAObsModeFilter& VLAObsModeFilter:: 68 : operator=(const VLAObsModeFilter& other) { 69 0 : if (this != &other) { 70 0 : itsObsModes.resize(); 71 0 : itsObsModes=other.itsObsModes; 72 : } 73 0 : DebugAssert(ok(), AipsError); 74 0 : return *this; 75 : } 76 : 77 20569 : Bool VLAObsModeFilter::passThru(const VLALogicalRecord& record) const { 78 : // it must be found in itsSupportedModes 79 20569 : if (anyEQ(itsSupportedModes,record.SDA().obsMode())) { 80 : // and itsObsModes must either be empty or this must be found there 81 20407 : if (itsObsModes.nelements()==0 || 82 20407 : anyEQ(itsObsModes,record.SDA().obsMode()) ) { 83 : // cerr << " match" << endl; 84 20407 : return true; 85 : } else { 86 : // cerr << " NO match" << endl; 87 0 : return false; 88 : } 89 : } else { 90 : // unsupported mode, warn? 91 162 : if (itsUnsupportedModes.count(record.SDA().obsMode())==0) { 92 : // unknown mode, add it 93 0 : itsUnsupportedModes[record.SDA().obsMode()] = modeDescWarn("unknown mode",false); 94 : } 95 162 : if (!itsUnsupportedModes.at(record.SDA().obsMode()).second) { 96 : // this warning only happens during fill, and it's less confusing if it appears to come from there 97 12 : LogIO logErr(LogOrigin("VLAFiller","fill")); 98 : logErr << LogIO::WARN 99 6 : << "Unsupported observing mode: " << record.SDA().obsMode() 100 12 : << " " << itsUnsupportedModes.at(record.SDA().obsMode()).first 101 18 : << LogIO::POST; 102 6 : itsUnsupportedModes.at(record.SDA().obsMode()).second = true; 103 : } 104 162 : return false; 105 : } 106 : // it can't get here, but just in case 107 : return false; 108 : } 109 : 110 32 : VLAFilter* VLAObsModeFilter::clone() const { 111 32 : DebugAssert(ok(), AipsError); 112 32 : VLAObsModeFilter* tmpPtr = new VLAObsModeFilter(*this); 113 32 : AlwaysAssert(tmpPtr != 0, AipsError); 114 32 : return tmpPtr; 115 : } 116 : 117 20937 : Bool VLAObsModeFilter::ok() const { 118 : // The LogIO class is only constructed if an error is detected for 119 : // performance reasons. Both function static and file static variables 120 : // where considered and rejected for this purpose. 121 20937 : if (!VLAFilter::ok()) return false; 122 20937 : return true; 123 : } 124 : 125 48 : void VLAObsModeFilter::setModeInternals() 126 : { 127 : // Permit only sensible modes for now 128 48 : itsSupportedModes.resize(9); 129 48 : itsSupportedModes[0]=" "; // standard 130 48 : itsSupportedModes[1]="H "; // holography 131 48 : itsSupportedModes[2]="S "; // solar 132 48 : itsSupportedModes[3]="SP"; // solar (low accuracy) 133 48 : itsSupportedModes[4]="VA"; // self-phasing (AD) 134 48 : itsSupportedModes[5]="VB"; // self-phasing (BC) 135 48 : itsSupportedModes[6]="VL"; // self-phasing (CD) 136 48 : itsSupportedModes[7]="VR"; // self-phasing (AB) 137 48 : itsSupportedModes[8]="VX"; // phasing from prior scan 138 : 139 : // used for error reporting - appendix D.2 : VLA Archive Data Format 140 48 : itsUnsupportedModes.clear(); 141 48 : itsUnsupportedModes["D "] = modeDescWarn("delay center determination mode",false); 142 48 : itsUnsupportedModes["IR"] = modeDescWarn("interferometer reference pointing mode",false); 143 48 : itsUnsupportedModes["IA"] = modeDescWarn("interferometer pointing mode A (IF)",false); 144 48 : itsUnsupportedModes["IB"] = modeDescWarn("interferometer pointing mode B (IF)",false); 145 48 : itsUnsupportedModes["IC"] = modeDescWarn("interferometer pointing mode C (IF)",false); 146 48 : itsUnsupportedModes["ID"] = modeDescWarn("interferometer pointing mode D (IF)",false); 147 48 : itsUnsupportedModes["JA"] = modeDescWarn("JPL mode A (IF)",false); 148 48 : itsUnsupportedModes["JB"] = modeDescWarn("JPL mode B (IF)",false); 149 48 : itsUnsupportedModes["JC"] = modeDescWarn("JPL mode C (IF)",false); 150 48 : itsUnsupportedModes["JD"] = modeDescWarn("JPL mode D (IF)",false); 151 48 : itsUnsupportedModes["PA"] = modeDescWarn("single dish pointing mode A (IF)",false); 152 48 : itsUnsupportedModes["PB"] = modeDescWarn("single dish pointing mode B (IF)",false); 153 48 : itsUnsupportedModes["PC"] = modeDescWarn("single dish pointing mode C (IF)",false); 154 48 : itsUnsupportedModes["PD"] = modeDescWarn("single dish pointing mode D (IF)",false); 155 48 : itsUnsupportedModes["TB"] = modeDescWarn("test back-end and front-end",false); 156 48 : itsUnsupportedModes["TE"] = modeDescWarn("tipping curve",false); 157 48 : itsUnsupportedModes["TF"] = modeDescWarn("test front-end",false); 158 48 : itsUnsupportedModes["VS"] = modeDescWarn("single dish VLBI",false); 159 48 : } 160 : 161 : // Local Variables: 162 : // compile-command: "gmake VLAObsModeFilter" 163 : // End: