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 |
|
---|
17 | using namespace casa;
|
---|
18 |
|
---|
19 | namespace asap {
|
---|
20 |
|
---|
21 | FillerBase::FillerBase(casa::CountedPtr<Scantable> stable) :
|
---|
22 | table_(stable)
|
---|
23 | {
|
---|
24 | row_ = TableRow(table_->table());
|
---|
25 | }
|
---|
26 |
|
---|
27 | void FillerBase::setHeader(const STHeader& header)
|
---|
28 | {
|
---|
29 | table_->setHeader(header);
|
---|
30 | }
|
---|
31 |
|
---|
32 | void 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 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | void FillerBase::setOpacity(Float opacity)
|
---|
47 | {
|
---|
48 | RecordFieldPtr<Float> tauCol(row_.record(), "OPACITY") ;
|
---|
49 | *tauCol = opacity ;
|
---|
50 | }
|
---|
51 |
|
---|
52 | void FillerBase::setIndex(uInt scanno, uInt cycleno, uInt ifno, uInt polno,
|
---|
53 | uInt beamno)
|
---|
54 | {
|
---|
55 | RecordFieldPtr<uInt> beamCol(row_.record(), "BEAMNO");
|
---|
56 | RecordFieldPtr<uInt> ifCol(row_.record(), "IFNO");
|
---|
57 | RecordFieldPtr<uInt> polCol(row_.record(), "POLNO");
|
---|
58 | RecordFieldPtr<uInt> cycleCol(row_.record(), "CYCLENO");
|
---|
59 | RecordFieldPtr<uInt> scanCol(row_.record(), "SCANNO");
|
---|
60 | *beamCol = beamno;
|
---|
61 | *cycleCol = cycleno;
|
---|
62 | *ifCol = ifno;
|
---|
63 | *polCol = polno;
|
---|
64 | *scanCol = scanno;
|
---|
65 | }
|
---|
66 |
|
---|
67 | void FillerBase::setFrequency(Double refpix, Double refval,
|
---|
68 | Double incr)
|
---|
69 | {
|
---|
70 | /// @todo this has to change when nchan isn't global anymore
|
---|
71 | uInt id= table_->frequencies().addEntry(refpix, refval, incr);
|
---|
72 | RecordFieldPtr<uInt> mfreqidCol(row_.record(), "FREQ_ID");
|
---|
73 | *mfreqidCol = id;
|
---|
74 |
|
---|
75 | }
|
---|
76 |
|
---|
77 |
|
---|
78 | void FillerBase::setMolecule(const Vector<Double>& restfreq)
|
---|
79 | {
|
---|
80 | Vector<String> tmp;
|
---|
81 | uInt id = table_->molecules().addEntry(restfreq, tmp, tmp);
|
---|
82 | RecordFieldPtr<uInt> molidCol(row_.record(), "MOLECULE_ID");
|
---|
83 | *molidCol = id;
|
---|
84 | }
|
---|
85 |
|
---|
86 | void FillerBase::setDirection(const Vector<Double>& dir,
|
---|
87 | Float az, Float el)
|
---|
88 | {
|
---|
89 | RecordFieldPtr<Array<Double> > dirCol(row_.record(), "DIRECTION");
|
---|
90 | *dirCol = dir;
|
---|
91 | RecordFieldPtr<Float> azCol(row_.record(), "AZIMUTH");
|
---|
92 | *azCol = az;
|
---|
93 | RecordFieldPtr<Float> elCol(row_.record(), "ELEVATION");
|
---|
94 | *elCol = el;
|
---|
95 | }
|
---|
96 |
|
---|
97 | void FillerBase::setFocus(Float pa, Float faxis,
|
---|
98 | Float ftan, Float frot)
|
---|
99 | {
|
---|
100 | RecordFieldPtr<uInt> mfocusidCol(row_.record(), "FOCUS_ID");
|
---|
101 | uInt id = table_->focus().addEntry(pa, faxis, ftan, frot);
|
---|
102 | *mfocusidCol = id;
|
---|
103 | }
|
---|
104 |
|
---|
105 | void FillerBase::setTime(Double interval, Double mjd)
|
---|
106 | {
|
---|
107 | RecordFieldPtr<Double> mjdCol(row_.record(), "TIME");
|
---|
108 | *mjdCol = mjd;
|
---|
109 | RecordFieldPtr<Double> intCol(row_.record(), "INTERVAL");
|
---|
110 | *intCol = interval;
|
---|
111 |
|
---|
112 | }
|
---|
113 |
|
---|
114 | void FillerBase::setWeather(Float temperature, Float pressure,
|
---|
115 | Float humidity,
|
---|
116 | Float windspeed, Float windaz)
|
---|
117 | {
|
---|
118 | uInt id = table_->weather().addEntry(temperature, pressure,
|
---|
119 | humidity, windspeed, windaz);
|
---|
120 | RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID");
|
---|
121 | *mweatheridCol = id;
|
---|
122 | }
|
---|
123 |
|
---|
124 | void FillerBase::setTcal(const String& tcaltime,
|
---|
125 | const Vector<Float>& tcal)
|
---|
126 | {
|
---|
127 | uInt id = table_->tcal().addEntry(tcaltime, tcal);
|
---|
128 | RecordFieldPtr<uInt> mcalidCol(row_.record(), "TCAL_ID");
|
---|
129 | *mcalidCol = id;
|
---|
130 | }
|
---|
131 |
|
---|
132 | void FillerBase::setScanRate(const Vector<Double>& srate)
|
---|
133 | {
|
---|
134 | RecordFieldPtr<Array<Double> > srateCol(row_.record(), "SCANRATE");
|
---|
135 | *srateCol = srate;
|
---|
136 | }
|
---|
137 |
|
---|
138 | void FillerBase::setReferenceBeam(Int beamno)
|
---|
139 | {
|
---|
140 | RecordFieldPtr<Int> rbCol(row_.record(), "REFBEAMNO");
|
---|
141 | *rbCol = beamno;
|
---|
142 | }
|
---|
143 |
|
---|
144 | void FillerBase::setSource(const std::string& name, Int type,
|
---|
145 | const std::string& fieldname,
|
---|
146 | const Vector<Double>& dir,
|
---|
147 | const Vector<Double>& propermot,
|
---|
148 | Double velocity)
|
---|
149 | {
|
---|
150 | RecordFieldPtr<String> srcnCol(row_.record(), "SRCNAME");
|
---|
151 | *srcnCol = name;
|
---|
152 | RecordFieldPtr<Int> srctCol(row_.record(), "SRCTYPE");
|
---|
153 | *srctCol = type;
|
---|
154 | RecordFieldPtr<String> fieldnCol(row_.record(), "FIELDNAME");
|
---|
155 | *fieldnCol = fieldname;
|
---|
156 | RecordFieldPtr<Array<Double> > spmCol(row_.record(), "SRCPROPERMOTION");
|
---|
157 | *spmCol = propermot;
|
---|
158 | RecordFieldPtr<Array<Double> > sdirCol(row_.record(), "SRCDIRECTION");
|
---|
159 | *sdirCol = dir;
|
---|
160 | RecordFieldPtr<Double> svelCol(row_.record(), "SRCVELOCITY");
|
---|
161 | *svelCol = velocity;
|
---|
162 | }
|
---|
163 |
|
---|
164 | void FillerBase::commitRow()
|
---|
165 | {
|
---|
166 | table_->table().addRow();
|
---|
167 | row_.put(table_->table().nrow()-1);
|
---|
168 | }
|
---|
169 |
|
---|
170 | };
|
---|