[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 |
|
---|
| 75 | // Add a new entry or match an existing one. Returns the index into the table
|
---|
| 76 | casa::Int 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::Int length) {nFreq_ = length;}
|
---|
| 81 |
|
---|
| 82 | // Get attributes
|
---|
[125] | 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_; }
|
---|
[204] | 88 | void restFrequencies(casa::Vector<casa::Double>& rfs,
|
---|
| 89 | casa::String& rfunit ) const ;
|
---|
[34] | 90 |
|
---|
[320] | 91 | // Set attributes
|
---|
[125] | 92 | void setEquinox(casa::Float eq) { equinox_ = eq; }
|
---|
| 93 | void setRefFrame(const casa::String& reff) { refFrame_ = reff; }
|
---|
[204] | 94 | void addRestFrequency(casa::Double);
|
---|
[320] | 95 | void setRestFrequencyUnit(const casa::String& theunit) {restFreqUnit_ = theunit;}
|
---|
[204] | 96 |
|
---|
[2] | 97 | private:
|
---|
[125] | 98 | casa::Int nFreq_;
|
---|
| 99 | casa::Vector<casa::Double> refPix_;
|
---|
[307] | 100 | casa::Vector<casa::Double> refVal_; // Hz
|
---|
[314] | 101 | casa::Vector<casa::Double> increment_; // Hz
|
---|
[125] | 102 | casa::Float equinox_;
|
---|
| 103 | casa::String refFrame_;
|
---|
[307] | 104 | casa::Vector<casa::Double> restFreqs_; // Hz
|
---|
[204] | 105 | casa::String restFreqUnit_;
|
---|
[2] | 106 | };
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | class SDContainer {
|
---|
| 110 |
|
---|
| 111 | public:
|
---|
[125] | 112 | SDContainer(casa::uInt nBeam, casa::uInt nIF, casa::uInt nPol,
|
---|
| 113 | casa::uInt nChan);
|
---|
| 114 | SDContainer(casa::IPosition shp);
|
---|
[2] | 115 |
|
---|
| 116 | virtual ~SDContainer();
|
---|
| 117 |
|
---|
[125] | 118 | casa::Bool resize(casa::IPosition shp);
|
---|
[47] | 119 |
|
---|
[125] | 120 | casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
|
---|
| 121 | casa::uInt whichBeam, casa::uInt whichIF);
|
---|
| 122 | casa::Bool putSpectrum(const casa::Array<casa::Float>& spec);
|
---|
[2] | 123 |
|
---|
[125] | 124 | casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs,
|
---|
| 125 | casa::uInt whichBeam, casa::uInt whichIF);
|
---|
| 126 | casa::Bool putFlags(const casa::Array<casa::uChar>& spec);
|
---|
[2] | 127 |
|
---|
[125] | 128 | casa::Bool setTsys(const casa::Vector<casa::Float>& ts,
|
---|
| 129 | casa::uInt whichBeam, casa::uInt whichIF);
|
---|
| 130 | casa::Bool putTsys(const casa::Array<casa::Float>& spec);
|
---|
[2] | 131 |
|
---|
[125] | 132 | casa::Bool setDirection(const casa::Vector<casa::Double>& point,
|
---|
| 133 | casa::uInt whichBeam);
|
---|
| 134 | casa::Bool putDirection(const casa::Array<casa::Double>& dir);
|
---|
[2] | 135 |
|
---|
[125] | 136 | casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
|
---|
| 137 | casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs);
|
---|
[2] | 138 |
|
---|
[125] | 139 | casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam,
|
---|
| 140 | casa::uInt whichIF) const;
|
---|
| 141 | casa::Array<casa::uChar> getFlags(casa::uInt whichBeam,
|
---|
| 142 | casa::uInt whichIF) const;
|
---|
| 143 | casa::Array<casa::Float> getTsys(casa::uInt whichBeam,
|
---|
| 144 | casa::uInt whichIF) const;
|
---|
| 145 | casa::Array<casa::Double> getDirection(casa::uInt whichBeam) const;
|
---|
[34] | 146 |
|
---|
[125] | 147 | const casa::Array<casa::Float>& getSpectrum() const { return spectrum_; }
|
---|
| 148 | const casa::Array<casa::uChar>& getFlags() const { return flags_; }
|
---|
| 149 | const casa::Array<casa::Float>& getTsys() const { return tsys_; }
|
---|
| 150 | const casa::Array<casa::Double>& getDirection() const { return direction_; }
|
---|
[2] | 151 |
|
---|
[125] | 152 | const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; }
|
---|
[79] | 153 |
|
---|
[204] | 154 | const casa::Vector<casa::String>& getHistory() const { return history_; }
|
---|
| 155 | casa::Bool putHistory(const casa::Vector<casa::String>& hist);
|
---|
| 156 | casa::Bool appendHistory(const casa::String& hist);
|
---|
| 157 |
|
---|
[125] | 158 | casa::Double timestamp;
|
---|
[104] | 159 | //Double bandwidth;
|
---|
[125] | 160 | casa::String sourcename;
|
---|
| 161 | casa::String fieldname;
|
---|
| 162 | casa::Double interval;
|
---|
| 163 | casa::Int scanid;
|
---|
| 164 | casa::Vector<casa::Float> tcal;
|
---|
| 165 | casa::String tcaltime;
|
---|
| 166 | casa::Float azimuth;
|
---|
| 167 | casa::Float elevation;
|
---|
| 168 | casa::Float parangle;
|
---|
| 169 | casa::Int refbeam;
|
---|
[104] | 170 |
|
---|
[2] | 171 | private:
|
---|
[125] | 172 | casa::uInt nBeam_,nIF_,nPol_,nChan_;
|
---|
[2] | 173 |
|
---|
[16] | 174 | // (nBeam,nIF,nPol,nChannel)
|
---|
[125] | 175 | casa::Array<casa::Float> spectrum_;
|
---|
| 176 | casa::Array<casa::uChar> flags_;
|
---|
[16] | 177 | // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of
|
---|
[7] | 178 | // channel, but this makes it easier to work with at the expense of
|
---|
| 179 | // a little memory
|
---|
[125] | 180 | casa::Array<casa::Float> tsys_;
|
---|
| 181 | casa::Array<casa::Float> tcal_;
|
---|
[2] | 182 |
|
---|
| 183 | //(nIF) indx into "global" frequency table
|
---|
[125] | 184 | casa::Vector<casa::uInt> freqidx_;
|
---|
[79] | 185 | //(nBeam,2) maybe use Measures here...
|
---|
[125] | 186 | casa::Array<casa::Double> direction_;
|
---|
[204] | 187 | casa::Vector<casa::String> history_;
|
---|
[349] | 188 | void setSlice (casa::IPosition& start, casa::IPosition& end,
|
---|
| 189 | const casa::IPosition& shpIn, const casa::IPosition& shpOut,
|
---|
| 190 | casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol) const;
|
---|
[2] | 191 | };
|
---|
| 192 |
|
---|
[326] | 193 |
|
---|
| 194 |
|
---|
| 195 | class SDDataDesc {
|
---|
| 196 |
|
---|
| 197 | public:
|
---|
| 198 |
|
---|
| 199 | // COnstructor
|
---|
| 200 | SDDataDesc() : n_(0) {;}
|
---|
| 201 | ~SDDataDesc() {;}
|
---|
| 202 |
|
---|
| 203 | // Add an entry if source name (not direction at this point) and freqID are unique
|
---|
| 204 | casa::uInt addEntry (const casa::String& source, casa::uInt freqID,
|
---|
| 205 | const casa::MDirection& dir);
|
---|
| 206 |
|
---|
| 207 | // Number of entries
|
---|
| 208 | casa::Int length() const { return n_;}
|
---|
| 209 |
|
---|
| 210 | // Get attributes
|
---|
| 211 | casa::String source (casa::uInt which) const {return source_[which];}
|
---|
| 212 | casa::uInt freqID(casa::uInt which) const {return freqID_[which];}
|
---|
| 213 | casa::MDirection direction (casa::uInt which) const {return dir_[which];}
|
---|
| 214 |
|
---|
| 215 | // Summary
|
---|
| 216 | void summary() const;
|
---|
| 217 |
|
---|
| 218 | private:
|
---|
| 219 | casa::uInt n_;
|
---|
| 220 | casa::Vector<casa::String> source_;
|
---|
| 221 | casa::Vector<casa::uInt> freqID_;
|
---|
| 222 | casa::Block<casa::MDirection> dir_;
|
---|
| 223 | //
|
---|
| 224 | SDDataDesc(const SDDataDesc& other);
|
---|
[349] | 225 |
|
---|
[326] | 226 | };
|
---|
| 227 |
|
---|
[2] | 228 | } // namespace
|
---|
| 229 | #endif
|
---|