1 | //#---------------------------------------------------------------------------
|
---|
2 | //# MBFITSreader.h: ATNF single-dish RPFITS reader.
|
---|
3 | //#---------------------------------------------------------------------------
|
---|
4 | //# Copyright (C) 2000-2007
|
---|
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: MBFITSreader.h,v 19.21 2008-11-17 06:33:10 cal103 Exp $
|
---|
30 | //#---------------------------------------------------------------------------
|
---|
31 | //# The MBFITSreader class reads single dish RPFITS files (such as Parkes
|
---|
32 | //# Multibeam MBFITS files).
|
---|
33 | //#
|
---|
34 | //# Original: 2000/07/28 Mark Calabretta
|
---|
35 | //#---------------------------------------------------------------------------
|
---|
36 |
|
---|
37 | #ifndef ATNF_MBFITSREADER_H
|
---|
38 | #define ATNF_MBFITSREADER_H
|
---|
39 |
|
---|
40 | #include <atnf/PKSIO/FITSreader.h>
|
---|
41 | #include <atnf/PKSIO/MBrecord.h>
|
---|
42 |
|
---|
43 | using namespace std;
|
---|
44 |
|
---|
45 | // <summary>
|
---|
46 | // ATNF single-dish RPFITS reader.
|
---|
47 | // </summary>
|
---|
48 |
|
---|
49 | class MBFITSreader : public FITSreader
|
---|
50 | {
|
---|
51 | public:
|
---|
52 | // Default constructor; position interpolation codes are:
|
---|
53 | // 0: no interpolation,
|
---|
54 | // 1: correct interpolation,
|
---|
55 | // 2: pksmbfits interpolation.
|
---|
56 | MBFITSreader(const int retry = 0, const int interpolate = 1);
|
---|
57 |
|
---|
58 | // Destructor.
|
---|
59 | virtual ~MBFITSreader();
|
---|
60 |
|
---|
61 | // Open the RPFITS file for reading.
|
---|
62 | virtual int open(
|
---|
63 | char *rpname,
|
---|
64 | int &nBeam,
|
---|
65 | int* &beams,
|
---|
66 | int &nIF,
|
---|
67 | int* &IFs,
|
---|
68 | int* &nChan,
|
---|
69 | int* &nPol,
|
---|
70 | int* &haveXPol,
|
---|
71 | int &haveBase,
|
---|
72 | int &haveSpectra,
|
---|
73 | int &extraSysCal);
|
---|
74 |
|
---|
75 | // Get parameters describing the data.
|
---|
76 | virtual int getHeader(
|
---|
77 | char observer[32],
|
---|
78 | char project[32],
|
---|
79 | char telescope[32],
|
---|
80 | double antPos[3],
|
---|
81 | char obsType[32],
|
---|
82 | char bunit[32],
|
---|
83 | float &equinox,
|
---|
84 | char radecsys[32],
|
---|
85 | char dopplerFrame[32],
|
---|
86 | char datobs[32],
|
---|
87 | double &utc,
|
---|
88 | double &refFreq,
|
---|
89 | double &bandwidth);
|
---|
90 |
|
---|
91 | // Get frequency parameters for each IF.
|
---|
92 | virtual int getFreqInfo(
|
---|
93 | int &nIF,
|
---|
94 | double* &startFreq,
|
---|
95 | double* &endFreq);
|
---|
96 |
|
---|
97 | // Find the range of the data selected in time and position.
|
---|
98 | virtual int findRange(
|
---|
99 | int &nRow,
|
---|
100 | int &nSel,
|
---|
101 | char dateSpan[2][32],
|
---|
102 | double utcSpan[2],
|
---|
103 | double* &positions);
|
---|
104 |
|
---|
105 | // Read the next data record.
|
---|
106 | virtual int read(MBrecord &record);
|
---|
107 |
|
---|
108 | // Close the RPFITS file.
|
---|
109 | virtual void close(void);
|
---|
110 |
|
---|
111 | private:
|
---|
112 | // RPFITSIN subroutine arguments.
|
---|
113 | int cBaseline, cFlag, cBin, cIFno, cSrcNo;
|
---|
114 | float cUTC, cU, cV, cW, *cVis, *cWgt;
|
---|
115 |
|
---|
116 | char cDateObs[12];
|
---|
117 | int *cBeamSel, *cChanOff, cFirst, *cIFSel, cInterp, cIntTime, cMBopen,
|
---|
118 | cMopra, cNBeamSel, cNBin, cRetry, cSUpos, *cXpolOff;
|
---|
119 |
|
---|
120 | // The data has to be bufferred to allow positions to be interpolated.
|
---|
121 | int cEOF, cEOS, cFlushBin, cFlushIF, cFlushing;
|
---|
122 | double *cPosUTC;
|
---|
123 | MBrecord *cBuffer;
|
---|
124 |
|
---|
125 | // Scan and cycle number bookkeeping.
|
---|
126 | int cCycleNo, cScanNo;
|
---|
127 | double cPrevUTC;
|
---|
128 |
|
---|
129 | // Read the next data record from the RPFITS file.
|
---|
130 | int rpget(int syscalonly, int &EOS);
|
---|
131 | int rpfitsin(int &jstat);
|
---|
132 |
|
---|
133 | // Check and, if necessary, repair a position timestamp.
|
---|
134 | int cCode5, cNRate;
|
---|
135 | double cAvRate[2];
|
---|
136 | int fixw(const char *datobs, int cycleNo, int beamNo, double avRate[2],
|
---|
137 | double thisRA, double thisDec, double thisUTC,
|
---|
138 | double nextRA, double nextDec, float &nextUTC);
|
---|
139 |
|
---|
140 | // Subtract two UTCs (s).
|
---|
141 | double utcDiff(double utc1, double utc2);
|
---|
142 |
|
---|
143 | // Compute and apply the scan rate corrected for grid convergence.
|
---|
144 | double cRA0, cDec0;
|
---|
145 | void scanRate(double ra0, double dec0,
|
---|
146 | double ra1, double dec1,
|
---|
147 | double ra2, double dec2, double dt,
|
---|
148 | double &raRate, double &decRate);
|
---|
149 | void applyRate(double ra0, double dec0,
|
---|
150 | double ra1, double dec1,
|
---|
151 | double raRate, double decRate, double dt,
|
---|
152 | double &ra2, double &dec2);
|
---|
153 | void eulerx(double lng0, double lat0, double phi0, double theta,
|
---|
154 | double phi, double &lng1, double &lat1);
|
---|
155 | };
|
---|
156 |
|
---|
157 | #endif
|
---|