casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTStateTable.h
Go to the documentation of this file.
00001 //# GBTStateTable.h: Class for dealing with the STATE table in GBT FITS files
00002 //# Copyright (C) 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_GBTSTATETABLE_H
00030 #define NRAO_GBTSTATETABLE_H
00031 
00032 //#! Includes go here
00033 
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/BasicSL/String.h>
00036 
00037 #include <casa/namespace.h>
00038 //# Forward Declarations
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 class Table;
00041 class FITSTable;
00042 } //# NAMESPACE CASA - END
00043 
00044 
00045 // <summary>
00046 // Class for dealing with the STATE table in GBT FITS files.
00047 // </summary>
00048 
00049 // <use visibility=export>
00050 
00051 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00052 // </reviewed>
00053 
00054 // <prerequisite>
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // </etymology>
00059 //
00060 // <synopsis>
00061 // </synopsis>
00062 //
00063 // <example>
00064 // </example>
00065 //
00066 // <motivation>
00067 // </motivation>
00068 //
00069 //
00070 // <thrown>
00071 //#! A list of exceptions thrown if errors are discovered in the function.
00072 //#! This tag will appear in the body of the header file, preceding the
00073 //#! declaration of each function which throws an exception.
00074 //    <li>
00075 //    <li>
00076 // </thrown>
00077 //
00078 // <todo asof="yyyy/mm/dd">
00079 // </todo>
00080 
00081 class GBTStateTable
00082 {
00083 public:
00084     // This constructs a GBTStateTable that is not attached to any table.
00085     // reattach must be used to make such an object useful.
00086     GBTStateTable();
00087 
00088     // Make a GBTStateTable attached to the indicated FITSTable
00089     GBTStateTable(FITSTable &fitstab);
00090 
00091     // uses copy semantics
00092     GBTStateTable(const GBTStateTable &other);
00093 
00094     ~GBTStateTable();
00095 
00096     // uses copy semantics
00097     GBTStateTable &operator=(const GBTStateTable &other);
00098 
00099     // reattach this object to a new FITSTable.  If there are problems with the
00100     // file, the return value is False and appropriate warnings are sent to the
00101     // logger.  The resulting object is not attached to any FITSTable.
00102     Bool reattach(FITSTable &fitstab);
00103     
00104     // detach from any table.
00105     void detach();
00106 
00107     // Is this object attached to a FITSTable.
00108     Bool isAttached() const {return itsAttached;}
00109 
00110     // the STATE table converted to a table
00111     const Table &table() const {return *itsTab;}
00112 
00113     // the value of the MASTER keyword in this table
00114     const String &master() const {return itsMaster;}
00115 
00116     // the value of the NUMPHASE keyword in this table
00117     Int numphase() const {return itsNumphase;}
00118 
00119     // the value of the SWPERIOD keyword in this table
00120     Double swperiod() const {return itsSwperiod;}
00121 
00122     // The SIGREF values - converted to the MS convention
00123     // T if signal being observed, F if reference.
00124     // In original FITS, 0 -> signal and 1 -> reference
00125     const Vector<Bool> &sigref() const {return itsSigref;}
00126 
00127     // The CAL values - converted to the MS convention
00128     // T if CAL noise being observed, F if not.
00129     // In original FITS, 0->no cal, 1->cal.
00130     const Vector<Bool> &cal() const {return itsCal;}
00131 
00132     // Digest an ACT_STATE table.  Return False if one of the following rules
00133     // are violated:
00134     // 1) The changing columns must be either ICAL or ECAL and ISIGREF or ESIGREF.
00135     // 2) Each row of STATE must have one and only one matching row in ACT_STATE.
00136     // If the above are true, the return value will be true and mixedSignals will be False.
00137     // states will contain the STATE row numbers corresponding to the rows of ACT_STATE
00138     // (hence states will have the same number of elements as rows in ACT_STATE).
00139     // For matching rows, the row number of the corresponding STATE row will appear
00140     // in the location for that row in ACT_STATE (i.e. in order).  ACT_STATE rows with
00141     // no match in STATE will be indicated by a value of -1 at that location in states.
00142     // Data corresponding to that ACT_STATE row should all be zero (not checked here,
00143     // obviously).  Hence states is resized so that it has the same number of rows as
00144     // the ACT_STATE table.
00145     // mixedSignals = T is not necessarily fatal. If multipleCal and multipleSigref are
00146     // both false, that is okay.   In that case, mixedSignals = True imples that there
00147     // was a non-zero value in both an E and I column but not both *CAL or *SIGREF columns.
00148     // If oldCalState is True, then this implies that the ECAL and ICAL columns in the
00149     // ACT_STATE table have the wrong sense (i.e. 0->on and 1->off) instead of the
00150     // sense in the STATE table (0->off and 1->on).  It is expected that this will
00151     // be fixed in a future version of the ACS FITS file.  It is up to the
00152     // GBTACSFiller class to decide how to set that argument.
00153     Bool digestActState(const Table &actState, Vector<Int> &states,
00154                         Bool &mixedSignals, Bool &multipleCal, Bool &multipleSigref,
00155                         Bool oldCalState) const;
00156 private:
00157     Table *itsTab;
00158 
00159     Bool itsAttached;
00160 
00161     String itsMaster;
00162     Int itsNumphase;
00163     Double itsSwperiod;
00164 
00165     Vector<Bool> itsSigref, itsCal;
00166 
00167     Int itsBaseVer, itsDeviceVer;
00168 
00169     Bool examineColumn(const Table &actState, const String &colName,
00170                        Vector<Int> &colValue, Int factor,
00171                        Bool oldCalState) const;
00172 };
00173 
00174 #endif
00175 
00176