source: trunk/src/SDContainer.h@ 797

Last change on this file since 797 was 754, checked in by mar637, 19 years ago

Bug fix: SDFreqTable did not copy user settings for unit and frame

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
RevLine 
[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]43template<class T> class casa::Matrix;
[2]44
[83]45namespace asap {
[2]46
[18]47
48struct 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]68class SDFrequencyTable {
69
70public:
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
[754]77 casa::uInt addFrequency(casa::Double refPix, casa::Double refVal,
78 casa::Double inc);
[453]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_; }
[754]89 casa::String baseRefFrame() const { return baseRefFrame_; }
90 casa::String unit() const { return unit_; }
[34]91
[754]92 void restFrequencies(casa::Vector<casa::Double>& rfs,
93 casa::String& rfunit ) const ;
94
[453]95 // Set attributes
[125]96 void setEquinox(casa::Float eq) { equinox_ = eq; }
97 void setRefFrame(const casa::String& reff) { refFrame_ = reff; }
[754]98 void setBaseRefFrame(const casa::String& reff) { baseRefFrame_ = reff; }
99 void setUnit(const casa::String& un) { unit_= un; }
[453]100
101 void deleteRestFrequencies() {restFreqs_.resize(0);}
[388]102 casa::uInt addRestFrequency(casa::Double);
[754]103 void setRestFrequencyUnit(const casa::String& theunit)
[453]104 { restFreqUnit_ = theunit;}
[204]105
[2]106private:
[388]107 casa::uInt nFreq_;
[125]108 casa::Vector<casa::Double> refPix_;
[307]109 casa::Vector<casa::Double> refVal_; // Hz
[314]110 casa::Vector<casa::Double> increment_; // Hz
[125]111 casa::Float equinox_;
[754]112 casa::String unit_;
[125]113 casa::String refFrame_;
[754]114 casa::String baseRefFrame_;
[307]115 casa::Vector<casa::Double> restFreqs_; // Hz
[204]116 casa::String restFreqUnit_;
[2]117};
118
119
120class SDContainer {
121
122public:
[754]123 SDContainer(casa::uInt nBeam, casa::uInt nIF, casa::uInt nPol,
124 casa::uInt nChan);
[125]125 SDContainer(casa::IPosition shp);
[2]126
127 virtual ~SDContainer();
128
[125]129 casa::Bool resize(casa::IPosition shp);
[47]130
[125]131 casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
[754]132 casa::uInt whichBeam, casa::uInt whichIF);
[417]133 casa::Bool setSpectrum(const casa::Matrix<casa::Float>& spec,
[754]134 const casa::Vector<casa::Complex>& cSpec,
[417]135 casa::uInt whichBeam, casa::uInt whichIF);
[125]136 casa::Bool putSpectrum(const casa::Array<casa::Float>& spec);
[2]137
[125]138 casa::Bool setFlags(const casa::Matrix<casa::uChar>& flgs,
[754]139 casa::uInt whichBeam, casa::uInt whichIF,
[417]140 casa::Bool hasXPol=casa::False);
[125]141 casa::Bool putFlags(const casa::Array<casa::uChar>& spec);
[2]142
[754]143 casa::Bool setTsys(const casa::Vector<casa::Float>& ts,
144 casa::uInt whichBeam, casa::uInt whichIF,
[417]145 casa::Bool hasXpol);
[125]146 casa::Bool putTsys(const casa::Array<casa::Float>& spec);
[2]147
[754]148 casa::Bool setDirection(const casa::Vector<casa::Double>& point,
149 casa::uInt whichBeam);
[125]150 casa::Bool putDirection(const casa::Array<casa::Double>& dir);
[2]151
[125]152 casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
153 casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs);
[388]154
155 casa::Bool setRestFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
156 casa::Bool putRestFreqMap(const casa::Vector<casa::uInt>& freqs);
[754]157
158 casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam,
159 casa::uInt whichIF);
160 casa::Array<casa::uChar> getFlags(casa::uInt whichBeam,
161 casa::uInt whichIF);
162 casa::Array<casa::Float> getTsys(casa::uInt whichBeam,
163 casa::uInt whichIF);
[125]164 casa::Array<casa::Double> getDirection(casa::uInt whichBeam) const;
[34]165
[125]166 const casa::Array<casa::Float>& getSpectrum() const { return spectrum_; }
167 const casa::Array<casa::uChar>& getFlags() const { return flags_; }
168 const casa::Array<casa::Float>& getTsys() const { return tsys_; }
169 const casa::Array<casa::Double>& getDirection() const { return direction_; }
[2]170
[125]171 const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; }
[754]172 const casa::Vector<casa::uInt>& getRestFreqMap() const
[453]173 { return restfreqidx_; }
[754]174
[453]175 casa::Bool putFitMap(const casa::Array<casa::Int>& arr);
176
177 const casa::Array<casa::Int>& getFitMap() const { return fitIDMap_; }
178
179
[125]180 casa::Double timestamp;
[104]181 //Double bandwidth;
[125]182 casa::String sourcename;
183 casa::String fieldname;
184 casa::Double interval;
185 casa::Int scanid;
186 casa::Vector<casa::Float> tcal;
187 casa::String tcaltime;
188 casa::Float azimuth;
189 casa::Float elevation;
190 casa::Float parangle;
191 casa::Int refbeam;
[104]192
[2]193private:
[125]194 casa::uInt nBeam_,nIF_,nPol_,nChan_;
[2]195
[16]196 // (nBeam,nIF,nPol,nChannel)
[754]197 casa::Array<casa::Float> spectrum_;
[125]198 casa::Array<casa::uChar> flags_;
[453]199
[16]200 // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of
[7]201 // channel, but this makes it easier to work with at the expense of
202 // a little memory
[125]203 casa::Array<casa::Float> tsys_;
204 casa::Array<casa::Float> tcal_;
[2]205
206 //(nIF) indx into "global" frequency table
[125]207 casa::Vector<casa::uInt> freqidx_;
[453]208
[388]209 // (nIF) indx into "global" rest frequency table
210 casa::Vector<casa::uInt> restfreqidx_;
[453]211
[79]212 //(nBeam,2) maybe use Measures here...
[125]213 casa::Array<casa::Double> direction_;
[453]214 casa::Array<casa::Int> fitIDMap_;
215
216 void setSlice(casa::IPosition& start, casa::IPosition& end,
[754]217 const casa::IPosition& shpIn, const casa::IPosition& shpOut,
218 casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol,
219 casa::Bool xPol) const;
[453]220 void setSlice(casa::IPosition& start, casa::IPosition& end,
[754]221 const casa::IPosition& shape,
222 casa::uInt whichBeam, casa::uInt whichIF) const;
[2]223};
224
[326]225
226
227class SDDataDesc {
228
229public:
230
[453]231 // Constructor
[326]232 SDDataDesc() : n_(0) {;}
233 ~SDDataDesc() {;}
234
[453]235 // Add an entry if source name and Integer ID (can be anything you
236 // like, such as FreqID) are unique. You can add secondary entries
237 // direction and another integer index which are just stored along
238 // with the the primary entries
239 casa::uInt addEntry(const casa::String& source, casa::uInt ID,
[754]240 const casa::MDirection& secDir, casa::uInt secID);
[326]241
[453]242 // Number of entries
[326]243 casa::Int length() const { return n_;}
[754]244
[453]245 // Get attributes
246 casa::String source(casa::uInt which) const {return source_[which];}
[396]247 casa::uInt ID(casa::uInt which) const {return ID_[which];}
248 casa::uInt secID(casa::uInt which) const {return secID_[which];}
[453]249 casa::MDirection secDir(casa::uInt which) const {return secDir_[which];}
[754]250
[453]251 // Summary
[326]252 void summary() const;
253
254private:
255 casa::uInt n_;
256 casa::Vector<casa::String> source_;
[396]257 casa::Vector<casa::uInt> ID_, secID_;
258 casa::Block<casa::MDirection> secDir_;
[453]259
[326]260 SDDataDesc(const SDDataDesc& other);
[349]261
[326]262};
263
[453]264
[2]265} // namespace
266#endif
Note: See TracBrowser for help on using the repository browser.