[2] | 1 | //#--------------------------------------------------------------------------- |
---|
| 2 | //# SDContainer.h: A container class for single dish integrations |
---|
| 3 | //#--------------------------------------------------------------------------- |
---|
| 4 | //# Copyright (C) 2004 |
---|
[125] | 5 | //# ATNF |
---|
[2] | 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 | //#--------------------------------------------------------------------------- |
---|
[125] | 31 | #ifndef SDCONTAINER_H |
---|
| 32 | #define SDCONTAINER_H |
---|
[2] | 33 | |
---|
[18] | 34 | #include <vector> |
---|
| 35 | |
---|
[81] | 36 | #include <casa/aips.h> |
---|
| 37 | #include <casa/BasicSL/String.h> |
---|
| 38 | #include <casa/Arrays/Array.h> |
---|
| 39 | #include <casa/Arrays/Vector.h> |
---|
[326] | 40 | #include <casa/Containers/Block.h> |
---|
| 41 | #include <measures/Measures/MDirection.h> |
---|
[2] | 42 | |
---|
[125] | 43 | template<class T> class casa::Matrix; |
---|
[2] | 44 | |
---|
[83] | 45 | namespace asap { |
---|
[2] | 46 | |
---|
[18] | 47 | |
---|
| 48 | struct SDHeader { |
---|
[125] | 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; |
---|
[204] | 63 | casa::String fluxunit; |
---|
| 64 | casa::String epoch; |
---|
[18] | 65 | void print() const ; |
---|
| 66 | }; |
---|
| 67 | |
---|
[2] | 68 | class SDFrequencyTable { |
---|
| 69 | |
---|
| 70 | public: |
---|
| 71 | |
---|
[34] | 72 | SDFrequencyTable() : nFreq_(0) {;} |
---|
| 73 | virtual ~SDFrequencyTable() {;} |
---|
[320] | 74 | |
---|
[453] | 75 | // Add a new entry or match an existing one. Returns the index into |
---|
| 76 | // the table |
---|
[388] | 77 | casa::uInt addFrequency(casa::Double refPix, casa::Double refVal, |
---|
[453] | 78 | casa::Double inc); |
---|
| 79 | |
---|
| 80 | casa::Int length() const { return nFreq_;} // # of stored Frequencies |
---|
[392] | 81 | void setLength(casa::uInt length) {nFreq_ = length;} |
---|
[320] | 82 | |
---|
[453] | 83 | // Get attributes |
---|
[125] | 84 | casa::Double referencePixel(casa::uInt which) const { return refPix_[which];} |
---|
| 85 | casa::Double referenceValue(casa::uInt which) const { return refVal_[which];} |
---|
| 86 | casa::Double increment(casa::uInt which) const { return increment_[which];} |
---|
| 87 | casa::Float equinox() const { return equinox_; } |
---|
| 88 | casa::String refFrame() const { return refFrame_; } |
---|
[453] | 89 | |
---|
[204] | 90 | void restFrequencies(casa::Vector<casa::Double>& rfs, |
---|
| 91 | casa::String& rfunit ) const ; |
---|
[34] | 92 | |
---|
[453] | 93 | // Set attributes |
---|
[125] | 94 | void setEquinox(casa::Float eq) { equinox_ = eq; } |
---|
| 95 | void setRefFrame(const casa::String& reff) { refFrame_ = reff; } |
---|
[453] | 96 | |
---|
| 97 | void deleteRestFrequencies() {restFreqs_.resize(0);} |
---|
[388] | 98 | casa::uInt addRestFrequency(casa::Double); |
---|
[453] | 99 | void setRestFrequencyUnit(const casa::String& theunit) |
---|
| 100 | { restFreqUnit_ = theunit;} |
---|
[204] | 101 | |
---|
[2] | 102 | private: |
---|
[388] | 103 | casa::uInt nFreq_; |
---|
[125] | 104 | casa::Vector<casa::Double> refPix_; |
---|
[307] | 105 | casa::Vector<casa::Double> refVal_; // Hz |
---|
[314] | 106 | casa::Vector<casa::Double> increment_; // Hz |
---|
[125] | 107 | casa::Float equinox_; |
---|
| 108 | casa::String refFrame_; |
---|
[307] | 109 | casa::Vector<casa::Double> restFreqs_; // Hz |
---|
[204] | 110 | casa::String restFreqUnit_; |
---|
[2] | 111 | }; |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | class SDContainer { |
---|
| 115 | |
---|
| 116 | public: |
---|
[125] | 117 | SDContainer(casa::uInt nBeam, casa::uInt nIF, casa::uInt nPol, |
---|
| 118 | casa::uInt nChan); |
---|
| 119 | SDContainer(casa::IPosition shp); |
---|
[2] | 120 | |
---|
| 121 | virtual ~SDContainer(); |
---|
| 122 | |
---|
[125] | 123 | casa::Bool resize(casa::IPosition shp); |
---|
[47] | 124 | |
---|
[125] | 125 | casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec, |
---|
| 126 | casa::uInt whichBeam, casa::uInt whichIF); |
---|
[417] | 127 | casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec, |
---|
| 128 | const casa::Vector<casa::Complex>& cSpec, |
---|
| 129 | casa::uInt whichBeam, casa::uInt whichIF); |
---|
[125] | 130 | casa::Bool putSpectrum(const casa::Array<casa::Float>& spec); |
---|
[2] | 131 | |
---|
[125] | 132 | casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs, |
---|
[417] | 133 | casa::uInt whichBeam, casa::uInt whichIF, |
---|
| 134 | casa::Bool hasXPol=casa::False); |
---|
[125] | 135 | casa::Bool putFlags(const casa::Array<casa::uChar>& spec); |
---|
[2] | 136 | |
---|
[125] | 137 | casa::Bool setTsys(const casa::Vector<casa::Float>& ts, |
---|
[417] | 138 | casa::uInt whichBeam, casa::uInt whichIF, |
---|
| 139 | casa::Bool hasXpol); |
---|
[125] | 140 | casa::Bool putTsys(const casa::Array<casa::Float>& spec); |
---|
[2] | 141 | |
---|
[125] | 142 | casa::Bool setDirection(const casa::Vector<casa::Double>& point, |
---|
| 143 | casa::uInt whichBeam); |
---|
| 144 | casa::Bool putDirection(const casa::Array<casa::Double>& dir); |
---|
[2] | 145 | |
---|
[125] | 146 | casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF); |
---|
| 147 | casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs); |
---|
[388] | 148 | |
---|
| 149 | casa::Bool setRestFrequencyMap(casa::uInt freqslot, casa::uInt whichIF); |
---|
| 150 | casa::Bool putRestFreqMap(const casa::Vector<casa::uInt>& freqs); |
---|
[2] | 151 | |
---|
[125] | 152 | casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam, |
---|
[449] | 153 | casa::uInt whichIF); |
---|
[125] | 154 | casa::Array<casa::uChar> getFlags(casa::uInt whichBeam, |
---|
[449] | 155 | casa::uInt whichIF); |
---|
[125] | 156 | casa::Array<casa::Float> getTsys(casa::uInt whichBeam, |
---|
[449] | 157 | casa::uInt whichIF); |
---|
[125] | 158 | casa::Array<casa::Double> getDirection(casa::uInt whichBeam) const; |
---|
[34] | 159 | |
---|
[125] | 160 | const casa::Array<casa::Float>& getSpectrum() const { return spectrum_; } |
---|
| 161 | const casa::Array<casa::uChar>& getFlags() const { return flags_; } |
---|
| 162 | const casa::Array<casa::Float>& getTsys() const { return tsys_; } |
---|
| 163 | const casa::Array<casa::Double>& getDirection() const { return direction_; } |
---|
[2] | 164 | |
---|
[125] | 165 | const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; } |
---|
[453] | 166 | const casa::Vector<casa::uInt>& getRestFreqMap() const |
---|
| 167 | { return restfreqidx_; } |
---|
[79] | 168 | |
---|
[453] | 169 | casa::Bool putFitMap(const casa::Array<casa::Int>& arr); |
---|
| 170 | |
---|
| 171 | const casa::Array<casa::Int>& getFitMap() const { return fitIDMap_; } |
---|
| 172 | |
---|
| 173 | |
---|
[125] | 174 | casa::Double timestamp; |
---|
[104] | 175 | //Double bandwidth; |
---|
[125] | 176 | casa::String sourcename; |
---|
| 177 | casa::String fieldname; |
---|
| 178 | casa::Double interval; |
---|
| 179 | casa::Int scanid; |
---|
| 180 | casa::Vector<casa::Float> tcal; |
---|
| 181 | casa::String tcaltime; |
---|
| 182 | casa::Float azimuth; |
---|
| 183 | casa::Float elevation; |
---|
| 184 | casa::Float parangle; |
---|
| 185 | casa::Int refbeam; |
---|
[104] | 186 | |
---|
[2] | 187 | private: |
---|
[125] | 188 | casa::uInt nBeam_,nIF_,nPol_,nChan_; |
---|
[2] | 189 | |
---|
[16] | 190 | // (nBeam,nIF,nPol,nChannel) |
---|
[125] | 191 | casa::Array<casa::Float> spectrum_; |
---|
| 192 | casa::Array<casa::uChar> flags_; |
---|
[453] | 193 | |
---|
[16] | 194 | // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of |
---|
[7] | 195 | // channel, but this makes it easier to work with at the expense of |
---|
| 196 | // a little memory |
---|
[125] | 197 | casa::Array<casa::Float> tsys_; |
---|
| 198 | casa::Array<casa::Float> tcal_; |
---|
[2] | 199 | |
---|
| 200 | //(nIF) indx into "global" frequency table |
---|
[125] | 201 | casa::Vector<casa::uInt> freqidx_; |
---|
[453] | 202 | |
---|
[388] | 203 | // (nIF) indx into "global" rest frequency table |
---|
| 204 | casa::Vector<casa::uInt> restfreqidx_; |
---|
[453] | 205 | |
---|
[79] | 206 | //(nBeam,2) maybe use Measures here... |
---|
[125] | 207 | casa::Array<casa::Double> direction_; |
---|
[453] | 208 | casa::Array<casa::Int> fitIDMap_; |
---|
| 209 | |
---|
| 210 | void setSlice(casa::IPosition& start, casa::IPosition& end, |
---|
| 211 | const casa::IPosition& shpIn, const casa::IPosition& shpOut, |
---|
| 212 | casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol, |
---|
| 213 | casa::Bool xPol) const; |
---|
| 214 | void setSlice(casa::IPosition& start, casa::IPosition& end, |
---|
| 215 | const casa::IPosition& shape, |
---|
| 216 | casa::uInt whichBeam, casa::uInt whichIF) const; |
---|
[2] | 217 | }; |
---|
| 218 | |
---|
[326] | 219 | |
---|
| 220 | |
---|
| 221 | class SDDataDesc { |
---|
| 222 | |
---|
| 223 | public: |
---|
| 224 | |
---|
[453] | 225 | // Constructor |
---|
[326] | 226 | SDDataDesc() : n_(0) {;} |
---|
| 227 | ~SDDataDesc() {;} |
---|
| 228 | |
---|
[453] | 229 | // Add an entry if source name and Integer ID (can be anything you |
---|
| 230 | // like, such as FreqID) are unique. You can add secondary entries |
---|
| 231 | // direction and another integer index which are just stored along |
---|
| 232 | // with the the primary entries |
---|
| 233 | casa::uInt addEntry(const casa::String& source, casa::uInt ID, |
---|
| 234 | const casa::MDirection& secDir, casa::uInt secID); |
---|
[326] | 235 | |
---|
[453] | 236 | // Number of entries |
---|
[326] | 237 | casa::Int length() const { return n_;} |
---|
[453] | 238 | |
---|
| 239 | // Get attributes |
---|
| 240 | casa::String source(casa::uInt which) const {return source_[which];} |
---|
[396] | 241 | casa::uInt ID(casa::uInt which) const {return ID_[which];} |
---|
| 242 | casa::uInt secID(casa::uInt which) const {return secID_[which];} |
---|
[453] | 243 | casa::MDirection secDir(casa::uInt which) const {return secDir_[which];} |
---|
| 244 | |
---|
| 245 | // Summary |
---|
[326] | 246 | void summary() const; |
---|
| 247 | |
---|
| 248 | private: |
---|
| 249 | casa::uInt n_; |
---|
| 250 | casa::Vector<casa::String> source_; |
---|
[396] | 251 | casa::Vector<casa::uInt> ID_, secID_; |
---|
| 252 | casa::Block<casa::MDirection> secDir_; |
---|
[453] | 253 | |
---|
[326] | 254 | SDDataDesc(const SDDataDesc& other); |
---|
[349] | 255 | |
---|
[326] | 256 | }; |
---|
| 257 | |
---|
[453] | 258 | |
---|
[2] | 259 | } // namespace |
---|
| 260 | #endif |
---|