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