| 1 | //#---------------------------------------------------------------------------
 | 
|---|
| 2 | //# PKSMBrecord.h: Class to store an MBFITS single-dish data record.
 | 
|---|
| 3 | //#---------------------------------------------------------------------------
 | 
|---|
| 4 | //# Copyright (C) 2000-2008
 | 
|---|
| 5 | //# Mark Calabretta, ATNF
 | 
|---|
| 6 | //#
 | 
|---|
| 7 | //# This library is free software; you can redistribute it and/or modify it
 | 
|---|
| 8 | //# under the terms of the GNU Library General Public License as published by
 | 
|---|
| 9 | //# the Free Software Foundation; either version 2 of the License, or (at your
 | 
|---|
| 10 | //# option) any later version.
 | 
|---|
| 11 | //#
 | 
|---|
| 12 | //# This library is distributed in the hope that it will be useful, but WITHOUT
 | 
|---|
| 13 | //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 | 
|---|
| 14 | //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 | 
|---|
| 15 | //# License for more details.
 | 
|---|
| 16 | //#
 | 
|---|
| 17 | //# You should have received a copy of the GNU Library General Public License
 | 
|---|
| 18 | //# along with this library; if not, write to the Free Software Foundation,
 | 
|---|
| 19 | //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 20 | //#
 | 
|---|
| 21 | //# Correspondence concerning this software should be addressed as follows:
 | 
|---|
| 22 | //#        Internet email: mcalabre@atnf.csiro.au.
 | 
|---|
| 23 | //#        Postal address: Dr. Mark Calabretta,
 | 
|---|
| 24 | //#                        Australia Telescope National Facility,
 | 
|---|
| 25 | //#                        P.O. Box 76,
 | 
|---|
| 26 | //#                        Epping, NSW, 2121,
 | 
|---|
| 27 | //#                        AUSTRALIA
 | 
|---|
| 28 | //#
 | 
|---|
| 29 | //# $Id: PKSMBrecord.h,v 19.9 2008-06-26 02:10:21 cal103 Exp $
 | 
|---|
| 30 | //#---------------------------------------------------------------------------
 | 
|---|
| 31 | //# The PKSMBrecord class stores an MBFITS single-dish data record.
 | 
|---|
| 32 | //#
 | 
|---|
| 33 | //# Storage for spectral data may be managed in either of two ways:
 | 
|---|
| 34 | //#
 | 
|---|
| 35 | //#   1) The allocate() member function may be used to allocate storage that
 | 
|---|
| 36 | //#      is subsequently managed by the PKSMBrecord class; the assignment
 | 
|---|
| 37 | //#      operator automatically deletes and reallocates more if insufficient
 | 
|---|
| 38 | //#      was provided, and the PKSMBrecord destructor deletes it.
 | 
|---|
| 39 | //#
 | 
|---|
| 40 | //#      Allocation of storage for cross-polarization data is optional.
 | 
|---|
| 41 | //#
 | 
|---|
| 42 | //#   2) In some cases it may be desirable for the user to provide storage via
 | 
|---|
| 43 | //#      the 'spectra', and 'flagged' (and 'xpol') variables in order to avoid
 | 
|---|
| 44 | //#      in-core copying.  It is assumed that space has been provided for at
 | 
|---|
| 45 | //#      least nChan*nPol floats for 'spectra', nChan*nPol unsigned chars for
 | 
|---|
| 46 | //#      'flagged', and 2*nChan floats for 'xpol'.  This storage will not be
 | 
|---|
| 47 | //#      reassigned by the assignment operator nor deleted by the destructor.
 | 
|---|
| 48 | //#
 | 
|---|
| 49 | //# The two methods may not be mixed; allocate() checks that either
 | 
|---|
| 50 | //#
 | 
|---|
| 51 | //#   a) the 'spectra', 'flagged', and 'xpol' variables are null pointers,
 | 
|---|
| 52 | //#
 | 
|---|
| 53 | //#   b) storage was previously allocated via allocate().
 | 
|---|
| 54 | //#
 | 
|---|
| 55 | //# Original: 2000/08/01 Mark Calabretta, ATNF
 | 
