casa
$Rev:20696$
|
00001 //# GBTFITSBase.h: A base class for GBT FITS files - primary keywords. 00002 //# Copyright (C) 2001,2002 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_GBTFITSBASE_H 00030 #define NRAO_GBTFITSBASE_H 00031 00032 //#! Includes go here 00033 00034 #include <casa/aips.h> 00035 #include <casa/Arrays/Vector.h> 00036 #include <casa/Containers/Record.h> 00037 #include <fits/FITS/FITSTable.h> 00038 #include <measures/Measures/MEpoch.h> 00039 #include <casa/BasicSL/String.h> 00040 00041 #include <casa/namespace.h> 00042 //# Forward Declarations 00043 00044 // <summary> 00045 // A base class for GBT FITS files - primary keywords. 00046 // </summary> 00047 00048 // <use visibility=export> 00049 00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00051 // </reviewed> 00052 00053 // <prerequisite> 00054 // </prerequisite> 00055 // 00056 // <etymology> 00057 // </etymology> 00058 // 00059 // <synopsis> 00060 // </synopsis> 00061 // 00062 // <example> 00063 // </example> 00064 // 00065 // <motivation> 00066 // GBT FITS files have several required keywords common to all of them. 00067 // This class provides access to those fields and provides default values 00068 // for older FITS files where the required keywords were not present. 00069 // Specific classes for specific types of GBT FITS files are derived 00070 // from this class. Only the record of keywords from the primary HDU are 00071 // decoded here. 00072 // </motivation> 00073 // 00074 // 00075 // <thrown> 00076 //#! A list of exceptions thrown if errors are discovered in the function. 00077 //#! This tag will appear in the body of the header file, preceding the 00078 //#! declaration of each function which throws an exception. 00079 // <li> 00080 // <li> 00081 // </thrown> 00082 // 00083 // <todo asof="yyyy/mm/dd"> 00084 // </todo> 00085 00086 class GBTFITSBase 00087 { 00088 public: 00089 // This constructs a GBTFITSBase that has no primary keywords. 00090 GBTFITSBase(); 00091 00092 // Copy constructor. 00093 GBTFITSBase(const GBTFITSBase &other); 00094 00095 virtual ~GBTFITSBase() {;} 00096 00097 // Assignment operator, copy semantics. 00098 GBTFITSBase &operator=(const GBTFITSBase &other); 00099 00100 // attach this object to a new FITS file. If there are problems with the 00101 // file, the return value is False and appropriate warnings are sent to the 00102 // logger. The resulting object is not attached to any file. 00103 virtual Bool attach(const String &fitsFile) = 0; 00104 00105 // Is this object attached to a FITS file. This base class is never 00106 // attached to a file. 00107 virtual Bool isAttached() const {return False;} 00108 00109 // The name of the attached FITS file. Returns an empty string if 00110 // it is not attached. 00111 virtual const String &file() const = 0; 00112 00113 // Attach this base class to a new primary keyword record. This 00114 // resets all of the internals (including usedPrimaryKeys()). 00115 // Usually, a derived classes implementation of attach() will 00116 // invoke this function at some point. Returns false if any of 00117 // the expected keywords for this FITSVER were not found. If 00118 // scanlog is True, then the more limited set of keywords for the 00119 // scanlog will be expected. 00120 virtual Bool setPrimaryKeys(const Record &keys, Bool scanlog = False); 00121 00122 // The record containing the primary keywords. 00123 virtual const Record &primaryKeys() const {return itsKeys;} 00124 00125 // A vector indicating which keywords in primaryKeys() have been used 00126 // so (either by this base class or by a derived class). The index here 00127 // is the fieldNumber of the desired key. If that element is True, its 00128 // value has been used. Standard keywords required by the FITS standard 00129 // (e.g. SIMPLE, BITPIX, NAXIS, EXTEND, and END) are always marked as 00130 // used. 00131 virtual const Vector<Bool> &usedPrimaryKeys() const {return itsUsedKeys;} 00132 00133 // Mark the indicated keyword as being used. Returns False if the keyword 00134 // is not found. 00135 virtual Bool markAsUsed(const String &keywordName); 00136 00137 // Returns a record containing just the unused keywords. 00138 virtual Record unusedPrimaryKeys() const; 00139 00140 // ORIGIN - where this file originated. 00141 // Default value: "NRAO Green Bank" 00142 virtual const String &origin() const {return itsOrigin;} 00143 00144 // INSTRUME - device or program of origin. 00145 // Default value: empty string. 00146 virtual const String &instrume() const {return itsInstrume;} 00147 00148 // GBTMCVER - telescope control software release 00149 // Default value: empty string. 00150 virtual const String &mcVersion() const {return itsMCVersion;} 00151 00152 // FITSVER - FITS definition version for this device. 00153 // Default value: "0.0" 00154 virtual const String &fitsVers() const {return itsFitsVer;} 00155 00156 // Leading integer (before decimal) in FITSVER - version of base class. 00157 virtual Int baseVersion() const {return itsBaseVer;} 00158 00159 // Trailing integer (after decimal) in FITS - version of device. 00160 virtual Int deviceVersion() const {return itsDeviceVer;} 00161 00162 // DATEBLD - time program was linked 00163 // Default value: empty string. 00164 virtual const String &datebld() const {return itsDatebld;} 00165 00166 // SIMULATE - is the instrument in simulate mode? 00167 // Default value: F 00168 virtual Bool simulate() const {return itsSimulate;} 00169 00170 // DATE-OBS - Manager parameter startTime 00171 // Default value: MEpoch(0, MEpoch::Ref(MEpoch::UTC)) 00172 // This also uses the TIMESYS keyword when present (UTC is assumed if not) 00173 virtual const MEpoch &dateObs() const {return itsDateObs;} 00174 00175 // TELESCOP - green bank telescope 00176 // Default value: GBT. 00177 // The string NRAO_GBT is changed to GBT for use within AIPS++. 00178 virtual const String &telescop() const {return itsTelescop;} 00179 00180 // OBJECT - source 00181 // Default value: empty string. 00182 virtual const String &object() const {return itsObject;} 00183 00184 // PROJID - project ID 00185 // Default value: empty string. 00186 virtual const String &projid() const {return itsProjid;} 00187 00188 // OBSID - scan id 00189 // Default value: empty string. 00190 virtual const String &obsid() const {return itsObsid;} 00191 00192 // SCAN - scan number 00193 // Default value: -1 00194 virtual Int scan() const {return itsScan;} 00195 00196 // utility method to convert strings to integers 00197 static Int stringToInt(const String &str); 00198 00199 // utility method to convert strings to doubles 00200 static Double stringToDouble(const String &str); 00201 00202 // utility to construct a scratch table from a FITSTable. 00203 // It is the responsibility of the calling entity to delete 00204 // the returned pointer. 00205 static Table *tableFromFITS(FITSTable &fits); 00206 private: 00207 Record itsKeys; 00208 Vector<Bool> itsUsedKeys; 00209 00210 String itsOrigin, itsInstrume, itsMCVersion, itsFitsVer, itsDatebld, 00211 itsTelescop, itsObject, itsProjid, itsObsid; 00212 Int itsBaseVer, itsDeviceVer, itsScan; 00213 Bool itsSimulate; 00214 MEpoch itsDateObs; 00215 00216 // fill in the default values, clean up internals 00217 void init(); 00218 }; 00219 00220 #endif 00221 00222