[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> |
---|
[2] | 40 | |
---|
[125] | 41 | template<class T> class casa::Matrix; |
---|
[2] | 42 | |
---|
[83] | 43 | namespace asap { |
---|
[2] | 44 | |
---|
[18] | 45 | |
---|
| 46 | struct SDHeader { |
---|
[125] | 47 | casa::Int nchan; |
---|
| 48 | casa::Int npol; |
---|
| 49 | casa::Int nif; |
---|
| 50 | casa::Int nbeam; |
---|
| 51 | casa::String observer; |
---|
| 52 | casa::String project; |
---|
| 53 | casa::String obstype; |
---|
| 54 | casa::String antennaname; |
---|
| 55 | casa::Vector<casa::Double> antennaposition; |
---|
| 56 | casa::Float equinox; |
---|
| 57 | casa::String freqref; |
---|
| 58 | casa::Double reffreq; |
---|
| 59 | casa::Double bandwidth; |
---|
| 60 | casa::Double utc; |
---|
[204] | 61 | casa::String fluxunit; |
---|
| 62 | casa::String epoch; |
---|
[18] | 63 | void print() const ; |
---|
| 64 | }; |
---|
| 65 | |
---|
[2] | 66 | class SDFrequencyTable { |
---|
| 67 | |
---|
| 68 | public: |
---|
| 69 | |
---|
[34] | 70 | SDFrequencyTable() : nFreq_(0) {;} |
---|
| 71 | virtual ~SDFrequencyTable() {;} |
---|
[320] | 72 | |
---|
| 73 | // Add a new entry or match an existing one. Returns the index into the table |
---|
| 74 | casa::Int addFrequency(casa::Double refPix, casa::Double refVal, |
---|
| 75 | casa::Double inc); |
---|
| 76 | // |
---|
| 77 | casa::Int length() const { return nFreq_;} // # of stored Frequencies |
---|
| 78 | void setLength(casa::Int length) {nFreq_ = length;} |
---|
| 79 | |
---|
| 80 | // Get attributes |
---|
[125] | 81 | casa::Double referencePixel(casa::uInt which) const { return refPix_[which];} |
---|
| 82 | casa::Double referenceValue(casa::uInt which) const { return refVal_[which];} |
---|
| 83 | casa::Double increment(casa::uInt which) const { return increment_[which];} |
---|
| 84 | casa::Float equinox() const { return equinox_; } |
---|
| 85 | casa::String refFrame() const { return refFrame_; } |
---|
[204] | 86 | void restFrequencies(casa::Vector<casa::Double>& rfs, |
---|
| 87 | casa::String& rfunit ) const ; |
---|
[34] | 88 | |
---|
[320] | 89 | // Set attributes |
---|
[125] | 90 | void setEquinox(casa::Float eq) { equinox_ = eq; } |
---|
| 91 | void setRefFrame(const casa::String& reff) { refFrame_ = reff; } |
---|
[204] | 92 | void addRestFrequency(casa::Double); |
---|
[320] | 93 | void setRestFrequencyUnit(const casa::String& theunit) {restFreqUnit_ = theunit;} |
---|
[204] | 94 | |
---|
[2] | 95 | private: |
---|
[125] | 96 | casa::Int nFreq_; |
---|
| 97 | casa::Vector<casa::Double> refPix_; |
---|
[307] | 98 | casa::Vector<casa::Double> refVal_; // Hz |
---|
[314] | 99 | casa::Vector<casa::Double> increment_; // Hz |
---|
[125] | 100 | casa::Float equinox_; |
---|
| 101 | casa::String refFrame_; |
---|
[307] | 102 | casa::Vector<casa::Double> restFreqs_; // Hz |
---|
[204] | 103 | casa::String restFreqUnit_; |
---|
[2] | 104 | }; |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | class SDContainer { |
---|
| 108 | |
---|
| 109 | public: |
---|
[125] | 110 | SDContainer(casa::uInt nBeam, casa::uInt nIF, casa::uInt nPol, |
---|
| 111 | casa::uInt nChan); |
---|
| 112 | SDContainer(casa::IPosition shp); |
---|
[2] | 113 | |
---|
| 114 | virtual ~SDContainer(); |
---|
| 115 | |
---|
[125] | 116 | casa::Bool resize(casa::IPosition shp); |
---|
[47] | 117 | |
---|
[125] | 118 | casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec, |
---|
| 119 | casa::uInt whichBeam, casa::uInt whichIF); |
---|
| 120 | casa::Bool putSpectrum(const casa::Array<casa::Float>& spec); |
---|
[2] | 121 | |
---|
[125] | 122 | casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs, |
---|
| 123 | casa::uInt whichBeam, casa::uInt whichIF); |
---|
| 124 | casa::Bool putFlags(const casa::Array<casa::uChar>& spec); |
---|
[2] | 125 | |
---|
[125] | 126 | casa::Bool setTsys(const casa::Vector<casa::Float>& ts, |
---|
| 127 | casa::uInt whichBeam, casa::uInt whichIF); |
---|
| 128 | casa::Bool putTsys(const casa::Array<casa::Float>& spec); |
---|
[2] | 129 | |
---|
[125] | 130 | casa::Bool setDirection(const casa::Vector<casa::Double>& point, |
---|
| 131 | casa::uInt whichBeam); |
---|
| 132 | casa::Bool putDirection(const casa::Array<casa::Double>& dir); |
---|
[2] | 133 | |
---|
[125] | 134 | casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF); |
---|
| 135 | casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs); |
---|
[2] | 136 | |
---|
[125] | 137 | casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam, |
---|
| 138 | casa::uInt whichIF) const; |
---|
| 139 | casa::Array<casa::uChar> getFlags(casa::uInt whichBeam, |
---|
| 140 | casa::uInt whichIF) const; |
---|
| 141 | casa::Array<casa::Float> getTsys(casa::uInt whichBeam, |
---|
| 142 | casa::uInt whichIF) const; |
---|
| 143 | casa::Array<casa::Double> getDirection(casa::uInt whichBeam) const; |
---|
[34] | 144 | |
---|
[125] | 145 | const casa::Array<casa::Float>& getSpectrum() const { return spectrum_; } |
---|
| 146 | const casa::Array<casa::uChar>& getFlags() const { return flags_; } |
---|
| 147 | const casa::Array<casa::Float>& getTsys() const { return tsys_; } |
---|
| 148 | const casa::Array<casa::Double>& getDirection() const { return direction_; } |
---|
[2] | 149 | |
---|
[125] | 150 | const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; } |
---|
[79] | 151 | |
---|
[204] | 152 | const casa::Vector<casa::String>& getHistory() const { return history_; } |
---|
| 153 | casa::Bool putHistory(const casa::Vector<casa::String>& hist); |
---|
| 154 | casa::Bool appendHistory(const casa::String& hist); |
---|
| 155 | |
---|
[125] | 156 | casa::Double timestamp; |
---|
[104] | 157 | //Double bandwidth; |
---|
[125] | 158 | casa::String sourcename; |
---|
| 159 | casa::String fieldname; |
---|
| 160 | casa::Double interval; |
---|
| 161 | casa::Int scanid; |
---|
| 162 | casa::Vector<casa::Float> tcal; |
---|
| 163 | casa::String tcaltime; |
---|
| 164 | casa::Float azimuth; |
---|
| 165 | casa::Float elevation; |
---|
| 166 | casa::Float parangle; |
---|
| 167 | casa::Int refbeam; |
---|
[104] | 168 | |
---|
[2] | 169 | private: |
---|
[125] | 170 | casa::uInt nBeam_,nIF_,nPol_,nChan_; |
---|
[2] | 171 | |
---|
[16] | 172 | // (nBeam,nIF,nPol,nChannel) |
---|
[125] | 173 | casa::Array<casa::Float> spectrum_; |
---|
| 174 | casa::Array<casa::uChar> flags_; |
---|
[16] | 175 | // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of |
---|
[7] | 176 | // channel, but this makes it easier to work with at the expense of |
---|
| 177 | // a little memory |
---|
[125] | 178 | casa::Array<casa::Float> tsys_; |
---|
| 179 | casa::Array<casa::Float> tcal_; |
---|
[2] | 180 | |
---|
| 181 | //(nIF) indx into "global" frequency table |
---|
[125] | 182 | casa::Vector<casa::uInt> freqidx_; |
---|
[79] | 183 | //(nBeam,2) maybe use Measures here... |
---|
[125] | 184 | casa::Array<casa::Double> direction_; |
---|
[204] | 185 | casa::Vector<casa::String> history_; |
---|
[2] | 186 | |
---|
| 187 | }; |
---|
| 188 | |
---|
| 189 | } // namespace |
---|
| 190 | #endif |
---|