source: trunk/src/FillerBase.cpp@ 2136

Last change on this file since 2136 was 1876, checked in by Takeshi Nakazato, 14 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Fixed a bug that causes regression failure.


File size: 4.9 KB
Line 
1//
2// C++ Interface: FillerBase
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2010
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12
13#include <casa/Containers/RecordField.h>
14
15#include "FillerBase.h"
16
17using namespace casa;
18
19namespace asap {
20
21FillerBase::FillerBase(casa::CountedPtr<Scantable> stable) :
22 table_(stable)
23{
24 row_ = TableRow(table_->table());
25}
26
27void FillerBase::setHeader(const STHeader& header)
28{
29 table_->setHeader(header);
30}
31
32void FillerBase::setSpectrum(const Vector<Float>& spectrum,
33 const Vector<uChar>& flags,
34 const Vector<Float>& tsys)
35{
36 RecordFieldPtr< Array<Float> > specCol(row_.record(), "SPECTRA");
37 RecordFieldPtr< Array<uChar> > flagCol(row_.record(), "FLAGTRA");
38 RecordFieldPtr< Array<Float> > tsysCol(row_.record(), "TSYS");
39
40 //*specCol = spectrum;
41 //*flagCol = flags;
42 //*tsysCol = tsys;
43 specCol.define(spectrum);
44 flagCol.define(flags);
45 tsysCol.define(tsys);
46}
47
48void FillerBase::setFlagrow(uInt flag)
49{
50 RecordFieldPtr<uInt> flagrowCol(row_.record(), "FLAGROW");
51 *flagrowCol = flag;
52}
53
54void FillerBase::setOpacity(Float opacity)
55{
56 RecordFieldPtr<Float> tauCol(row_.record(), "OPACITY") ;
57 *tauCol = opacity ;
58}
59
60void FillerBase::setIndex(uInt scanno, uInt cycleno, uInt ifno, uInt polno,
61 uInt beamno)
62{
63 RecordFieldPtr<uInt> beamCol(row_.record(), "BEAMNO");
64 RecordFieldPtr<uInt> ifCol(row_.record(), "IFNO");
65 RecordFieldPtr<uInt> polCol(row_.record(), "POLNO");
66 RecordFieldPtr<uInt> cycleCol(row_.record(), "CYCLENO");
67 RecordFieldPtr<uInt> scanCol(row_.record(), "SCANNO");
68 *beamCol = beamno;
69 *cycleCol = cycleno;
70 *ifCol = ifno;
71 *polCol = polno;
72 *scanCol = scanno;
73}
74
75void FillerBase::setFrequency(Double refpix, Double refval,
76 Double incr)
77{
78 /// @todo this has to change when nchan isn't global anymore
79 uInt id= table_->frequencies().addEntry(refpix, refval, incr);
80 RecordFieldPtr<uInt> mfreqidCol(row_.record(), "FREQ_ID");
81 *mfreqidCol = id;
82
83}
84
85
86void FillerBase::setMolecule(const Vector<Double>& restfreq)
87{
88 Vector<String> tmp;
89 uInt id = table_->molecules().addEntry(restfreq, tmp, tmp);
90 RecordFieldPtr<uInt> molidCol(row_.record(), "MOLECULE_ID");
91 *molidCol = id;
92}
93
94void FillerBase::setDirection(const Vector<Double>& dir,
95 Float az, Float el)
96{
97 RecordFieldPtr<Array<Double> > dirCol(row_.record(), "DIRECTION");
98 *dirCol = dir;
99 RecordFieldPtr<Float> azCol(row_.record(), "AZIMUTH");
100 *azCol = az;
101 RecordFieldPtr<Float> elCol(row_.record(), "ELEVATION");
102 *elCol = el;
103}
104
105void FillerBase::setFocus(Float pa, Float faxis,
106 Float ftan, Float frot)
107{
108 RecordFieldPtr<uInt> mfocusidCol(row_.record(), "FOCUS_ID");
109 uInt id = table_->focus().addEntry(pa, faxis, ftan, frot);
110 *mfocusidCol = id;
111}
112
113void FillerBase::setTime(Double mjd, Double interval)
114{
115 RecordFieldPtr<Double> mjdCol(row_.record(), "TIME");
116 *mjdCol = mjd;
117 RecordFieldPtr<Double> intCol(row_.record(), "INTERVAL");
118 *intCol = interval;
119
120}
121
122void FillerBase::setWeather(Float temperature, Float pressure,
123 Float humidity,
124 Float windspeed, Float windaz)
125{
126 uInt id = table_->weather().addEntry(temperature, pressure,
127 humidity, windspeed, windaz);
128 RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID");
129 *mweatheridCol = id;
130}
131
132void FillerBase::setTcal(const String& tcaltime,
133 const Vector<Float>& tcal)
134{
135 uInt id = table_->tcal().addEntry(tcaltime, tcal);
136 RecordFieldPtr<uInt> mcalidCol(row_.record(), "TCAL_ID");
137 *mcalidCol = id;
138}
139
140void FillerBase::setScanRate(const Vector<Double>& srate)
141{
142 RecordFieldPtr<Array<Double> > srateCol(row_.record(), "SCANRATE");
143 *srateCol = srate;
144}
145
146void FillerBase::setReferenceBeam(Int beamno)
147{
148 RecordFieldPtr<Int> rbCol(row_.record(), "REFBEAMNO");
149 *rbCol = beamno;
150}
151
152void FillerBase::setSource(const std::string& name, Int type,
153 const std::string& fieldname,
154 const Vector<Double>& dir,
155 const Vector<Double>& propermot,
156 Double velocity)
157{
158 RecordFieldPtr<String> srcnCol(row_.record(), "SRCNAME");
159 *srcnCol = name;
160 RecordFieldPtr<Int> srctCol(row_.record(), "SRCTYPE");
161 *srctCol = type;
162 RecordFieldPtr<String> fieldnCol(row_.record(), "FIELDNAME");
163 *fieldnCol = fieldname;
164 RecordFieldPtr<Array<Double> > spmCol(row_.record(), "SRCPROPERMOTION");
165 *spmCol = propermot;
166 RecordFieldPtr<Array<Double> > sdirCol(row_.record(), "SRCDIRECTION");
167 *sdirCol = dir;
168 RecordFieldPtr<Double> svelCol(row_.record(), "SRCVELOCITY");
169 *svelCol = velocity;
170}
171
172void FillerBase::commitRow()
173{
174 table_->table().addRow();
175 row_.put(table_->table().nrow()-1);
176}
177
178};
Note: See TracBrowser for help on using the repository browser.