casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTIFLOHelper.h
Go to the documentation of this file.
00001 //# GBTIFLOHelper.h: GBTIFLOHelper helps the GBT fillers use the IF and LO data
00002 //# Copyright (C) 2001,2002,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_GBTIFLOHELPER_H
00030 #define NRAO_GBTIFLOHELPER_H
00031 
00032 //#! Includes go here
00033 #include <casa/Arrays/IPosition.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <casa/Arrays/Vector.h>
00036 #include <casa/Containers/Block.h>
00037 #include <casa/BasicSL/String.h>
00038 
00039 //# Forward Declarations
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 class Table;
00042 } //# NAMESPACE CASA - END
00043 
00044 class GBTIFFiller;
00045 class GBTLO1File;
00046 class GBTLO1DAPFiller;
00047 
00048 #include <casa/namespace.h>
00049 
00050 // <summary>
00051 // GBTIFLOHelper helps the GBT filler use the IF and LO FITS files.
00052 // </summary>
00053 
00054 // <use visibility=local>
00055 
00056 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00057 // </reviewed>
00058 
00059 // <prerequisite>
00060 //   <li> GBTIFFiller
00061 //   <li> GBTLO1DAPFiller
00062 //   <li> Contents of the GBT IF and LO FITS files
00063 // </prerequisite>
00064 //
00065 // <etymology>
00066 // The GBT fillers need to take the IF and LO fits files plus their receiver
00067 // tables and other information to arrive at feeds, spectral windows, and
00068 // polarizations as well as groupings of data so that they can be filled into
00069 // the MS appropriately.
00070 // </etymology>
00071 //
00072 // <synopsis>
00073 // Currently, this is only useful for SpectralProcessor data.  It needs to be
00074 // generalized as much as possible.
00075 // </synopsis>
00076 //
00077 // <example>
00078 // </example>
00079 //
00080 // <motivation>
00081 // The code in the SP filler that this is derived from was getting sufficiently
00082 // large and confusing that it was difficult to see the forest for the trees.
00083 // Moving it here served to encapsulate it all in one place, hopefully making
00084 // it easier to modify, understand, and reuse.
00085 // </motivation>
00086 //
00087 // <todo asof="yyyy/mm/dd">
00088 //   <li> This needs to work for the other backends as well.
00089 // </todo>
00090 
00091 class GBTIFLOHelper
00092 {
00093 public:
00094     // the ifFiller, lo1File and lo1Handler are used directly here.  If lo1File is a 
00095     // non-null pointer, it will be used in preference to lo1Handler.  Neither should
00096     // be deleted by the calling object until this object is no longer going to be
00097     // used.
00098     GBTIFLOHelper(GBTIFFiller *ifFiller,
00099                   const GBTLO1File *lo1AFile, 
00100                   const GBTLO1File *lo1BFile, 
00101                   GBTLO1DAPFiller *lo1Handler,
00102                   const Table &samplerTable,
00103                   const Table &portTable,
00104                   uInt nphases, uInt nchannels,
00105                   const String &dcrBank = "");
00106 
00107     ~GBTIFLOHelper();
00108 
00109     // number of independent feeds in use in the sampler table
00110     uInt nfeeds() const {return itsSamplerFeeds.nelements();}
00111 
00112     // map from sampler feed number (starts from 0 through (nfeeds()-1)
00113     // to feedNumber (from iffiller).  feedNumber should be used
00114     // as the whichFeed argument to the other methods here.
00115     uInt whichFeed(uInt samplerFeed) {return itsSamplerFeeds[samplerFeed];}
00116 
00117      // the feed IDs as returned by GBTIFFiller
00118     Int feedId(uInt whichFeed) const {return itsFeedIds[whichFeed];}
00119 
00120     // row(s) in receiver table for each feed.  The validity of whichFeed is not checked.
00121     const Block<uInt> &receiverRows(uInt whichFeed) const {return *(itsRcvrRows[whichFeed]);}
00122 
00123     // Polarization information for the indicated feed.  The validity of whichFeed
00124     // is not checked.
00125     // <group>
00126     const Vector<Int> &corrType(uInt whichFeed) const {return itsCorrType[whichFeed];}
00127     const Array<Int> &corrProduct(uInt whichFeed) const {return itsCorrProduct[whichFeed];}
00128     // </group>
00129 
00130     // Feed information for the indicated feed.  The validity of whichFeed is
00131     // not checked.
00132     // <group>
00133     // From the "polarize" column
00134     const Vector<String> &polarizationType(uInt whichFeed) const {return itsPolType[whichFeed];}
00135     // From the "receiver" column
00136     const String &receiverName(uInt whichFeed) const {return itsRxName[whichFeed];}
00137     // From the "receptor" column
00138     const Vector<String> &feedName(uInt whichFeed) const {return itsFeedName[whichFeed];}
00139     // From the "feed" column if present, returns -1 if not.
00140     Int feed(uInt whichFeed) const {return itsFeed[whichFeed];}
00141     // From the "srfeed1" column if present, returns -1 if not.
00142     Int srfeed1(uInt whichFeed) const {return itsSrfeed1[whichFeed];}
00143     // From the "srfeed2" column if present, returns -1 if not.
00144     Int srfeed2(uInt whichFeed) const {return itsSrfeed2[whichFeed];}
00145     // From the "high_cal" column if present, returns -1 if not.
00146     Int highCal(uInt whichFeed) const {return itsHighCal[whichFeed];}
00147     // From the "bank" column if present, returns "" if not.
00148     const String &bank(uInt whichFeed) const {return itsBank[whichFeed];}
00149     // Also from the "bank" column, but for the appropriate switched feed,
00150     // this returns the bank of other feed involved if any switching is
00151     // going on AND this is from the ACS.
00152     const String &srbank(uInt whichFeed) const {return itsSRBank[whichFeed];}
00153     // The feedName corresponding to srbank
00154     const Vector<String> &srFeedName(uInt whichFeed) const 
00155     {return itsSRFeedName[whichFeed];}
00156     // </group>
00157 
00158     // Spectral information.  The validity of whichFeed and whichPhase is not checked.
00159     // Currently the SPECTRAL_WINDOW filler constructs the frequency axis 
00160     // from these linear values, although that could move here if appropriate.
00161     // <group>
00162     // all of the nphases values are returned together for the first timestamp in
00163     // the LO1 table.  Also set are the refframe (reference frame),
00164     // doptype (velocity definition) and souvel (source velocity in m/s) arguments.
00165     const Vector<Double> &centerFreqs(uInt whichFeed, MFrequency::Types &refframe,
00166                                       MDoppler::Types &doptype, Double &souvel);
00167     // channel spacing is independent of phase and time
00168     Double deltaFreq(uInt whichFeed) const {return itsDeltaFreq[whichFeed];}
00169 
00170     // reference channel is independent of phase and time
00171     // Channels are numbered from 0 in this scheme.
00172     Double refChan(uInt whichFeed) const {return itsRefChan;}
00173     // </group>
00174 
00175     // The LO1 file in use for each feed
00176     const GBTLO1File &lo1File(uInt whichFeed) const {return *(itsLO1Files[whichFeed]);}
00177 
00178     // The shape of the FLOAT_DATA column for the indicated feed.
00179     // The value of whichFeed is not checked.
00180     const IPosition &shape(uInt whichFeed) const {return itsShapes[whichFeed];}
00181 private:
00182     uInt itsNfeeds, itsNphases, itsNchannels;
00183     Double itsRefChan;
00184     PtrBlock<const GBTLO1File *> itsLO1Files;
00185     GBTLO1DAPFiller *itsLO1Filler;
00186 
00187     PtrBlock<Block<uInt> *> itsRcvrRows;
00188 
00189 
00190     Block<Double> itsT0CenterFreq;
00191     Block<Double> itsSFFMultiplier;
00192 
00193     Block<Int> itsFeedIds;
00194 
00195     Block<Vector<Int> > itsCorrType;
00196     Block<Vector<Double> > itsCenterFreq;
00197     Block<Vector<String> > itsPolType;
00198     Block<String> itsRxName, itsBank, itsSRBank;
00199     Block<Vector<String> > itsFeedName, itsSRFeedName;
00200     Block<Int> itsFeed, itsSrfeed1, itsSrfeed2, itsHighCal;
00201 
00202     Block<Array<Int> > itsCorrProduct;
00203 
00204     Block<Double> itsDeltaFreq;
00205 
00206     Block<IPosition> itsShapes;
00207 
00208     Vector<Double> itsLO1offset;
00209 
00210     Vector<uInt> itsSamplerFeeds;
00211 
00212     // function to try and ensure that SFF_sideband, SFF_multiplier, SFF_offset, initial LO1,
00213     // center_IF and center_Sky are all consistent.
00214     void ifParms(GBTIFFiller &ifFiller,
00215                  Int whichRow, Double &sffSideband, Double &sffMultiplier, Double &sffOffset);
00216 
00217     // undefined and unavailable
00218     GBTIFLOHelper();
00219     GBTIFLOHelper(const GBTIFLOHelper &);
00220     GBTIFLOHelper &operator=(const GBTIFLOHelper &);
00221 
00222 };
00223 
00224 #endif
00225 
00226