casa
$Rev:20696$
|
00001 //# VLASDA: 00002 //# Copyright (C) 1999,2000,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_VLASDA_H 00030 #define NRAO_VLASDA_H 00031 00032 #include <casa/aips.h> 00033 #include <nrao/VLA/VLAEnum.h> 00034 #include <casa/IO/ByteSource.h> 00035 #include <measures/Measures/MDirection.h> 00036 #include <measures/Measures/MFrequency.h> 00037 #include <measures/Measures/MDoppler.h> 00038 #include <measures/Measures/Stokes.h> 00039 00040 #include <casa/namespace.h> 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 template <class T> class Vector; 00043 template <class T> class Matrix; 00044 class String; 00045 } //# NAMESPACE CASA - END 00046 00047 00048 // <summary> 00049 // Interprets the data in an sub-array data area of a VLA logical record. 00050 // </summary> 00051 00052 // <use visibility=export> 00053 00054 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00055 // </reviewed> 00056 00057 // <prerequisite> 00058 // <li> The VLA archive format as described in VLA computer memo 188 00059 // </prerequisite> 00060 // 00061 // <etymology> The sub-array data is, in memo 188, frequently shortened to the 00062 // acronym SDA. As this is specific to the VLA the name VLAADA seemed 00063 // appropriate. 00064 // </etymology> 00065 // 00066 // <synopsis> 00067 // This class contains functions which access and interpret the data in the 00068 // sub-array data area of a VLA logical record. 00069 // 00070 // The functions in this class access the specified data in the sub-array data 00071 // area and may convert the units and data types to something more suitable for 00072 // general use. They also interpret the data and provide some derived 00073 // quantities eg., the nPol function. 00074 // </synopsis> 00075 // 00076 // <example> 00077 00078 // This code fragment shows how to initialise a VLASDA object and then use 00079 // this object to determine how much data is in this record. It is assumed that 00080 // the Bytesource object contains a VLA Logical record. 00081 // <srcblock> 00082 // ByteSource VLARecord(...); 00083 // VLARCA rca; 00084 // VLASDA sda(VLARecord, rca.SDAOffset()); 00085 // cout << "The record has " << rca.nAntennas() << " antennas." << endl; 00086 // for (uInt c = 0; c < 4; c++) { 00087 // cout << "CDA " << c; 00088 // if (rca.CDAOffset() == 0) { 00089 // cout << " is not used." << endl; 00090 // else { 00091 // cout << " has " << sda.nChannels(c) << " spectral channels and" 00092 // << sda.npol(c) << " polarisations." << endl; 00093 // } 00094 // } 00095 // </srcblock> 00096 // </example> 00097 // 00098 // <motivation> 00099 // This class was needed as part of the VLA filler application. 00100 // </motivation> 00101 // 00102 // <thrown> 00103 // This class will throw an exception (AipSError) if you the correlator data 00104 // area argument is four or more. When compiled in debug mode this class does a 00105 // lot of consistancy checking. If it detects anomolies it will throw an 00106 // exception (AipsError). 00107 // </thrown> 00108 // 00109 // <todo asof="1999/08/13"> 00110 // <li> The member functions should probably be rounded out. 00111 // </todo> 00112 00113 class VLASDA 00114 { 00115 public: 00116 // The default constructor creates a unusable object. You need to use the 00117 // assignment operator or the attach function to create a usable object. 00118 VLASDA(); 00119 00120 // Construct this object to read data from the SDA of the given VLA logical 00121 // record. The SDA must begin at the specified number of bytes from the 00122 // beginning of the record (see the example above). 00123 VLASDA(ByteSource& record, uInt offset); 00124 00125 // The destructor is trivial; 00126 ~VLASDA(); 00127 00128 // The copy constructor uses reference semantics. 00129 VLASDA(const VLASDA& other); 00130 00131 // The assignment constructor uses reference semantics. 00132 VLASDA& operator=(const VLASDA& other); 00133 00134 // Re-initialise this object so that it now reads data from the given VLA 00135 // logical record. The sub-array data area that will be used begins at the 00136 // specified number of bytes from the beginning of the record. 00137 void attach(ByteSource& record, uInt offset); 00138 00139 // returns the number of data channels in the specified CDA (including 00140 // the average channel) 00141 uInt trueChannels(VLAEnum::CDA cda) const; 00142 00143 // returns the number of spectral channels in the specified CDA (excludes 00144 // channel zero) 00145 uInt nChannels(VLAEnum::CDA cda) const; 00146 00147 // returns the observed frequency (in Hz), at the band centre for the 00148 // specified CDA. This is the observed frequency after Doppler tracking has 00149 // been applied. It will correspond to the middle of the centre channel if 00150 // there are an odd number of channels and takes into account that some 00151 // channels may have been correlated but discarded prior to archiving. 00152 Double obsFrequency(VLAEnum::CDA cda) const; 00153 00154 // returns the observed frequency at the lower edge of the band, after 00155 // correcting for channels that have been correlated and discarded prior to 00156 // archiving the data. ie it returns the observed frequency of the lower edge 00157 // of the first channel in the data. 00158 Double edgeFrequency(VLAEnum::CDA cda) const; 00159 00160 // returns true if Doppler tracking has been turned on for the specified 00161 // CDA. If so then the observed frequency is calculated from the source 00162 // radial velocity, the line rest frequency and the component of the earths 00163 // velocity relative to the source (in the specified reference Frame). 00164 Bool dopplerTracking(VLAEnum::CDA cda) const; 00165 00166 // returns the assumed rest frequency of the source radiation in Hz (for the 00167 // specified CDA). This number is supplied by the observer and used in the 00168 // doppler tracking calculations. The returned value is not meaningful if 00169 // doppler tracking is not used. 00170 Double restFrequency(VLAEnum::CDA cda) const; 00171 00172 // returns the assumed radial velocity of the source in m/sec (for the 00173 // specified CDA). This number is supplied by the observer and used in the 00174 // doppler tracking calculations. The returned value is not meaningful if 00175 // doppler tracking is not used. 00176 Double radialVelocity(VLAEnum::CDA cda) const; 00177 00178 // Return the assumed rest frame that will be used when calculating the 00179 // observers motion relative to the source (for the specified CDA). This 00180 // frame is supplied by the observer and used in the Doppler tracking 00181 // calculations. The returned value is not meaningful of Doppler tracking is 00182 // not used. 00183 MFrequency::Types restFrame(VLAEnum::CDA cda) const; 00184 00185 // Return the definition of Doppler shift used to convert the radial 00186 // velocity to a frequency (for the specified CDA). This is supplied by the 00187 // observer and used in the Doppler tracking calculations. The returned value 00188 // is not meaningful of Doppler tracking is not used. 00189 MDoppler::Types dopplerDefn(VLAEnum::CDA cda) const; 00190 00191 // returns the bandwidth of an individual channel, in Hz, of the data in the 00192 // specified CDA. 00193 Double channelWidth(VLAEnum::CDA cda) const; 00194 00195 // returns the total bandwidth, in Hz, over all the channels of the data in 00196 // the specified CDA. Throws an exception if which > 3. 00197 Double correlatedBandwidth(VLAEnum::CDA cda) const; 00198 00199 // returns the total bandwidth, in Hz, of the front end filter in the 00200 // specified CDA. Throws an exception if which > 3. 00201 Double filterBandwidth(VLAEnum::CDA cda) const; 00202 00203 // Return the correlator mode for this record. Only useful if you know what 00204 // these codes are. The functions immediatly following this one are probably 00205 // more useful as they interpret this code for you. 00206 VLAEnum::CorrMode correlatorMode() const; 00207 00208 // Return the 'electronic path' that the data in the specified CDA has 00209 // travveled through. Returns 0 if the data in the specified CDA is from IF's 00210 // A or C and 1 if the data is from IF's B or D. The returned value is 00211 // meaningless if the CDA is not used in the current record. This information 00212 // is obtained from knowing what the correlator modes represent. 00213 uInt electronicPath(VLAEnum::CDA cda) const; 00214 00215 // Return the number of polarisations in the specified CDA. This information 00216 // is obtained from knowing what the correlator modes represent. 00217 uInt npol(VLAEnum::CDA cda) const; 00218 00219 // return a Matrix indicating which if's contributed to which correlations 00220 // within the specified CDA. The return Matrix always has two columns and the 00221 // same number of rows as there are correlations. Each row indicates which IF 00222 // from antennas one & two respectrively contributed to thw correlation. This 00223 // function encodes the information in Appendix F1 of memo 188. 00224 Matrix<VLAEnum::IF> ifUsage(VLAEnum::CDA cda) const; 00225 00226 // Return the subarray ID. This is a number between 1 and 4 indicating which 00227 // subarray this data corresponds to. 00228 uInt subArray() const; 00229 00230 // Return the Array configuration as a string. The string will contain at 00231 // between one and two characters and be somethings like "A", "D", "AD", etc 00232 String arrayConfig() const; 00233 00234 // Return the source RA and Dec at the standard epoch of this integration 00235 // (given by the epoch function). The returned Vector will always have two 00236 // elements being the RA and Dec in radians. 00237 Vector<Double> sourceDir() const; 00238 00239 // Return the source name as typed in by the observer. 00240 String sourceName() const; 00241 00242 // Return the source qualifier as typed in by the observer. This is really 00243 // the scan number. 00244 Int sourceQual() const; 00245 00246 // Return the integration time in seconds. 00247 Double intTime() const; 00248 00249 // Return the observation time in seconds of the centre of this 00250 // integration. Zero seconds means midnight on the day specified win the 00251 // RCA. 00252 Double obsTime() const; 00253 00254 // Return the observation program id. 00255 String obsId() const; 00256 00257 // Return the observing mode 00258 String obsMode() const; 00259 00260 // Return the observing mode in full glory 00261 String obsModeFull() const; 00262 00263 // Return the calibration code. 00264 String calCode() const; 00265 00266 // return the reference frame for the field directions. 00267 MDirection::Types epoch() const; 00268 00269 // returns whether the data spectrum has been Hanning smoothed (and every 00270 // second channel discarded). Always returns False for continuum data. 00271 Bool smoothed() const; 00272 00273 private: 00274 //# Contains a logical record 00275 mutable ByteSource itsRecord; 00276 // the offset to the start of this SDA in the record. An offset of zero means 00277 // this SDA is not used in this record. 00278 uInt itsOffset; 00279 }; 00280 #endif 00281 00282