casa
$Rev:20696$
|
00001 //# GBTCorrelation: GBTCorrelation holds spw and pol info 00002 //# Copyright (C) 2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id$ 00028 00029 #ifndef NRAO_GBTCORRELATION_H 00030 #define NRAO_GBTCORRELATION_H 00031 00032 #include <casa/aips.h> 00033 #include <casa/Arrays/IPosition.h> 00034 #include <casa/Arrays/Matrix.h> 00035 #include <casa/Arrays/Vector.h> 00036 #include <casa/Containers/SimOrdMap.h> 00037 #include <casa/BasicSL/String.h> 00038 00039 #include <casa/namespace.h> 00040 00041 //# Forward Declarations 00042 class GBTFeed; 00043 00044 // <summary> 00045 // GBTCorrelation holds spectral window and polarization information 00046 // </summary> 00047 00048 // <use visibility=local> 00049 00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tGBTCorrelation.cc" demos=""> 00051 // </reviewed> 00052 00053 // <prerequisite> 00054 // <li> The POLARIZATION table of the MeasurementSet. 00055 // <li> The SPECTRAL_WINDOW table. 00056 // <li> The DATA_DESCRIPTION table. 00057 // <li> The GBT FITS files. 00058 // <li> The GBT filler. 00059 // </prerequisite> 00060 // 00061 // <etymology> 00062 // This holds information that describes the correlation type 00063 // appropriate for one row of a MS. This is used for GBT data 00064 // and within the GBT filler. This information includes the 00065 // data description id and the two components of the data description 00066 // table (spectral window id and polarization id). It also 00067 // includes information necessary to fill the polarization table. 00068 // Finally, it keeps a record of which sampler row contributed to 00069 // each pair of receptors in a given correlation. 00070 // </etymology> 00071 // 00072 // <motivation> 00073 // When this information was being held by a larger class, it was getting 00074 // confused with other issues related to that class. By putting it in a 00075 // smaller, simpler class the maintenance will be easier and usage will 00076 // be less confusing. 00077 // </motivation> 00078 00079 class GBTCorrelation 00080 { 00081 public: 00082 // Construct one with no feed information. This will have 00083 // one correlation labelled "XX". The number of states 00084 // and channels must be specified at construction time. 00085 // Bank defaults to the empty string. 00086 GBTCorrelation(Int nstate, Int nchan); 00087 00088 // Use the indicated FEED to prepare to record the 00089 // sampler row information for each receptor pair. 00090 // Initially has space available for each possible 00091 // combination of receptor pairs. When freeze is 00092 // called, those pairs not actually set via setSamplerRow 00093 // are removed and numCorr then reflects the actual 00094 // receptor pairs in use (as do corrType and corrProduct). 00095 // The number of states and channels must be specified at construction. 00096 // The bank is used to discriminate against similar correlations 00097 // in the ACS but from different banks. 00098 GBTCorrelation(const GBTFeed &feed, Int nstate, Int nchan, 00099 const String &bank); 00100 00101 // copy constructor 00102 GBTCorrelation(const GBTCorrelation &other); 00103 00104 ~GBTCorrelation() {;} 00105 00106 // Assignment operator, uses copy syntax. 00107 GBTCorrelation &operator=(const GBTCorrelation &other); 00108 00109 // comparison operator. Checks shape, corrType, corrProduct 00110 // and receptors. 00111 Bool operator==(const GBTCorrelation &other) const; 00112 00113 // The number of states used in the constructor. 00114 Int nstate() const {return itsNstate;} 00115 00116 // The bank used in the constructor. 00117 const String &bank() const {return itsBank;} 00118 00119 // Set the name of the other bank for switched data 00120 void setsrbank(const String &srbank) {itsSrbank = srbank;} 00121 00122 // Get the name of the other bank for switched data 00123 const String &srbank() const {return itsSrbank;} 00124 00125 // The DATA_DESC_ID appropriate for this correlation and the 00126 // requested state. Returns -1 if unset. 00127 Int dataDescId(Int state) const {return itsDataDescId[state];} 00128 00129 // Set the associated DATA_DESC_ID for the given state. 00130 // It can be set and changed after freeze has been called. 00131 // This will typically be the last item set. 00132 void setDataDescId(Int ddid, Int state) {itsDataDescId[state] = ddid;} 00133 00134 // The POLARIZATION_ID appropriate for this correlation and state. 00135 // Returns -1 if unset. 00136 Int polId() const {return itsPolId;} 00137 00138 // Set the associated POLARIZATION_ID for the given state. 00139 // It can be set and changed after freeze has been called. 00140 // This will typically be set before DATA_DESC_ID is available. 00141 // It can be set and changed after freeze has been called. 00142 void setPolId(Int pid) {itsPolId = pid;} 00143 00144 // Set up information about a given sampler row. 00145 // If the constructor without GBTFeed was used, then this 00146 // always is associated with the XX correlation, 00147 // irrespective of the actual values of polA and polB. 00148 // If not, then this returns False if the polA or polB 00149 // receptors are not found in the feed used in the constructor. 00150 // This returns False if this polA and polB combination 00151 // has already been set here. Returns False after freeze() 00152 // has been called. The names of the two receptors from the IF 00153 // fits file are also passed in. These are later available 00154 // via receptors() 00155 Bool setSamplerRow(Int samplerRow, const String &polA, const String &polB, 00156 const String &receptorA, const String &receptorB); 00157 00158 // Merge the unfrozen aspects of otherCorr with this GBTCorr. Returns 00159 // False if the setSamplerRow would have returned False had these been 00160 // added in that way or if the bank in otherCorr does not match 00161 // the one used in the constructor for this object. The bank check 00162 // is only done when bankCheck is True. That should only be done 00163 // for ACS data. 00164 Bool mergeCorr(const GBTCorrelation &otherCorr, Bool bankCheck); 00165 00166 // Does the same checks that mergeCorr does without actually merging 00167 // anything. 00168 Bool mergeCheck(const GBTCorrelation &otherCorr, Bool bankCheck); 00169 00170 // Freeze this correlation with the sampler row information already 00171 // provided. Additional calls to setSamplerRow return False and are 00172 // ignored. 00173 void freeze(); 00174 00175 // The samplerRows associated with corrType. The actual 00176 // returned value is not specified if it has not yet been 00177 // frozen. 00178 const Vector<Int> &samplerRows() const {return itsSamplerRows;} 00179 00180 // the number of correlations. Returns 0 if called before 00181 // freeze() has been called. 00182 Int numCorr() const {return itsFrozen ? itsNumCorr:0;} 00183 00184 // The polarization of the numCorr correlations. The 00185 // actual returned value is not specified if it has not 00186 // yet been frozen. 00187 const Vector<Int> &corrType() const {return itsCorrType;} 00188 00189 // The polarizations as strings. Auto-correlations are returned 00190 // as single letters (i.e. "XX" becomes "X"). 00191 const Vector<String> &corrTypeAsString() const {return itsCorrTypeString;} 00192 00193 // The receptor cross-products. The actual returned value is 00194 // not specified if it has not yet been frozen 00195 const Matrix<Int> &corrProduct() const {return itsCorrProduct;} 00196 00197 // The receptors names used, one for each correlation pair. 00198 // For auto-correlation data, this will be just the original 00199 // receptor name. For cross-correlation data, it will be 00200 // receptor A name "x" receptor B name e.g. "R1xL1". This 00201 // is used when getting the tcal and trx values from the 00202 // rcvr tables. 00203 const Vector<String> &receptors() const {return itsReceptors;} 00204 00205 // The shape of this correlation 00206 const IPosition &shape() const {return itsShape;} 00207 private: 00208 Int itsNstate, itsPolId; 00209 uInt itsNumCorr, itsNumPol; 00210 Bool itsFrozen, itsIsDefault; 00211 String itsBank, itsSrbank; 00212 00213 IPosition itsShape; 00214 00215 //# this is always itsNstate elements long 00216 Vector<Int> itsDataDescId; 00217 00218 //# maps from the polarization string to a receptor (index into feed.polType()). 00219 SimpleOrderedMap<String, Int> itsRecptMap; 00220 00221 Vector<Int> itsCorrType, itsSamplerRows; 00222 Matrix<Int> itsCorrProduct; 00223 Vector<String> itsReceptors, itsCorrTypeString; 00224 00225 // unimplemented and unavailable 00226 GBTCorrelation(); 00227 }; 00228 00229 //#ifndef AIPS_NO_TEMPLATE_SRC 00230 //#include <nrao/GBTFillers/GBTCorrelation.tcc> 00231 //#endif //# AIPS_NO_TEMPLATE_SRC 00232 #endif