1 | //#---------------------------------------------------------------------------
|
---|
2 | //# SDContainer.h: A container class for single dish integrations
|
---|
3 | //#---------------------------------------------------------------------------
|
---|
4 | //# Copyright (C) 2004
|
---|
5 | //# ATNF
|
---|
6 | //#
|
---|
7 | //# This program is free software; you can redistribute it and/or modify it
|
---|
8 | //# under the terms of the GNU General Public License as published by the Free
|
---|
9 | //# Software Foundation; either version 2 of the License, or (at your option)
|
---|
10 | //# any later version.
|
---|
11 | //#
|
---|
12 | //# This program is distributed in the hope that it will be useful, but
|
---|
13 | //# WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
---|
15 | //# Public License for more details.
|
---|
16 | //#
|
---|
17 | //# You should have received a copy of the GNU General Public License along
|
---|
18 | //# with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
19 | //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
|
---|
20 | //#
|
---|
21 | //# Correspondence concerning this software should be addressed as follows:
|
---|
22 | //# Internet email: Malte.Marquarding@csiro.au
|
---|
23 | //# Postal address: Malte Marquarding,
|
---|
24 | //# Australia Telescope National Facility,
|
---|
25 | //# P.O. Box 76,
|
---|
26 | //# Epping, NSW, 2121,
|
---|
27 | //# AUSTRALIA
|
---|
28 | //#
|
---|
29 | //# $Id:
|
---|
30 | //#---------------------------------------------------------------------------
|
---|
31 | #ifndef SDCONTAINER_H
|
---|
32 | #define SDCONTAINER_H
|
---|
33 |
|
---|
34 | #include <vector>
|
---|
35 |
|
---|
36 | #include <casa/aips.h>
|
---|
37 | #include <casa/BasicSL/String.h>
|
---|
38 | #include <casa/Arrays/Array.h>
|
---|
39 | #include <casa/Arrays/Vector.h>
|
---|
40 | #include <casa/Containers/Block.h>
|
---|
41 | #include <measures/Measures/MDirection.h>
|
---|
42 |
|
---|
43 | template<class T> class casa::Matrix;
|
---|
44 |
|
---|
45 | namespace asap {
|
---|
46 |
|
---|
47 |
|
---|
48 | struct SDHeader {
|
---|
49 | casa::Int nchan;
|
---|
50 | casa::Int npol;
|
---|
51 | casa::Int nif;
|
---|
52 | casa::Int nbeam;
|
---|
53 | casa::String observer;
|
---|
54 | casa::String project;
|
---|
55 | casa::String obstype;
|
---|
56 | casa::String antennaname;
|
---|
57 | casa::Vector<casa::Double> antennaposition;
|
---|
58 | casa::Float equinox;
|
---|
59 | casa::String freqref;
|
---|
60 | casa::Double reffreq;
|
---|
61 | casa::Double bandwidth;
|
---|
62 | casa::Double utc;
|
---|
63 | casa::String fluxunit;
|
---|
64 | casa::String epoch;
|
---|
65 | void print() const ;
|
---|
66 | };
|
---|
67 |
|
---|
68 | class SDFrequencyTable {
|
---|
69 |
|
---|
70 | public:
|
---|
71 |
|
---|
72 | SDFrequencyTable() : nFreq_(0) {;}
|
---|
73 | virtual ~SDFrequencyTable() {;}
|
---|
74 |
|
---|
75 | // Add a new entry or match an existing one. Returns the index into the table
|
---|
76 | casa::uInt addFrequency(casa::Double refPix, casa::Double refVal,
|
---|
77 | casa::Double inc);
|
---|
78 | //
|
---|
79 | casa::Int length() const { return nFreq_;} // # of stored Frequencies
|
---|
80 | void setLength(casa::uInt length) {nFreq_ = length;}
|
---|
81 |
|
---|
82 | // Get attributes
|
---|
83 | casa::Double referencePixel(casa::uInt which) const { return refPix_[which];}
|
---|
84 | casa::Double referenceValue(casa::uInt which) const { return refVal_[which];}
|
---|
85 | casa::Double increment(casa::uInt which) const { return increment_[which];}
|
---|
86 | casa::Float equinox() const { return equinox_; }
|
---|
87 | casa::String refFrame() const { return refFrame_; }
|
---|
88 | //
|
---|
89 | void restFrequencies(casa::Vector<casa::Double>& rfs,
|
---|
90 | casa::String& rfunit ) const ;
|
---|
91 |
|
---|
92 | // Set attributes
|
---|
93 | void setEquinox(casa::Float eq) { equinox_ = eq; }
|
---|
94 | void setRefFrame(const casa::String& reff) { refFrame_ = reff; }
|
---|
95 | //
|
---|
96 | void deleteRestFrequencies () {restFreqs_.resize(0);}
|
---|
97 | casa::uInt addRestFrequency(casa::Double);
|
---|
98 | void setRestFrequencyUnit(const casa::String& theunit) {restFreqUnit_ = theunit;}
|
---|
99 |
|
---|
100 | private:
|
---|
101 | casa::uInt nFreq_;
|
---|
102 | casa::Vector<casa::Double> refPix_;
|
---|
103 | casa::Vector<casa::Double> refVal_; // Hz
|
---|
104 | casa::Vector<casa::Double> increment_; // Hz
|
---|
105 | casa::Float equinox_;
|
---|
106 | casa::String refFrame_;
|
---|
107 | casa::Vector<casa::Double> restFreqs_; // Hz
|
---|
108 | casa::String restFreqUnit_;
|
---|
109 | };
|
---|
110 |
|
---|
111 |
|
---|
112 | class SDContainer {
|
---|
113 |
|
---|
114 | public:
|
---|
115 | SDContainer(casa::uInt nBeam, casa::uInt nIF, casa::uInt nPol,
|
---|
116 | casa::uInt nChan);
|
---|
117 | SDContainer(casa::IPosition shp);
|
---|
118 |
|
---|
119 | virtual ~SDContainer();
|
---|
120 |
|
---|
121 | casa::Bool resize(casa::IPosition shp);
|
---|
122 |
|
---|
123 | casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
|
---|
124 | casa::uInt whichBeam, casa::uInt whichIF);
|
---|
125 | casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
|
---|
126 | const casa::Vector<casa::Complex>& cSpec,
|
---|
127 | casa::uInt whichBeam, casa::uInt whichIF);
|
---|
128 | casa::Bool putSpectrum(const casa::Array<casa::Float>& spec);
|
---|
129 |
|
---|
130 | casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs,
|
---|
131 | casa::uInt whichBeam, casa::uInt whichIF,
|
---|
132 | casa::Bool hasXPol=casa::False);
|
---|
133 | casa::Bool putFlags(const casa::Array<casa::uChar>& spec);
|
---|
134 |
|
---|
135 | casa::Bool setTsys(const casa::Vector<casa::Float>& ts,
|
---|
136 | casa::uInt whichBeam, casa::uInt whichIF,
|
---|
137 | casa::Bool hasXpol);
|
---|
138 | casa::Bool putTsys(const casa::Array<casa::Float>& spec);
|
---|
139 |
|
---|
140 | casa::Bool setDirection(const casa::Vector<casa::Double>& point,
|
---|
141 | casa::uInt whichBeam);
|
---|
142 | casa::Bool putDirection(const casa::Array<casa::Double>& dir);
|
---|
143 |
|
---|
144 | casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
|
---|
145 | casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs);
|
---|
146 |
|
---|
147 | casa::Bool setRestFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
|
---|
148 | casa::Bool putRestFreqMap(const casa::Vector<casa::uInt>& freqs);
|
---|
149 |
|
---|
150 | casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam,
|
---|
151 | casa::uInt whichIF) const;
|
---|
152 | casa::Array<casa::uChar> getFlags(casa::uInt whichBeam,
|
---|
153 | casa::uInt whichIF) const;
|
---|
154 | casa::Array<casa::Float> getTsys(casa::uInt whichBeam,
|
---|
155 | casa::uInt whichIF) const;
|
---|
156 | casa::Array<casa::Double> getDirection(casa::uInt whichBeam) const;
|
---|
157 |
|
---|
158 | const casa::Array<casa::Float>& getSpectrum() const { return spectrum_; }
|
---|
159 | const casa::Array<casa::uChar>& getFlags() const { return flags_; }
|
---|
160 | const casa::Array<casa::Float>& getTsys() const { return tsys_; }
|
---|
161 | const casa::Array<casa::Double>& getDirection() const { return direction_; }
|
---|
162 |
|
---|
163 | const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; }
|
---|
164 | const casa::Vector<casa::uInt>& getRestFreqMap() const { return restfreqidx_; }
|
---|
165 |
|
---|
166 | const casa::Vector<casa::String>& getHistory() const { return history_; }
|
---|
167 | casa::Bool putHistory(const casa::Vector<casa::String>& hist);
|
---|
168 | casa::Bool appendHistory(const casa::String& hist);
|
---|
169 |
|
---|
170 | casa::Double timestamp;
|
---|
171 | //Double bandwidth;
|
---|
172 | casa::String sourcename;
|
---|
173 | casa::String fieldname;
|
---|
174 | casa::Double interval;
|
---|
175 | casa::Int scanid;
|
---|
176 | casa::Vector<casa::Float> tcal;
|
---|
177 | casa::String tcaltime;
|
---|
178 | casa::Float azimuth;
|
---|
179 | casa::Float elevation;
|
---|
180 | casa::Float parangle;
|
---|
181 | casa::Int refbeam;
|
---|
182 |
|
---|
183 | private:
|
---|
184 | casa::uInt nBeam_,nIF_,nPol_,nChan_;
|
---|
185 |
|
---|
186 | // (nBeam,nIF,nPol,nChannel)
|
---|
187 | casa::Array<casa::Float> spectrum_;
|
---|
188 | casa::Array<casa::uChar> flags_;
|
---|
189 | // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of
|
---|
190 | // channel, but this makes it easier to work with at the expense of
|
---|
191 | // a little memory
|
---|
192 | casa::Array<casa::Float> tsys_;
|
---|
193 | casa::Array<casa::Float> tcal_;
|
---|
194 |
|
---|
195 | //(nIF) indx into "global" frequency table
|
---|
196 | casa::Vector<casa::uInt> freqidx_;
|
---|
197 | // (nIF) indx into "global" rest frequency table
|
---|
198 | casa::Vector<casa::uInt> restfreqidx_;
|
---|
199 | //(nBeam,2) maybe use Measures here...
|
---|
200 | casa::Array<casa::Double> direction_;
|
---|
201 | casa::Vector<casa::String> history_;
|
---|
202 | void setSlice (casa::IPosition& start, casa::IPosition& end,
|
---|
203 | const casa::IPosition& shpIn, const casa::IPosition& shpOut,
|
---|
204 | casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol,
|
---|
205 | casa::Bool xPol) const;
|
---|
206 | };
|
---|
207 |
|
---|
208 |
|
---|
209 |
|
---|
210 | class SDDataDesc {
|
---|
211 |
|
---|
212 | public:
|
---|
213 |
|
---|
214 | // COnstructor
|
---|
215 | SDDataDesc() : n_(0) {;}
|
---|
216 | ~SDDataDesc() {;}
|
---|
217 |
|
---|
218 | // Add an entry if source name and Integer ID (can be anything you like, such
|
---|
219 | // as FreqID) are unique. You can add secondary entries direction
|
---|
220 | // and another integer index which are just stored along with the
|
---|
221 | // the primary entries
|
---|
222 | casa::uInt addEntry (const casa::String& source, casa::uInt ID,
|
---|
223 | const casa::MDirection& secDir, casa::uInt secID);
|
---|
224 |
|
---|
225 | // Number of entries
|
---|
226 | casa::Int length() const { return n_;}
|
---|
227 |
|
---|
228 | // Get attributes
|
---|
229 | casa::String source (casa::uInt which) const {return source_[which];}
|
---|
230 | casa::uInt ID(casa::uInt which) const {return ID_[which];}
|
---|
231 | casa::uInt secID(casa::uInt which) const {return secID_[which];}
|
---|
232 | casa::MDirection secDir (casa::uInt which) const {return secDir_[which];}
|
---|
233 |
|
---|
234 | // Summary
|
---|
235 | void summary() const;
|
---|
236 |
|
---|
237 | private:
|
---|
238 | casa::uInt n_;
|
---|
239 | casa::Vector<casa::String> source_;
|
---|
240 | casa::Vector<casa::uInt> ID_, secID_;
|
---|
241 | casa::Block<casa::MDirection> secDir_;
|
---|
242 | //
|
---|
243 | SDDataDesc(const SDDataDesc& other);
|
---|
244 |
|
---|
245 | };
|
---|
246 |
|
---|
247 | } // namespace
|
---|
248 | #endif
|
---|