casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MBrecord.h
Go to the documentation of this file.
00001 //#---------------------------------------------------------------------------
00002 //# MBrecord.h: Class to store an MBFITS single-dish data record.
00003 //#---------------------------------------------------------------------------
00004 //# livedata - processing pipeline for single-dish, multibeam spectral data.
00005 //# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
00006 //#
00007 //# This file is part of livedata.
00008 //#
00009 //# livedata is free software: you can redistribute it and/or modify it under
00010 //# the terms of the GNU General Public License as published by the Free
00011 //# Software Foundation, either version 3 of the License, or (at your option)
00012 //# any later version.
00013 //#
00014 //# livedata is distributed in the hope that it will be useful, but WITHOUT
00015 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00017 //# more details.
00018 //#
00019 //# You should have received a copy of the GNU General Public License along
00020 //# with livedata.  If not, see <http://www.gnu.org/licenses/>.
00021 //#
00022 //# Correspondence concerning livedata may be directed to:
00023 //#        Internet email: mcalabre@atnf.csiro.au
00024 //#        Postal address: Dr. Mark Calabretta
00025 //#                        Australia Telescope National Facility, CSIRO
00026 //#                        PO Box 76
00027 //#                        Epping NSW 1710
00028 //#                        AUSTRALIA
00029 //#
00030 //# http://www.atnf.csiro.au/computing/software/livedata.html
00031 //# $Id: MBrecord.h,v 19.16 2009-09-29 07:33:38 cal103 Exp $
00032 //#---------------------------------------------------------------------------
00033 //# The MBrecord class stores an MBFITS single-dish data record.
00034 //#
00035 //# Storage for spectral data may be managed in either of two ways:
00036 //#
00037 //#   1) The allocate() member function may be used to allocate storage that
00038 //#      is subsequently managed by the MBrecord class; the assignment
00039 //#      operator automatically deletes and reallocates more if insufficient
00040 //#      was provided, and the MBrecord destructor deletes it.
00041 //#
00042 //#      Allocation of storage for cross-polarization data is optional.
00043 //#
00044 //#   2) In some cases it may be desirable for the user to provide storage via
00045 //#      the 'spectra', and 'flagged' (and 'xpol') variables in order to avoid
00046 //#      in-core copying.  It is assumed that space has been provided for at
00047 //#      least nChan*nPol floats for 'spectra', nChan*nPol unsigned chars for
00048 //#      'flagged', and 2*nChan floats for 'xpol'.  This storage will not be
00049 //#      reassigned by the assignment operator nor deleted by the destructor.
00050 //#
00051 //# The two methods may not be mixed; allocate() checks that either
00052 //#
00053 //#   a) the 'spectra', 'flagged', and 'xpol' variables are null pointers,
00054 //#
00055 //#   b) storage was previously allocated via allocate().
00056 //#
00057 //# Original: 2000/08/01 Mark Calabretta, ATNF
00058 //#---------------------------------------------------------------------------
00059 
00060 #ifndef ATNF_MBRECORD_H
00061 #define ATNF_MBRECORD_H
00062 
00063 using namespace std;
00064 
00065 // <summary>
00066 // Class to store an MBFITS single-dish data record.
00067 // </summary>
00068 
00069 class MBrecord
00070 {
00071   public:
00072     // Default constructor allocates arrays for the required number of IFs.
00073     MBrecord(int nIF = 0);
00074 
00075     // Destructor; deletes any storage that may have been auto-allocated by
00076     // the assignment operator.
00077     ~MBrecord();
00078 
00079     // Expand arrays if necessary to accomodate the required number of IFs.
00080     void setNIFs(int nIF);
00081 
00082     // Ensure there is enough storage for the specified number of spectral
00083     // products (channels x polarizations) for IF with array index iif (i.e.
00084     // the actual IF number is IFno[iif]).  Expands arrays if necessary but
00085     // never contracts.
00086     void allocate(int iIF, int nprod, int nxpol);
00087 
00088     // Free all allocate()'d storage.
00089     void free();
00090 
00091     // The assignment operator does a deep copy and will auto-allocate or
00092     // re-allocate data storage if necessary.
00093     MBrecord &operator=(const MBrecord &other);
00094 
00095     // Extract a selected IF from a MBrecord into another.
00096     int extract(const MBrecord &other, int iIF);
00097 
00098     int    scanNo;              // Scan number.
00099     int    cycleNo;             // Integration cycle number.
00100     char   datobs[12];          // Date of observation YYYY-MM-DD.
00101     double utc;                 // UTC of the integration, s.
00102     float  exposure;            // Integration time, s.
00103     char   srcName[20];         // Source name.
00104     double srcRA;               // Source J2000 right ascension, radian.
00105     double srcDec;              // Source J2000 declination, radian.
00106     double restFreq;            // Line rest frequency, Hz.
00107     char   obsType[16];         // Two-letter observation type codes.
00108 
00109     // Beam-dependent parameters.
00110     short  beamNo;              // Multibeam beam number.
00111     double ra;                  // J2000 right ascension, radian.
00112     double dec;                 // J2000 declination, radian,
00113     int    pCode;               // Pointing problem code:
00114                                 //   1: position and timestamp unchanged,
00115                                 //   2: position changed but not timestamp,
00116                                 //   3: position and timestamp are rubbish,
00117                                 //   4: timestamp/1000 scale error (repaired),
00118                                 //   5: timestamp late by 1.0 sec (repaired),
00119                                 //   6: timestamp late by 0.5 sec (repaired).
00120     float  rateAge;             // Scan rate age (staleness), s.
00121     float  raRate;              // Scan rate in right ascension, radian/s.
00122     float  decRate;             // Scan rate in declination, radian/s.
00123     float  paRate;              // Rate of change of position angle, radian/s.
00124 
00125     // IF-dependent parameters.
00126     short  nIF;                 // Number of IFs.
00127     short  *IFno;               // IF number.
00128     int    *nChan;              // Number of channels.
00129     int    *nPol;               // Number of polarizations.
00130     float  *fqRefPix;           // Frequency reference pixel.
00131     double *fqRefVal;           // Frequency reference value, Hz.
00132     double *fqDelt;             // Frequency separation between channels, Hz.
00133     float  (*tsys)[2];          // Tsys for each polarization, Jy.
00134     float  (*calfctr)[2];       // Calibration factor for each polarization.
00135     float  (*xcalfctr)[2];      // Calibration factor for cross-polarizations.
00136     int    haveBase;            // Are baseline parameters present?
00137     float  (*baseLin)[2][2];    // Linear baseline fit for each polarization.
00138     float  (*baseSub)[2][24];   // Polynomial baseline subtracted.
00139     int    haveSpectra;         // Is spectral data present?
00140     float* *spectra;            // Spectra for each polarization, Jy.
00141     unsigned char* *flagged;    // Channel flagging, 0 = good, else bad.
00142     float* *xpol;               // Cross polarization spectra (if any).
00143 
00144     // Only present for Parkes Multibeam or LBA data after 1997/02/02.
00145     float   (*tcal)[2];         // Tcal for each polarization.
00146 
00147     // Extra syscal data available for Parkes Multibeam observations only.
00148     int    extraSysCal;         // Is this extra SysCal data available?
00149 
00150     float  azimuth;             // Azimuth, radian.
00151     float  elevation;           // Elevation, radian.
00152     float  parAngle;            // Parallactic angle, radian.
00153 
00154     float  focusAxi;            // Axial focus position, m.
00155     float  focusTan;            // Focus platform translation, m.
00156     float  focusRot;            // Focus rotation, radian.
00157 
00158     float  temp;                // Temperature, C.
00159     float  pressure;            // Pressure, Pa.
00160     float  humidity;            // Relative humidity, %.
00161     float  windSpeed;           // Wind speed, m/s.
00162     float  windAz;              // Wind azimuth, radian.
00163 
00164     char   tcalTime[20];        // Time of measurement of cal signals.
00165 
00166     short  refBeam;             // Reference beam, in beam-switching (MX)
00167                                 // mode (added 1999/03/17).
00168     int polNo ;                 // polarization ID
00169     double srcVelocity ;        // source velocity w.r.t. reference frame
00170 
00171     int srcType ;               // source type
00172 
00173   private:
00174     int    cNIF;                // Number of IFs allocated.
00175     int*   cNProd;              // Storage allocated for data.
00176     int*   cNXPol;              // Storage allocated for xpol.
00177 };
00178 
00179 #endif