casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTIF.h
Go to the documentation of this file.
00001 //# GBTIF: this describes a GBT IF
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_GBTIF_H
00030 #define NRAO_GBTIF_H
00031 
00032 #include <casa/aips.h>
00033 
00034 #include <nrao/GBTFillers/GBTCorrelation.h>
00035 
00036 #include <casa/Arrays/Vector.h>
00037 #include <casa/Containers/Block.h>
00038 #include <measures/Measures/MDoppler.h>
00039 #include <measures/Measures/MFrequency.h>
00040 #include <casa/Quanta/MVFrequency.h>
00041 
00042 //# Forward Declarations
00043 namespace casa { //# NAMESPACE CASA - BEGIN
00044 class String;
00045 } //# NAMESPACE CASA - END
00046 
00047 class GBTIFFiller;
00048 class GBTLO1File;
00049 class GBTCorrelation;
00050 
00051 #include <casa/namespace.h>
00052 
00053 // <summary>
00054 // </summary>
00055 
00056 // <use visibility=local>
00057 
00058 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tGBTIF.cc" demos="">
00059 // </reviewed>
00060 
00061 // <prerequisite>
00062 //   <li> GBT FITS files
00063 //   <li> GBTIFFiller
00064 //   <li> GBTLO1File
00065 //   <li> MS
00066 // </prerequisite>
00067 //
00068 // <etymology>
00069 // This describes a GBT IF and its associated correlations.
00070 // </etymology>
00071 //
00072 // <motivation>
00073 // It is necessary to know what the unique IFs are given a backend
00074 // FITS file, an IF fits file, and any LO1 fits files.  It is also
00075 // necessary to associated each correlation with an IF.
00076 // </motivation>
00077 //
00078 
00079 class GBTIF
00080 {
00081 public:
00082     // This is used where there is NO associated IF FITS file
00083     // returns defaults.  This is constructed with one
00084     // GBTCorrelation - the default.
00085     GBTIF(uInt nchan, uInt nstate);
00086     
00087     // Matches bank and port in the iffiller (which has already
00088     // been constructed with the backend already selected) to
00089     // get the IF information.  Uses the appropriate LO1 file
00090     // for that row to get the LO1 doppler tracking and frequency
00091     // switching information along with the LO1 offsets which
00092     // finishes the description of the frequency axis.
00093     // ifFreq is the IF frequency to be used in the sky frequency
00094     // formula corresponding to channel 0.
00095     // bw is the total bandwith.  increases indicates
00096     // whether the IF frequency increases with increasing channel
00097     // number.  For the ACS backend, some bandwidths
00098     // decrease with increasing channel number.
00099     // If ifFreq is < 0, then the value in CENTER_IF is used.
00100     // If bw is < 0, then the value in BANDWDTH is used.
00101     GBTIF(uInt nchan, uInt nstate, const String &bank, Int port,
00102           Double ifFreq, Double bw, Bool increases,
00103           const GBTIFFiller &iffiller,
00104           const GBTLO1File &lo1aFile, const GBTLO1File &lo1bFile,
00105           Bool continuum);
00106 
00107     // Copy constructor.
00108     GBTIF(const GBTIF &other);
00109 
00110     ~GBTIF();
00111 
00112     // Assignment operator. Uses copy semantics.
00113     GBTIF &operator=(const GBTIF &other);
00114 
00115     // Comparison operator.
00116     Bool operator==(const GBTIF &other) const;
00117     
00118     // This one adds another associated IF row.  The intent is that
00119     // when you collect all of the rows associated with each unique IF.
00120     // This is a row from the IF fits file which shares this frequency
00121     // axis information.  Each row then contributes to one of the
00122     // associated correlations.
00123     void addIFRow(Int whichRow);
00124 
00125     // The vector of associated IF rows (rows from the IF fits file
00126     // which all share this frequency axis). 
00127     const Vector<Int> &ifrows() const {return itsIFrows;}
00128 
00129     // The number of associated GBTCorrelations
00130     uInt ncorr() const {return itsNcorr;}
00131 
00132     // Add this correlation to this GBTIF.
00133     void addCorr(const GBTCorrelation &corr);
00134 
00135     // Get a specific correlation.
00136     GBTCorrelation &getCorr(Int whichCorr) {return *(itsCorrs[whichCorr]);}
00137 
00138     // Get a specific const correlation.
00139     const GBTCorrelation &getCorr(Int whichCorr) const {return *(itsCorrs[whichCorr]);}
00140 
00141     // The values which define this IF.  These are used
00142     // in the comparison operators and they are also used
00143     // when filling the spectral window table.  These
00144     // describe a linear frequency axis.  The comparison
00145     // operators also require that nstate be the same
00146     // for equality to be true.
00147     // <group>
00148     // The number of channels along the frequency axis.
00149     // This is the same as used in the constructor.
00150     uInt nchan() const {return itsNchan;}
00151 
00152     // The number of states.
00153     uInt nstate() const {return itsNstate;}
00154 
00155     // The frequency at the refChan(), in Hz.
00156     // This defaults to refChan() if insufficient information
00157     // is available to construct the whole frequency axis.
00158     Double refFreq() const {return itsRefFreq;}
00159 
00160     // The channel spacing (may be negative) with positive 
00161     // increasing channel number, in Hz.  This defaults to 1.0.
00162     Double deltaFreq() const {return itsDeltaFreq;}
00163 
00164     // The reference channel.  This will be nchan/2 or 0 if nchan==1.
00165     Double refChan() const {return itsRefChan;}
00166 
00167     // The reference frame.  This defaults to Mfrequency::TOPO.
00168     MFrequency::Types refFrame() const {return itsRefFrame;}
00169 
00170     // The tolerance, in Hz.  This defaults to 10.0.  The
00171     // comparison operators use this when comparing 
00172     // refFreq and deltaFreq.
00173     Double tolerance() const {return itsTol;}
00174 
00175     // The rest frequency from the appropriate LO1 file.
00176     const MVFrequency &restFreq() const {return itsRestFreq;}
00177 
00178     // The doppler type from the LO1 file
00179     MDoppler::Types dopType() const {return itsDopType;}
00180 
00181     // The source velocity from the LO1 file
00182     Double vsource() const {return itsVsource;}
00183     // </group>
00184 
00185     // Offsets in refFreq for each state from the LO1 table.
00186     // These will be all 0 for non-frequency switched data,
00187     // and if the LO1 file is missing.
00188     const Vector<Double> &offsets() const {return itsOffsets;}
00189 
00190     // The SPECTRAL_WINDOW_ID appropriate for this state.
00191     // Returns -1 if unset.
00192     Int spwId(Int state) const {return itsSpwId[state];}
00193 
00194     // Set the associated SPECTRAL_WINDOW_ID for the given state.
00195     void setSpwId(Int swid, Int state) {itsSpwId[state] = swid;}
00196 private:
00197     uInt itsNchan, itsNstate;
00198     Double itsRefFreq, itsRefChan, itsDeltaFreq, itsTol, itsVsource;
00199     MFrequency::Types itsRefFrame;
00200     MVFrequency itsRestFreq;
00201     MDoppler::Types itsDopType;
00202 
00203     //# these are always both itsNstate elements long
00204     Vector<Double> itsOffsets;
00205     Vector<Int> itsSpwId;
00206 
00207     Vector<Int> itsIFrows;
00208 
00209     uInt itsNcorr;
00210     Block<GBTCorrelation *> itsCorrs;
00211 
00212     void clearCorrs();
00213 
00214     //# undefined and unavailable
00215     GBTIF();
00216 };
00217 
00218 //#ifndef AIPS_NO_TEMPLATE_SRC
00219 //#include <nrao/GBTFillers/GBTIF.tcc>
00220 //#endif //# AIPS_NO_TEMPLATE_SRC
00221 #endif
00222 
00223