casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SDFITSreader.h
Go to the documentation of this file.
00001 //#---------------------------------------------------------------------------
00002 //# SDFITSreader.h: ATNF CFITSIO interface class for SDFITS input.
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: SDFITSreader.h,v 19.22 2009-09-29 07:33:39 cal103 Exp $
00032 //#---------------------------------------------------------------------------
00033 //# The SDFITSreader class reads single dish FITS files such as those written
00034 //# by SDFITSwriter containing Parkes Multibeam data.
00035 //#
00036 //# Original: 2000/08/09, Mark Calabretta, ATNF
00037 //#---------------------------------------------------------------------------
00038 
00039 #ifndef ATNF_SDFITSREADER_H
00040 #define ATNF_SDFITSREADER_H
00041 
00042 #include <atnf/PKSIO/FITSreader.h>
00043 #include <atnf/PKSIO/MBrecord.h>
00044 
00045 #include <casa/Logging/LogIO.h>
00046 
00047 #include <fitsio.h>
00048 
00049 using namespace std;
00050 using namespace casa;
00051 
00052 // <summary>
00053 // ATNF class for SDFITS input using CFITSIO.
00054 // </summary>
00055 
00056 class SDFITSreader : public FITSreader
00057 {
00058   public:
00059     // Default constructor.
00060     SDFITSreader();
00061 
00062     // Destructor.
00063     virtual ~SDFITSreader();
00064 
00065     // Open an SDFITS file for reading.
00066     virtual int open(
00067         char*  sdname,
00068         int    &nBeam,
00069         int*   &beams,
00070         int    &nIF,
00071         int*   &IFs,
00072         int*   &nChan,
00073         int*   &nPol,
00074         int*   &haveXPol,
00075         int    &haveBase,
00076         int    &haveSpectra,
00077         int    &extraSysCal);
00078 
00079     // Get parameters describing the data.
00080     virtual int getHeader(
00081         char   observer[32],
00082         char   project[32],
00083         char   telescope[32],
00084         double antPos[3],
00085         char   obsMode[32],
00086         char   bunit[32],
00087         float  &equinox,
00088         char   radecsys[32],
00089         char   dopplerFrame[32],
00090         char   datobs[32],
00091         double &utc,
00092         double &refFreq,
00093         double &bandwidth);
00094 
00095     // Get frequency parameters for each IF.
00096     virtual int getFreqInfo(
00097         int     &nIF,
00098         double* &startFreq,
00099         double* &endFreq);
00100 
00101     // Find the range of the data selected in time and position.
00102     virtual int findRange(
00103         int    &nRow,
00104         int    &nSel,
00105         char   dateSpan[2][32],
00106         double utcSpan[2],
00107         double* &positions);
00108 
00109     // Read the next data record.
00110     virtual int read(MBrecord &record);
00111 
00112     // Close the SDFITS file.
00113     virtual void close(void);
00114 
00115   private:
00116     int      cCycleNo, cExtraSysCal, cNAxes, cStatus;
00117     long     cBeamAxis, cDecAxis, cFreqAxis, cNAxis[5], cNAxisTime, cNRow,
00118              cRaAxis, cRow, cStokesAxis, cTimeAxis, cTimeIdx;
00119     double   cLastUTC;
00120     fitsfile *cSDptr;
00121     class FITSparm *cData;
00122 
00123     // These are to differentiate 0-, and 1-relative beam and IF numbering.
00124     int  cBeam_1rel, cIF_1rel;
00125 
00126     // for GBT
00127     int *cPols ;
00128 
00129     enum {SCAN, CYCLE, DATE_OBS, TIME, EXPOSURE, OBJECT, OBJ_RA, OBJ_DEC,
00130           RESTFRQ, OBSMODE, BEAM, IF, FqRefVal, FqDelt, FqRefPix, RA, DEC,
00131           TimeRefVal, TimeDelt, TimeRefPix, SCANRATE, TSYS, CALFCTR, XCALFCTR,
00132           BASELIN, BASESUB, DATA, FLAGGED, DATAXED, XPOLDATA, REFBEAM, TCAL,
00133           TCALTIME, AZIMUTH, ELEVATIO, PARANGLE, FOCUSAXI, FOCUSTAN, FOCUSROT,
00134           TAMBIENT, PRESSURE, HUMIDITY, WINDSPEE, WINDDIRE, STOKES, SIG, CAL, 
00135           VFRAME, RVSYS, VELDEF, NDATA};
00136 
00137     // Message handling.
00138     void log(LogOrigin origin, LogIO::Command cmd, const char *msg = 0x0);
00139 
00140     void findData(int iData, char *name, int type);
00141     void  findCol(char *name, int *colnum);
00142     int   readDim(int iData, long iRow, int *naxis, long naxes[]);
00143     int  readParm(char *name, int type, void *value);
00144     int  readData(char *name, int type, long iRow, void *value);
00145     int  readData(int iData, long iRow, void *value);
00146     int  readCol(int iData, void *value);
00147     int  readTime(long iRow, int iPix, char *datobs, double &utc);
00148 
00149     // These are for ALFA data: "BDFITS" or "CIMAFITS".  Statics are required
00150     // for CIMAFITS v2.0 because CAL ON/OFF data is split into separate files.
00151     static int  sInit, sReset;
00152     static int  (*sALFAcalNon)[2], (*sALFAcalNoff)[2];
00153     static float (*sALFAcal)[2], (*sALFAcalOn)[2], (*sALFAcalOff)[2];
00154 
00155     int   cALFA, cALFA_BD, cALFA_CIMA, cALFAscan, cScanNo;
00156     float cALFAacc;
00157     int   alfaCal(short iBeam, short iIF, short iPol);
00158     float alfaGain(float zd);
00159 
00160     // These are for GBT data.
00161     int   cGBT, cFirstScanNo;
00162     double cGLastUTC[4] ;
00163     int cGLastScan[4] ;
00164     int cGCycleNo[4] ;
00165 };
00166 
00167 #endif