source: trunk/src/SDContainer.h @ 320

Last change on this file since 320 was 320, checked in by kil064, 19 years ago

document SDFreqTable functions a bit

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
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
41template<class T> class casa::Matrix;
42
43namespace asap {
44
45
46struct SDHeader {
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;
61  casa::String fluxunit;
62  casa::String epoch;
63  void print() const ;
64};
65
66class SDFrequencyTable {
67
68public:
69
70  SDFrequencyTable() : nFreq_(0) {;}
71  virtual ~SDFrequencyTable() {;}
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
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_; }
86  void restFrequencies(casa::Vector<casa::Double>& rfs,
87                       casa::String& rfunit ) const ;
88
89// Set attributes
90  void setEquinox(casa::Float eq) { equinox_ = eq; }
91  void setRefFrame(const casa::String& reff) { refFrame_ = reff; }
92  void addRestFrequency(casa::Double);
93  void setRestFrequencyUnit(const casa::String& theunit) {restFreqUnit_ = theunit;}
94
95private:
96  casa::Int nFreq_;
97  casa::Vector<casa::Double> refPix_;
98  casa::Vector<casa::Double> refVal_;           // Hz
99  casa::Vector<casa::Double> increment_;        // Hz
100  casa::Float equinox_;
101  casa::String refFrame_;
102  casa::Vector<casa::Double> restFreqs_;        // Hz
103  casa::String restFreqUnit_;
104};
105
106
107class SDContainer {
108
109public:
110  SDContainer(casa::uInt nBeam, casa::uInt nIF, casa::uInt nPol,
111              casa::uInt nChan);
112  SDContainer(casa::IPosition shp);
113
114  virtual ~SDContainer();
115
116  casa::Bool resize(casa::IPosition shp);
117
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);
121
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);
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);
129
130  casa::Bool setDirection(const casa::Vector<casa::Double>& point,
131                          casa::uInt whichBeam);
132  casa::Bool putDirection(const casa::Array<casa::Double>& dir);
133
134  casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
135  casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs);
136 
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;
144
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_; }
149
150  const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; }
151 
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
156  casa::Double timestamp;
157  //Double bandwidth;
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;
168
169private:
170  casa::uInt nBeam_,nIF_,nPol_,nChan_;
171
172  // (nBeam,nIF,nPol,nChannel)
173  casa::Array<casa::Float>    spectrum_; 
174  casa::Array<casa::uChar>    flags_;
175  // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of
176  // channel, but this makes it easier to work with at the expense of
177  // a little memory
178  casa::Array<casa::Float>    tsys_;
179  casa::Array<casa::Float>    tcal_;
180
181  //(nIF) indx into "global" frequency table
182  casa::Vector<casa::uInt>    freqidx_;
183  //(nBeam,2) maybe use Measures here...
184  casa::Array<casa::Double>   direction_;
185  casa::Vector<casa::String> history_;
186
187};
188
189} // namespace
190#endif
Note: See TracBrowser for help on using the repository browser.