casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTFeed.h
Go to the documentation of this file.
00001 //# GBTFeed: this holds information about a specific feed with IFs
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_GBTFEED_H
00030 #define NRAO_GBTFEED_H
00031 
00032 #include <casa/aips.h>
00033 
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 #include <casa/namespace.h>
00040 
00041 //# Forward Declarations
00042 class GBTIF;
00043 
00044 // <summary>
00045 // This holds information about a specific feed with IFs
00046 // </summary>
00047 
00048 // <use visibility=local>
00049 
00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tGBTFeed.cc" demos="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //   <li> ANTENNA BEAM_OFFSETS table
00055 //   <li> MeasurementSet
00056 // </prerequisite>
00057 //
00058 // <motivation>
00059 // It is necessary to collect information about the feeds in use in a
00060 // given scan and associate each feed with a set of IFs.
00061 // </motivation>
00062 //
00063 
00064 class GBTFeed
00065 {
00066 public:
00067     // The default feed.  Zero offsets and no associated srfeeds.
00068     // Equivalent to GBTFeed(0.0, 0.0, -1, -1, -1, "");
00069     GBTFeed();
00070 
00071     // A specific feed with the values taken directly from one row
00072     // of the BEAM_OFFSETS table.  The offsets should be in
00073     // deg, which is how they are expressed there.  Since
00074     // other parts of this class use the integer equivalences of
00075     // the feedName and since the IF table only contains an integer
00076     // FEED column, only the physical feeds present in the BEAM_OFFSETS
00077     // table should be used here.
00078     GBTFeed(Double xeloffset, Double eloffset, const String &feedName,
00079             Int srfeed1, Int srfeed2, const String &trckbeam);
00080 
00081     // Copy constructor.  Copy semantics.
00082     GBTFeed(const GBTFeed &other);
00083 
00084     ~GBTFeed();
00085 
00086     // Assignment operator, copy semantics.  This is the only way
00087     // to "unfreeze" a GBTFeed.  If other is not yet frozen than
00088     // this will become unfrozen as a result if it being made to
00089     // be a copy of other.
00090     GBTFeed &operator=(const GBTFeed &other);
00091 
00092     // This is the filled FEED_ID from the MS.  Returns -1 if not
00093     // yet known.
00094     Int feedId() const {return itsFeedId;}
00095 
00096     // Set the filled FEED_ID.
00097     void setFeedId(Int feedid) {itsFeedId = feedid;}
00098 
00099     // This is the filled FEED_ID from the MS corresponding to the
00100     // switched beam (i.e. corresponding to sdFitsFeedId).  Returns
00101     // -1 if not yet known.  This should be set equal to 
00102     // feedId() if there is no beam switching going on.
00103     // This will be filled to the GBT_SRFEED_ID column of the FEED
00104     // subtable.
00105     Int srFeedId() const {return itsSRFeedId;}
00106 
00107     // Set the filled GBT_SRFEED_ID.
00108     void setSRFeedId(Int srfeedid) {itsSRFeedId = srfeedid;}
00109 
00110     // The number of associated GBTIFs.
00111     uInt nif() const {return itsNif;}
00112 
00113     // Get a specific GBTIF
00114     const GBTIF &getIF(uInt whichIF) const {return *(itsIFPtr[whichIF]);}
00115 
00116     // Get one to possibly modify
00117     GBTIF &getIF(uInt whichIF) {return *(itsIFPtr[whichIF]);}
00118 
00119     // Add a new GBTIF - copies the values over, only adds if the IF
00120     // is unique.  Returns the index of the just newIF - which will
00121     // be < nif() before this call if this IF has already been added
00122     // (i.e. if it isn't unique).  The returned value can be used
00123     // as the whichIF argument of getIF.  Also combines the ifrows
00124     // and the correlations as necessary when mergeCorr is True.
00125     // If bankCheck is true, then the correlations are only
00126     // merged if the banks they came from are the same.  That
00127     // check should only be done on ACS data.
00128     Int addUniqueIF(const GBTIF &newIF, Bool mergeCorr,
00129                     Bool bankCheck);
00130 
00131     // Set the receiver name.
00132     void setReceiver(const String &receiver) {itsRxName = receiver;}
00133 
00134     // Get the receiver name.
00135     const String &receiver() const {return itsRxName;}
00136 
00137     // Add a receptor of a given polarization.  Has no effect after
00138     // freeze() has been called.  Should be one of just X,Y,L, or R.
00139     // The name comes from the IF manager.  Returns False if
00140     // that pol with a different receptorName has already been added.
00141     Bool addReceptor(const String &pol, const String &receptorName);
00142 
00143     // Freezes the number of receptors. This is necessary so that
00144     // receptors can be added in any order and sorted to a specific
00145     // order.  Sort order is x,y,r,l (although presumably in most
00146     // case there will be just x,y and r,l - or perhaps just one of
00147     // x,y,r, or l).  If no receptors have been added by the
00148     // time of the freeze, the default case of a single "x" receptor
00149     // will be made.
00150     void freeze();
00151 
00152     // The number of receptors.  Returns 0 before freeze().
00153     uInt numReceptors() const {return itsFrozen ? itsPolType.nelements():0;}
00154 
00155     // Returns the set of known receptors for this feed once
00156     // the feed has been frozen.  Prior to freeze() being called
00157     // the contents of this vector are not reliable.
00158     const Vector<String> &polType() const {return itsPolType;}
00159 
00160     // The names of the receptors as know in the IF FITS file once
00161     // the feed has been frozen.  Prior to freeze() being called
00162     // the contents of this vector are not reliable.
00163     const Vector<String> &receptorNames() const {return itsRecptNames;}
00164 
00165     // Return the offsets - to be used when filling the MS::FEED table.
00166     // The shape is (2,NUM_RECEPTORS). There is no actual dependence
00167     // here on NUM_RECEPTORS (i.e. all NUM_RECEPTORS values of each
00168     // row are identical).  The units are radians.  Prior to freeze
00169     // being called, the contents of this Matrix are not reliable.
00170     const Matrix<Double> &offsets() const {return itsOffsets;}
00171 
00172     // Return the feed number as it is known in the original FITS
00173     // file,  This is a direct translation of the String NAME column
00174     // in the FITS file to an integer.  Only those feeds which have
00175     // simple integer names will ever be used here..
00176     const Int fitsFeedId() const {return itsFitsFeedId;}
00177 
00178     // The original feed name
00179     const String name() const {return itsName;}
00180 
00181     // The tracking beam string
00182     const String trckbeam() const {return itsTrckbeam;}
00183 
00184     // Return the associated switching feed number as it appears in
00185     // the FITS table as dediced 
00186     // from the SRFEED1 and SRFEED2 columns.  Then the value here
00187     // is the one that is NOT the fitsFeedId() for this feed.
00188     // It therefore represents the fitsFeedId() for the other feed.
00189     // If both SRFEED1 and SRFEED2 are <= 0 then that implies that
00190     // no switching is going on.  In that case srFitsFeedId() == fitsFeedId().
00191     const Int srFitsFeedId() const {return itsSRFitsFeedId;}
00192 
00193     // Return a pointer to the associated switching feed.  This 
00194     // is the value set by setSRFeedPtr.  It should not be deleted.
00195     const GBTFeed *srFeedPtr() const {return itsSRFeedPtr;}
00196 
00197     // Set a pointer to the associated switching feed.
00198     void setSRFeedPtr(const GBTFeed *srFeedPtr) {itsSRFeedPtr = srFeedPtr;}
00199 private:
00200     Int itsFeedId, itsSRFeedId;
00201     String itsName, itsTrckbeam, itsRxName;
00202 
00203     const GBTFeed *itsSRFeedPtr;
00204     
00205     //# the number of GBTIF * actually in use and available in
00206     //# itsIFPtr.
00207     Int itsNif;
00208     Block<GBTIF *> itsIFPtr;
00209 
00210     Bool itsFrozen;
00211 
00212     //# initially this has length 4 and it is used to record which
00213     //# receptors of X,Y,R,L, have been added, in that order.  These
00214     //# will be non-empty strings only when they have been set.
00215     //# After freeze(), this is reduced to only the non-empty values.
00216     //# Presumably just (X,Y) or (R,L) or individual receptors.
00217     Vector<String> itsPolType;
00218     
00219     Vector<String> itsRecptNames;
00220 
00221     //# ths offsets as given in the ctor, units are still deg
00222     Double itsXeloffset, itsEloffset;
00223 
00224     Matrix<Double> itsOffsets;
00225 
00226     Int itsFitsFeedId, itsSRFitsFeedId;
00227 };
00228 
00229 //#ifndef AIPS_NO_TEMPLATE_SRC
00230 //#include <nrao/GBTFillers/GBTFeed.tcc>
00231 //#endif //# AIPS_NO_TEMPLATE_SRC
00232 #endif
00233 
00234