casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SDDHeader.h
Go to the documentation of this file.
00001 //# SDDHeader.h: a class containing the header information from an SDDFile
00002 //# Copyright (C) 1999,2001
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_SDDHEADER_H
00030 #define NRAO_SDDHEADER_H
00031 
00032 //#! Includes go here
00033 #include <casa/aips.h>
00034 #include <casa/Arrays/Vector.h>
00035 
00036 #include <casa/namespace.h>
00037 //# Forward declarations
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 class String;
00040 } //# NAMESPACE CASA - END
00041 
00042 class SDDBlock;
00043 #include <casa/iosfwd.h>
00044 
00045 #include <casa/namespace.h>
00046 // <summary>
00047 // a class containing the header information from an SDDFile
00048 // </summary>
00049 
00050 // <use visibility=export>
00051 
00052 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> SDDFile
00057 //   <li> SDDIndex
00058 //   <li> SDDHeader
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // </etymology>
00063 //
00064 // <synopsis>
00065 // </synopsis>
00066 //
00067 // <example>
00068 // </example>
00069 //
00070 // <motivation>
00071 // </motivation>
00072 //
00073 
00074 class SDDHeader {
00075 public:
00076     // String Header Values
00077     enum StringHeader {
00078         OBSID=0,                      // obsever initials, 8 characters
00079         OBSERVER,                     // observer name, 16 characters
00080         TELESCOP,                     // Telescope descriptor, 8 characters
00081         PROJID,                       // project ID, 8 characters
00082         OBJECT,                       // source name, 16 characters
00083         OBSMODE,                      // type of data + observing mode, 8 characters
00084         FRONTEND,                     // front end descriptor, 8 characters
00085         BACKEND,                      // back end descriptor, 8 characters
00086         PRECIS,                       // Data Precision, 8 characters, ignored!
00087         PT_MODEL,                     // Pointing Model descriptor, 8 characters
00088         CL11TYPE,                     // Class 11 type descriptor, 8 characters
00089         COORDCD,                      // Coordinate System Code, 8 characters
00090         FRAME,                        // XY Reference Frame Code, 8 characters
00091         VELDEF,                       // Velocity Definition and Reference, 8 characters
00092         TYPECAL,                      // Type of Calibration, 8 characters
00093         CFFORM,                       // Center Frequency Formula
00094         OPENPAR,                      // Class 10, open parameter, 80 characters
00095         POLARIZ,                      // Polarization descriptor, 8 characters
00096         RX_INFO,                      // Receiver information, 16 characters
00097         LAST_STRING
00098     };
00099     
00100     
00101     // R*8 (Double) Header values 
00102     enum BasicInformation {
00103         HEADLEN=0,                    // length of header in bytes
00104         DATALEN,                      // length of data in bytes
00105         SCAN,                         // Scan number
00106         SAVENUM=14,                   // index location for this scan
00107         NORECORD,                     // # of individual records for RECORDS scan
00108                                       // OR # of OTF spectra in this row
00109         RECORDID,                     // The record number for this scan
00110                                       // OR the # of this OTF spectra
00111         LAST_BASIC
00112     };
00113 
00114     enum PointingParameters {
00115         XPOINT=0,                     // Total Az/RA Pointing Correction (arcsec)
00116         YPOINT,                       // Total El/Dec Pointing Correction (arcsec)
00117         UXPNT,                        // User Az/RA Pointing Correction (arcsec)
00118         UYPNT,                        // User El/Dec Pointing Correction (arcsec)
00119         PTCON0,                       // Pointing Constants(0) (arcmin)
00120         PTCON1,                       // Pointing Constants(1) (arcmin)
00121         PTCON2,                       // Pointing Constants(2) (arcmin)
00122         PTCON3,                       // Pointing Constants(3) (arcmin)
00123         ORIENT,                       // Receiver box or secondary orientation (Degrees)
00124         FOCUSR,                       // Radial Focus (mm)
00125         FOCUSV,                       // North-South Focus (mm)
00126         FOCUSH,                       // East-West Focus (mm)
00127         LAST_POINTING=13
00128     };
00129 
00130     enum ObservingParameters {
00131         UTDATE=0,                     // Universal Time Date (YYYY.MMDD)
00132         UT,                           // Universay Time (hours)
00133         LST,                          // LST (hours)
00134         NORCHAN,                      // Number of receiver channels
00135         NOSWVAR,                      // Number of switching variables
00136         NOPHASE,                      // Number of phases per cycle
00137         CYCLEN,                       // Length of Cycle (seconds)
00138         SAMPRAT,                      // Length of Sample (seconds)
00139         PHASEID=9,                    // Phase number of this RECORDS data
00140         LAST_OBSERVING
00141     };
00142         
00143     enum Positions {
00144         EPOCH=0,                      // Epoch (years)
00145         XSOURCE,                      // Commanded Source X (Degrees)
00146         YSOURCE,                      // Commanded Source Y (Degrees)
00147         XREF,                         // Commanded Reference X (Degrees)
00148         YREF,                         // Commanded Reference Y (Degrees)
00149         EPOCRA,                       // Commanded RA at Epoch (Degrees)
00150         EPOCDEC,                      // Commanded Dec at Epoch (Degrees)
00151         GALLONG,                      // Commanded Galactic Longitude (Degrees)
00152         GALLAT,                       // Commanded Galactic Latitude (Degrees)
00153         AZ,                           // Commanded Azumuth (Degrees)
00154         EL,                           // Commanded Elevation (Degrees)
00155         INDX,                         // Indicated X Position (Degrees)
00156         INDY,                         // Indicated Y Position (Degrees)
00157         DESORG0,                      // Descriptive Origin (0) (Degrees)
00158         DESORG1,                      // Descriptive Origin (1) (Degrees)
00159         DESORG2,                      // Descriptive Origin (2) (Degrees)
00160         LAST_POSITIONS=17
00161     };
00162 
00163     enum Environment {
00164         TAMB=0,                       // Ambient temperature (C)
00165         PRESSURE,                     // Ambient Pressure (cm-Hg)
00166         HUMIDTY,                      // Ambient relative humidty (%)
00167         REFRAC,                       // Index of Refraction
00168         DEWPT,                        // Dew Point (C)
00169         MMH2O,                        // Mm of water
00170         LAST_ENVIRONMENT
00171     };
00172 
00173     enum MapParameters {
00174         SCANANG=0,                    // Map Scanning Angle (Degrees)
00175         XZERO,                        // X Position at Map Reference Position Zero
00176         YZERO,                        // Y Position at Map Reference Position Zero
00177         DELTAXR,                      // Delta X or X Rate (arcsec or arcsec/sec)
00178         DELTAYR,                      // Delta Y or Y Rate (arcsec or arcsec/sec)
00179         NOPTS,                        // Number of Grid Points
00180         NOXPTS,                       // Number of X Grid Points
00181         NOYPTS,                       // Number of Y Grid Points
00182         XCELL0,                       // Starting X Grid Cell Number
00183         YCELL0,                       // Starting Y Grid Cell Number
00184         LAST_MAP=11
00185     };
00186         
00187     enum DataParameters {
00188         BHWHM=0,                      // Beam Halfwidth at Half Maximum (arcsec)
00189         OFFSCAN,                      // Off Scan Number
00190         BADCHV,                       // Bad Channel Value (K)
00191         RVSYS,                        // Velocity Correction (km/s)
00192         VELOCITY,                     // Velocity with respect to Reference (km/s)
00193         LAST_DATA=7
00194     };
00195 
00196     enum EngineeringParameters {
00197         APPEFF=0,                     // Antenna Aperture Efficiency
00198         BEAMEFF,                      // Antenna Beam Efficiency
00199         ANTGAIN,                      // Antenna Gain
00200         ETAL,                         // Rear spill and scattering efficiency
00201         ETAFSS,                       // Forward spill and scattering efficiency
00202         LAST_ENGINEERING
00203     };
00204 
00205     enum GreenBank {
00206         L1=0,                         // MHz
00207         L1F1,                         // MHz
00208         L1F2,                         // MHz
00209         L2,                           // MHz
00210         L2F1,                         // MHz
00211         L2F2,                         // MHz
00212         LA,                           // MHz
00213         LB,                           // MHz
00214         LC,                           // MHz
00215         LD,                           // MHz
00216         LEVCORR,                      // Level Correction (Volts)
00217         PTFUDGE0,                     // Pointing Fudge (0) (arcmin)
00218         PTFUDGE1,                     // Pointing Fudge (1) (arcmin)
00219         RHO,                          // Degrees
00220         THETA,                        // Degrees
00221         LAST_GREENBANK=18
00222     };
00223 
00224     enum Tucson {
00225         SYNFREQ=0,                    // Synthesizer Frequency (MHz)
00226         LOFACT,                       // LO Factor
00227         HARMONIC,                     //
00228         LOIF,                         // MHz
00229         FIRSTIF,                      // MHz
00230         RAZOFF,                       // Reference Azimuth Offset (arcsec)
00231         RELOFF,                       // Reference Elevation Offset (arcsec)
00232         BMTHROW,                      // Beam Throw (arcsec)
00233         BMORENT,                      // Beam Orientation (Degrees)
00234         BASEOFF,                      // Baseline offset (K)
00235         OBSTOL,                       // Observing tolerance (arcsec)
00236         SIDEBAND,                     //
00237         WL,                           // Wavelength (mm)
00238         GAINS,                        // GAIN scan number
00239         PBEAM0,                       // + Beam(0) (arcsec)
00240         PBEAM1,                       // + Beam(1) (arcsec)
00241         MBEAM0,                       // - Beam(0) (arcsec)
00242         MBEAM1,                       // - Beam(1) (arcsec)
00243         SROFF0,                       // RA/Dec Offsets (0) (arcsec)
00244         SROFF1,                       // RA/Dec Offsets (1) (arcsec)
00245         SROFF2,                       // RA/Dec Offsets (2) (arcsec)
00246         SROFF3,                       // RA/Dec Offsets (3) (arcsec)
00247         FOFFSIG,                      // Frequency Switching Signal Offset (MHz)
00248         FOFFREF1,                     // Frequency SwitchinG Reference Offset 1 (MHz)
00249         FOFFREF2,                     // Frequency SwitchinG Reference Offset 2 (MHz)
00250         LAST_TUCSON
00251     };
00252 
00253     enum OriginalPhaseBlock {
00254         ORIGINAL_VARVAL=0,            // Variable Value
00255         LAST_ORIGINAL_PHASE=3
00256     };
00257     enum OriginalPhaseBlockStrings {
00258         ORIGINAL_VARDES=1,            // Variable Descriptor, 8 Characters
00259         ORIGINAL_PHASTB               // Phase Table - 8 characters
00260     };
00261 
00262     enum NewPhaseBlockBasics {
00263         NOSWVARF=0,                   // Number of Fast Switching Variables
00264         NUMCYC,                       // Number of Slow Cycles per Scan
00265         NUMCYCF,                      // Number of Fast Cycles per Scan
00266         NOPHASEF,                     // Number of Fast Phases per Cycle
00267         CYCLENF,                      // Length of Fast Cycle (seconds)
00268         SAMPTIMF,                     // Length of Fast Phase Sample (seconds)
00269         LAST_NEW_PHASE_BASICS
00270     };
00271     enum NewPhaseBlock {
00272         VARVAL=0,                     // Variable Value
00273         LAST_NEW_PHASE=6
00274     };
00275     enum NewPhaseBlockStrings {
00276         VARDES=1,                     // Variable Descript, 8 characters
00277         PHASTB                        // Phase Table, 32 characters
00278     };
00279 
00280     enum ReceiverBlock {
00281         OBSFREQ=0,                    // Observed Frequency
00282         RESTFREQ,                     // Rest Frequency
00283         FREQRES,                      // Frequency Resolution (LINE) (MHz) or
00284                                       // Scale Factor (CONT) (K/Count)
00285         BW,                           // Bandwidth (MHz)
00286         TRX,                          // Receiver Temperature (K)
00287         TCAL,                         // Calibration Temperature (K)
00288         STSYS,                        // Source System Temperature (K)
00289         RTSYS,                        // Reference System Temperature (K)
00290         TSOURCE,                      // Source Temperature (K)
00291         TRMS,                         // RMS of Mean (K)
00292         REFPT,                        // Reference Point Number
00293         X0,                           // X Value at REFPT (km/sec or degrees)
00294         DELTAX,                       // Delta X (km/sec or degrees)
00295         INTTIME,                      // Total integration time (seconds)
00296         NOINT,                        // Number of integrations
00297         SPN,                          // Starting Point Number
00298         TAUH2O,                       // H2O Opacity
00299         TH2O,                         // H2O Temperature (K)
00300         TAUO2,                        // O2 Opacity
00301         TO2,                          // O2 Temperature (K)
00302         EFFINT=21,                    // Effective Integration Time (sec)
00303         LAST_RECEIVER=24
00304     };
00305 
00306     enum ReductionParameters {
00307         NOSTAC=0,                       // Number of scans stacked
00308         FSCAN,                        // First scan in stack
00309         LSCAN,                        // Last scan in stack
00310         LAMP,                         // Line amplitude (K)
00311         LWID,                         // Line width (km/sec)
00312         ILI,                          // Integrated Line Intensity (K km/sec)
00313         RMS,                          // RMS Noise (K)
00314         LAST_REDUCTION
00315     };
00316 
00317     // construct an empty header block, minimal header, no data array
00318     SDDHeader();
00319     // construct one from istream, uses start of istream to determine how 
00320     // many records to use
00321     SDDHeader(istream& in);
00322     // copy constructor, true copy
00323     SDDHeader(const SDDHeader& other);
00324 
00325     // clean up the pointers
00326     ~SDDHeader();
00327 
00328     // assignment operator, true copy
00329     SDDHeader& operator=(const SDDHeader& other);
00330 
00331     // fill an existing SDDHeader from istream,  uses start of istream to determine how
00332     // many records to use, returns number of bytes actually read
00333     // the header is resized if necessary
00334     uInt fill(istream& in);
00335 
00336     // write to ostream, returns the number of bytes actually written
00337     uInt write(ostream& out) const;
00338 
00339     // empty out all the header words
00340     void empty();
00341 
00342     // Is it an NRAO telescope (12m or 140')
00343     Bool isNRAO() const;
00344     // Is it the 12m
00345     Bool is12m() const;
00346     // Is it the 140'
00347     Bool is140ft() const;
00348 
00349     // see if this is an OTF scan
00350     Bool isOTF() const;
00351 
00352     // The number of data vectors present (only !=1 for OTF amd POLZ data at present)
00353     uInt nvectors() const;
00354 
00355     // functions to retrieve and set parameters
00356     // for now, its just simpler to adopt the unipops rule and
00357     // do no sanity checks on any values (except the string header words)
00358 
00359     // for string header words, they must be less than the approproate length
00360     // or that string will not be set.
00361     String get(StringHeader field) const;
00362     Bool put(StringHeader field, const String& value);
00363 
00364     Double get(BasicInformation field) const;
00365     Bool put(BasicInformation field, const Double& value);
00366 
00367     Double get(PointingParameters field) const;
00368     Bool put(PointingParameters field, const Double& value);
00369 
00370     Double get(ObservingParameters field) const;
00371     Bool put(ObservingParameters field, const Double& value);
00372 
00373     Double get(Positions field) const;
00374     Bool put(Positions field, const Double& value);
00375     
00376     Double get(Environment field) const;
00377     Bool put(Environment field, const Double& value);
00378     
00379     Double get(MapParameters field) const;
00380     Bool put(MapParameters field, const Double& value);
00381 
00382     Double get(DataParameters field) const;
00383     Bool put(DataParameters field, const Double& value);
00384 
00385     Double get(EngineeringParameters field) const;
00386     Bool put(EngineeringParameters field, const Double& value);
00387     
00388     Double get(GreenBank field) const;
00389     Bool put(GreenBank field, const Double& value);
00390 
00391     Double get(Tucson field) const;
00392     Bool put(Tucson field, const Double& value);
00393 
00394     Double get(ReceiverBlock field) const;
00395     Bool put(ReceiverBlock field, const Double& value);
00396 
00397     Double get(ReductionParameters field) const;
00398     Bool put(ReductionParameters field, const Double& value);
00399 
00400     // Old class 11, need to specify which block as well as the field
00401     Double get(OriginalPhaseBlock, uInt whichBlock=0) const;
00402     Bool put(OriginalPhaseBlock field, const Double& value, 
00403              uInt whichBlock=0);
00404     // String get and put
00405     String get(OriginalPhaseBlockStrings field, uInt whichBlock=0) const;
00406     Bool put(OriginalPhaseBlockStrings field, const String& value, 
00407              uInt whichBlock=0);
00408 
00409     // New class 11, the basics are only at the start of the class
00410     Double get(NewPhaseBlockBasics field) const;
00411     Bool put(NewPhaseBlockBasics field, const Double& value);
00412     // And for the rest, the block needs to be specified
00413     Double get(NewPhaseBlock field, uInt whichBlock=0) const;
00414     Bool put(NewPhaseBlock field, const Double& value, uInt whichBlock);
00415     // Strings need get and put
00416     String get(NewPhaseBlockStrings field, uInt whichBlock=0) const;
00417     Bool put(NewPhaseBlockStrings field, const String& value, 
00418              uInt whichBlock=0);
00419 
00420 private:
00421     // this holds the preamble information
00422     Vector<Int> *preamble_p;
00423     // this actually holds the header
00424     SDDBlock *hdu_p;
00425 
00426     // helpful to stash these here
00427     Bool isOtf_p;
00428     uInt nvectors_p;
00429 
00430     // maps
00431     //  the GNU compiler doesn't seem to like it that this is static
00432     // I don't think its crucial so punt for now
00433     //   static Vector<uInt> nchars_p;
00434     Vector<uInt> nchars_p;
00435 
00436     Vector<uInt> strOffset_p;
00437 
00438     Double getFromClass(uInt whichClass, uInt offset) const;
00439     Bool putToClass(uInt whichClass, uInt offset, const Double& value);
00440 
00441     void init_nchars();
00442     void init_strOffset();
00443     uInt setOffset(uInt whichClass, uInt number) const;
00444 
00445     void putPreamble();
00446     void getPreamble();
00447 };
00448 
00449 #endif