[1778] | 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 | |
---|
[1780] | 13 | #include <casa/Containers/RecordField.h> |
---|
[1778] | 14 | |
---|
[1780] | 15 | #include "FillerBase.h" |
---|
| 16 | |
---|
[1778] | 17 | using namespace casa; |
---|
| 18 | |
---|
[1786] | 19 | namespace asap { |
---|
| 20 | |
---|
| 21 | FillerBase::FillerBase(casa::CountedPtr<Scantable> stable) : |
---|
| 22 | table_(stable) |
---|
[1778] | 23 | { |
---|
[1795] | 24 | row_ = TableRow(table_->table()); |
---|
[1778] | 25 | } |
---|
| 26 | |
---|
[1793] | 27 | void FillerBase::setHeader(const STHeader& header) |
---|
| 28 | { |
---|
| 29 | table_->setHeader(header); |
---|
| 30 | } |
---|
| 31 | |
---|
[1778] | 32 | void FillerBase::setSpectrum(const Vector<Float>& spectrum, |
---|
[1788] | 33 | const Vector<uChar>& flags, |
---|
| 34 | const Vector<Float>& tsys) |
---|
[1778] | 35 | { |
---|
| 36 | RecordFieldPtr< Array<Float> > specCol(row_.record(), "SPECTRA"); |
---|
| 37 | RecordFieldPtr< Array<uChar> > flagCol(row_.record(), "FLAGTRA"); |
---|
[1788] | 38 | RecordFieldPtr< Array<Float> > tsysCol(row_.record(), "TSYS"); |
---|
| 39 | |
---|
[1778] | 40 | *specCol = spectrum; |
---|
| 41 | *flagCol = flags; |
---|
[1788] | 42 | *tsysCol = tsys; |
---|
[1778] | 43 | } |
---|
| 44 | |
---|
[1788] | 45 | |
---|
| 46 | void FillerBase::setOpacity(Float opacity) |
---|
| 47 | { |
---|
| 48 | RecordFieldPtr<Float> tauCol(row_.record(), "OPACITY") ; |
---|
| 49 | *tauCol = opacity ; |
---|
| 50 | } |
---|
| 51 | |
---|
[1778] | 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"); |
---|
[1780] | 59 | RecordFieldPtr<uInt> scanCol(row_.record(), "SCANNO"); |
---|
[1778] | 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, |
---|
[1780] | 68 | Double incr) |
---|
[1778] | 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 | |
---|
[1780] | 78 | void FillerBase::setMolecule(const Vector<Double>& restfreq) |
---|
[1778] | 79 | { |
---|
[1780] | 80 | Vector<String> tmp; |
---|
| 81 | uInt id = table_->molecules().addEntry(restfreq, tmp, tmp); |
---|
[1778] | 82 | RecordFieldPtr<uInt> molidCol(row_.record(), "MOLECULE_ID"); |
---|
| 83 | *molidCol = id; |
---|
| 84 | } |
---|
| 85 | |
---|
[1780] | 86 | void FillerBase::setDirection(const Vector<Double>& dir, |
---|
[1778] | 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, |
---|
[1780] | 148 | Double velocity) |
---|
[1778] | 149 | { |
---|
| 150 | RecordFieldPtr<String> srcnCol(row_.record(), "SRCNAME"); |
---|
[1780] | 151 | *srcnCol = name; |
---|
[1778] | 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"); |
---|
[1780] | 157 | *spmCol = propermot; |
---|
[1778] | 158 | RecordFieldPtr<Array<Double> > sdirCol(row_.record(), "SRCDIRECTION"); |
---|
[1780] | 159 | *sdirCol = dir; |
---|
[1778] | 160 | RecordFieldPtr<Double> svelCol(row_.record(), "SRCVELOCITY"); |
---|
[1780] | 161 | *svelCol = velocity; |
---|
[1778] | 162 | } |
---|
| 163 | |
---|
| 164 | void FillerBase::commitRow() |
---|
| 165 | { |
---|
| 166 | table_->table().addRow(); |
---|
| 167 | row_.put(table_->table().nrow()-1); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | }; |
---|