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