[1868] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# GBTFITSreader.h: CFITSIO interface class for GBT SDFITS input.
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# livedata - processing pipeline for single-dish, multibeam spectral data.
|
---|
| 5 | //# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
|
---|
| 6 | //#
|
---|
| 7 | //# This file is part of livedata.
|
---|
| 8 | //#
|
---|
| 9 | //# livedata is free software: you can redistribute it and/or modify it under
|
---|
| 10 | //# the terms of the GNU General Public License as published by the Free
|
---|
| 11 | //# Software Foundation, either version 3 of the License, or (at your option)
|
---|
| 12 | //# any later version.
|
---|
| 13 | //#
|
---|
| 14 | //# livedata is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 15 | //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
| 16 | //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
---|
| 17 | //# more details.
|
---|
| 18 | //#
|
---|
| 19 | //# You should have received a copy of the GNU General Public License along
|
---|
| 20 | //# with livedata. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 21 | //#
|
---|
| 22 | //# Correspondence concerning livedata may be directed to:
|
---|
| 23 | //# Internet email: mcalabre@atnf.csiro.au
|
---|
| 24 | //# Postal address: Dr. Mark Calabretta
|
---|
| 25 | //# Australia Telescope National Facility, CSIRO
|
---|
| 26 | //# PO Box 76
|
---|
| 27 | //# Epping NSW 1710
|
---|
| 28 | //# AUSTRALIA
|
---|
| 29 | //#
|
---|
| 30 | //# http://www.atnf.csiro.au/computing/software/livedata.html
|
---|
| 31 | //# $Id: SDFITSreader.h,v 19.22 2009-09-29 07:33:39 cal103 Exp $
|
---|
| 32 | //#---------------------------------------------------------------------------
|
---|
| 33 | //# The GBTFITSreader class reads single dish FITS files from Green Bank
|
---|
| 34 | //# telescopes. This class is actually a specific version of SDFITSreader.
|
---|
| 35 | //#
|
---|
| 36 | //# Original: 2000/08/09, Mark Calabretta, ATNF
|
---|
| 37 | //# Update: 2010/07/29, Takeshi Nakazato, NAOJ
|
---|
| 38 | //#---------------------------------------------------------------------------
|
---|
| 39 |
|
---|
| 40 | #ifndef ATNF_GBTFITSREADER_H
|
---|
| 41 | #define ATNF_GBTFITSREADER_H
|
---|
| 42 |
|
---|
| 43 | #include <atnf/PKSIO/FITSreader.h>
|
---|
| 44 | #include <atnf/PKSIO/MBrecord.h>
|
---|
| 45 |
|
---|
| 46 | #include <casa/Logging/LogIO.h>
|
---|
| 47 | #include <casa/Arrays/Vector.h>
|
---|
| 48 |
|
---|
| 49 | #include <fitsio.h>
|
---|
| 50 |
|
---|
| 51 | using namespace std;
|
---|
| 52 | using namespace casa;
|
---|
| 53 |
|
---|
| 54 | // <summary>
|
---|
| 55 | // class for GBT SDFITS input using CFITSIO.
|
---|
| 56 | // </summary>
|
---|
| 57 |
|
---|
| 58 | class GBTFITSreader : public FITSreader
|
---|
| 59 | {
|
---|
| 60 | public:
|
---|
| 61 | // Default constructor.
|
---|
| 62 | GBTFITSreader();
|
---|
| 63 |
|
---|
| 64 | // Destructor.
|
---|
| 65 | virtual ~GBTFITSreader();
|
---|
| 66 |
|
---|
| 67 | // Open an SDFITS file for reading.
|
---|
| 68 | virtual int open(
|
---|
| 69 | char* sdname,
|
---|
| 70 | int &nBeam,
|
---|
| 71 | int* &beams,
|
---|
| 72 | int &nIF,
|
---|
| 73 | int* &IFs,
|
---|
| 74 | int* &nChan,
|
---|
| 75 | int* &nPol,
|
---|
| 76 | int* &haveXPol,
|
---|
| 77 | int &haveBase,
|
---|
| 78 | int &haveSpectra,
|
---|
| 79 | int &extraSysCal);
|
---|
| 80 |
|
---|
| 81 | // Get parameters describing the data.
|
---|
| 82 | virtual int getHeader(
|
---|
| 83 | char observer[32],
|
---|
| 84 | char project[32],
|
---|
| 85 | char telescope[32],
|
---|
| 86 | double antPos[3],
|
---|
| 87 | char obsMode[32],
|
---|
| 88 | char bunit[32],
|
---|
| 89 | float &equinox,
|
---|
| 90 | char radecsys[32],
|
---|
| 91 | char dopplerFrame[32],
|
---|
| 92 | char datobs[32],
|
---|
| 93 | double &utc,
|
---|
| 94 | double &refFreq,
|
---|
| 95 | double &bandwidth);
|
---|
| 96 |
|
---|
| 97 | // Get frequency parameters for each IF.
|
---|
| 98 | virtual int getFreqInfo(
|
---|
| 99 | int &nIF,
|
---|
| 100 | double* &startFreq,
|
---|
| 101 | double* &endFreq);
|
---|
| 102 |
|
---|
| 103 | // Find the range of the data selected in time and position.
|
---|
| 104 | virtual int findRange(
|
---|
| 105 | int &nRow,
|
---|
| 106 | int &nSel,
|
---|
| 107 | char dateSpan[2][32],
|
---|
| 108 | double utcSpan[2],
|
---|
| 109 | double* &positions);
|
---|
| 110 |
|
---|
| 111 | // Read the next data record.
|
---|
| 112 | virtual int read(MBrecord &record);
|
---|
| 113 |
|
---|
| 114 | // Close the SDFITS file.
|
---|
| 115 | virtual void close(void);
|
---|
| 116 |
|
---|
| 117 | private:
|
---|
| 118 | int cCycleNo, cExtraSysCal, cNAxes, cStatus;
|
---|
| 119 | long cBeamAxis, cDecAxis, cFreqAxis, cNAxis[5], cNAxisTime, cNRow,
|
---|
| 120 | cRaAxis, cRow, cStokesAxis, cTimeAxis, cTimeIdx;
|
---|
| 121 | double cLastUTC;
|
---|
| 122 | fitsfile *cSDptr;
|
---|
| 123 | class FITSparm *cData;
|
---|
| 124 |
|
---|
| 125 | // These are to differentiate 0-, and 1-relative beam and IF numbering.
|
---|
| 126 | int cBeam_1rel, cIF_1rel;
|
---|
| 127 |
|
---|
| 128 | // for GBT
|
---|
| 129 | int *cPols ;
|
---|
| 130 |
|
---|
| 131 | enum {SCAN, CYCLE, DATE_OBS, TIME, EXPOSURE, OBJECT, OBJ_RA, OBJ_DEC,
|
---|
| 132 | RESTFRQ, OBSMODE, BEAM, IF, FqRefVal, FqDelt, FqRefPix, RA, DEC,
|
---|
| 133 | TimeRefVal, TimeDelt, TimeRefPix, SCANRATE, TSYS, CALFCTR, XCALFCTR,
|
---|
| 134 | BASELIN, BASESUB, DATA, FLAGGED, DATAXED, XPOLDATA, REFBEAM, TCAL,
|
---|
| 135 | TCALTIME, AZIMUTH, ELEVATIO, PARANGLE, FOCUSAXI, FOCUSTAN, FOCUSROT,
|
---|
| 136 | TAMBIENT, PRESSURE, HUMIDITY, WINDSPEE, WINDDIRE, STOKES, SIG, CAL,
|
---|
| 137 | VFRAME, RVSYS, VELDEF, TIMESTAMP, DURATION, SAMPLER, NDATA};
|
---|
| 138 |
|
---|
| 139 | // Message handling.
|
---|
| 140 | void log(LogOrigin origin, LogIO::Command cmd, const char *msg = 0x0);
|
---|
| 141 |
|
---|
| 142 | void findData(int iData, char *name, int type);
|
---|
| 143 | void findCol(char *name, int *colnum);
|
---|
| 144 | int readDim(int iData, long iRow, int *naxis, long naxes[]);
|
---|
| 145 | int readParm(char *name, int type, void *value);
|
---|
| 146 | int readData(char *name, int type, long iRow, void *value);
|
---|
| 147 | int readData(int iData, long iRow, void *value);
|
---|
| 148 | int readCol(int iData, void *value);
|
---|
| 149 | int readTime(long iRow, int iPix, char *datobs, double &utc);
|
---|
| 150 |
|
---|
| 151 | // These are for ALFA data: "BDFITS" or "CIMAFITS". Statics are required
|
---|
| 152 | // for CIMAFITS v2.0 because CAL ON/OFF data is split into separate files.
|
---|
| 153 | static int sInit, sReset;
|
---|
| 154 | static int (*sALFAcalNon)[2], (*sALFAcalNoff)[2];
|
---|
| 155 | static float (*sALFAcal)[2], (*sALFAcalOn)[2], (*sALFAcalOff)[2];
|
---|
| 156 |
|
---|
| 157 | int cALFA, cALFA_BD, cALFA_CIMA, cALFAscan, cScanNo;
|
---|
| 158 | float cALFAacc;
|
---|
| 159 | int alfaCal(short iBeam, short iIF, short iPol);
|
---|
| 160 | float alfaGain(float zd);
|
---|
| 161 |
|
---|
| 162 | // For multiple binary table SDFITS (GBT)
|
---|
| 163 | long cRowRelative( long iRow ) ;
|
---|
| 164 | Vector<Int> nIFPerHDU() ;
|
---|
| 165 | Double getRefValLSR( int irow ) ;
|
---|
| 166 | Double getRefValLSR( long iRow, int idx, char *sampler, double restfreq ) ;
|
---|
| 167 | Int mergeIFPerHDU( int start, int n ) ;
|
---|
| 168 |
|
---|
| 169 | // These are for GBT data.
|
---|
| 170 | int cGBT, cFirstScanNo;
|
---|
| 171 | double cGLastUTC[4] ;
|
---|
| 172 | int cGLastScan[4] ;
|
---|
| 173 | int cGCycleNo[4] ;
|
---|
| 174 | long *cNRowT ;
|
---|
| 175 | long *cNRowCum ;
|
---|
| 176 | int *hduId ;
|
---|
| 177 | int numHDU ;
|
---|
| 178 | vector<String> cRefValKey ;
|
---|
| 179 | vector<double> cRefVal ;
|
---|
| 180 | vector<double> cIncVal ;
|
---|
| 181 | Vector<Int> cIFNO ;
|
---|
| 182 | vector<int> cNumKeys ;
|
---|
| 183 | //double cAntPos[3] ;
|
---|
| 184 | };
|
---|
| 185 |
|
---|
| 186 | #endif
|
---|