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