|---|
| 56 | //#---------------------------------------------------------------------------
 | 
|---|
| 57 | 
 | 
|---|
| 58 | #ifndef ATNF_PKSMBRECORD_H
 | 
|---|
| 59 | #define ATNF_PKSMBRECORD_H
 | 
|---|
| 60 | 
 | 
|---|
| 61 | // <summary>
 | 
|---|
| 62 | // Class to store an MBFITS single-dish data record.
 | 
|---|
| 63 | // </summary>
 | 
|---|
| 64 | 
 | 
|---|
| 65 | class PKSMBrecord
 | 
|---|
| 66 | {
 | 
|---|
| 67 |   public:
 | 
|---|
| 68 |     // Default constructor allocates arrays for the required number of IFs.
 | 
|---|
| 69 |     PKSMBrecord(int nIF = 0);
 | 
|---|
| 70 | 
 | 
|---|
| 71 |     // Destructor; deletes any storage that may have been auto-allocated by
 | 
|---|
| 72 |     // the assignment operator.
 | 
|---|
| 73 |     ~PKSMBrecord();
 | 
|---|
| 74 | 
 | 
|---|
| 75 |     // Expand arrays if necessary to accomodate the required number of IFs.
 | 
|---|
| 76 |     void setNIFs(int nIF);
 | 
|---|
| 77 | 
 | 
|---|
| 78 |     // Ensure there is enough storage for the specified number of spectral
 | 
|---|
| 79 |     // products (channels x polarizations) for IF with array index iif (i.e.
 | 
|---|
| 80 |     // the actual IF number is IFno[iif]).  Expands arrays if necessary but
 | 
|---|
| 81 |     // never contracts.
 | 
|---|
| 82 |     void allocate(int iIF, int nprod, int nxpol);
 | 
|---|
| 83 | 
 | 
|---|
| 84 |     // Free all allocate()'d storage.
 | 
|---|
| 85 |     void free();
 | 
|---|
| 86 | 
 | 
|---|
| 87 |     // The assignment operator does a deep copy and will auto-allocate or
 | 
|---|
| 88 |     // re-allocate data storage if necessary.
 | 
|---|
| 89 |     PKSMBrecord &operator=(const PKSMBrecord &other);
 | 
|---|
| 90 | 
 | 
|---|
| 91 |     // Extract a selected IF from a PKSMBrecord into another.
 | 
|---|
| 92 |     int extract(const PKSMBrecord &other, int iIF);
 | 
|---|
| 93 | 
 | 
|---|
| 94 |     int    scanNo;              // Scan number.
 | 
|---|
| 95 |     int    cycleNo;             // Integration cycle number.
 | 
|---|
| 96 |     char   datobs[11];          // Date of observation YYYY-MM-DD.
 | 
|---|
| 97 |     double utc;                 // UTC of the integration, s.
 | 
|---|
| 98 |     float  exposure;            // Integration time, s.
 | 
|---|
| 99 |     char   srcName[17];         // Source name.
 | 
|---|
| 100 |     double srcRA;               // Source J2000 right ascension, radian.
 | 
|---|
| 101 |     double srcDec;              // Source J2000 declination, radian.
 | 
|---|
| 102 |     double restFreq;            // Line rest frequency, Hz.
 | 
|---|
| 103 |     char   obsType[16];         // Two-letter observation type codes.
 | 
|---|
| 104 | 
 | 
|---|
| 105 |     // Beam-dependent parameters.
 | 
|---|
| 106 |     short  beamNo;              // Multibeam beam number.
 | 
|---|
| 107 |     double ra;                  // J2000 right ascension, radian.
 | 
|---|
| 108 |     double dec;                 // J2000 declination, radian,
 | 
|---|
| 109 |     float  raRate;              // Scan rate in right ascension, radian/s.
 | 
|---|
| 110 |     float  decRate;             // Scan rate in declination, radian/s.
 | 
|---|
| 111 |     short  rateAge;             // Scan rate age (staleness), cycles.
 | 
|---|
| 112 |     short  rateson;             // Staleness reason code:
 | 
|---|
| 113 |                                 //   1: position and timestamp unchanged,
 | 
|---|
| 114 |                                 //   2: position changed but not timestamp,
 | 
|---|
| 115 |                                 //   3: position timestamp went backwards.
 | 
|---|
| 116 | 
 | 
|---|
| 117 |     // IF-dependent parameters.
 | 
|---|
| 118 |     short  nIF;                 // Number of IFs.
 | 
|---|
| 119 |     short  *IFno;               // IF number.
 | 
|---|
| 120 |     int    *nChan;              // Number of channels.
 | 
|---|
| 121 |     int    *nPol;               // Number of polarizations.
 | 
|---|
| 122 |     float  *fqRefPix;           // Frequency reference pixel.
 | 
|---|
| 123 |     double *fqRefVal;           // Frequency reference value, Hz.
 | 
|---|
| 124 |     double *fqDelt;             // Frequency separation between channels, Hz.
 | 
|---|
| 125 |     float  (*tsys)[2];          // Tsys for each polarization, Jy.
 | 
|---|
| 126 |     float  (*calfctr)[2];       // Calibration factor for each polarization.
 | 
|---|
| 127 |     float  (*xcalfctr)[2];      // Calibration factor for cross-polarizations.
 | 
|---|
| 128 |     int    haveBase;            // Are baseline parameters present?
 | 
|---|
| 129 |     float  (*baseLin)[2][2];    // Linear baseline fit for each polarization.
 | 
|---|
| 130 |     float  (*baseSub)[2][9];    // Polynomial baseline subtracted.
 | 
|---|
| 131 |     int    haveSpectra;         // Is spectral data present?
 | 
|---|
| 132 |     float* *spectra;            // Spectra for each polarization, Jy.
 | 
|---|
| 133 |     unsigned char* *flagged;    // Channel flagging, 0 = good, else bad.
 | 
|---|
| 134 |     float* *xpol;               // Cross polarization spectra (if any).
 | 
|---|
| 135 | 
 | 
|---|
| 136 |     // Only present for Parkes Multibeam or LBA data after 1997/02/02.
 | 
|---|
| 137 |     float   (*tcal)[2];         // Tcal for each polarization.
 | 
|---|
| 138 | 
 | 
|---|
| 139 |     // Extra syscal data available for Parkes Multibeam observations only.
 | 
|---|
| 140 |     int    extraSysCal;         // Is this extra SysCal data available?
 | 
|---|
| 141 |     float  azimuth;             // Azimuth, radian.
 | 
|---|
| 142 |     float  elevation;           // Elevation, radian.
 | 
|---|
| 143 |     float  parAngle;            // Parallactic angle, radian.
 | 
|---|
| 144 |     float  focusAxi;            // Axial focus position, m.
 | 
|---|
| 145 |     float  focusTan;            // Focus platform translation, m.
 | 
|---|
| 146 |     float  focusRot;            // Focus rotation, radian.
 | 
|---|
| 147 |     float  temp;                // Temperature, C.
 | 
|---|
| 148 |     float  pressure;            // Pressure, Pa.
 | 
|---|
| 149 |     float  humidity;            // Relative humidity, %.
 | 
|---|
| 150 |     float  windSpeed;           // Wind speed, m/s.
 | 
|---|
| 151 |     float  windAz;              // Wind azimuth, radian.
 | 
|---|
| 152 |     char   tcalTime[17];        // Time of measurement of cal signals.
 | 
|---|
| 153 |     short  refBeam;             // Reference beam, in beam-switching (MX)
 | 
|---|
| 154 |                                 // mode, added 1999/03/17.
 | 
|---|
| 155 | 
 | 
|---|
| 156 |   private:
 | 
|---|
| 157 |     int    cNIF;                // Number of IFs allocated.
 | 
|---|
| 158 |     int*   cNProd;              // Storage allocated for data.
 | 
|---|
| 159 |     int*   cNXPol;              // Storage allocated for xpol.
 | 
|---|
| 160 | };
 | 
|---|
| 161 | 
 | 
|---|
| 162 | #endif
 | 
|---|