[805] | 1 | //
|
---|
| 2 | // C++ Implementation: STMath
|
---|
| 3 | //
|
---|
| 4 | // Description:
|
---|
| 5 | //
|
---|
| 6 | //
|
---|
| 7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
|
---|
| 8 | //
|
---|
| 9 | // Copyright: See COPYING file that comes with this distribution
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
[38] | 12 |
|
---|
[330] | 13 | #include <casa/iomanip.h>
|
---|
[805] | 14 | #include <casa/Exceptions/Error.h>
|
---|
| 15 | #include <casa/Containers/Block.h>
|
---|
[81] | 16 | #include <casa/BasicSL/String.h>
|
---|
[805] | 17 | #include <tables/Tables/TableIter.h>
|
---|
| 18 | #include <tables/Tables/TableCopy.h>
|
---|
| 19 | #include <casa/Arrays/MaskArrLogi.h>
|
---|
| 20 | #include <casa/Arrays/MaskArrMath.h>
|
---|
| 21 | #include <casa/Arrays/ArrayLogical.h>
|
---|
[81] | 22 | #include <casa/Arrays/ArrayMath.h>
|
---|
[805] | 23 | #include <casa/Containers/RecordField.h>
|
---|
| 24 | #include <tables/Tables/TableRow.h>
|
---|
| 25 | #include <tables/Tables/TableVector.h>
|
---|
[917] | 26 | #include <tables/Tables/TabVecMath.h>
|
---|
[805] | 27 | #include <tables/Tables/ExprNode.h>
|
---|
| 28 | #include <tables/Tables/TableRecord.h>
|
---|
| 29 | #include <tables/Tables/ReadAsciiTable.h>
|
---|
[2] | 30 |
|
---|
[262] | 31 | #include <lattices/Lattices/LatticeUtilities.h>
|
---|
| 32 |
|
---|
[917] | 33 | #include <coordinates/Coordinates/SpectralCoordinate.h>
|
---|
| 34 | #include <coordinates/Coordinates/CoordinateSystem.h>
|
---|
| 35 | #include <coordinates/Coordinates/CoordinateUtil.h>
|
---|
| 36 | #include <coordinates/Coordinates/FrequencyAligner.h>
|
---|
| 37 |
|
---|
[177] | 38 | #include <scimath/Mathematics/VectorKernel.h>
|
---|
| 39 | #include <scimath/Mathematics/Convolver.h>
|
---|
[234] | 40 | #include <scimath/Functionals/Polynomial.h>
|
---|
[177] | 41 |
|
---|
[38] | 42 | #include "MathUtils.h"
|
---|
[805] | 43 | #include "RowAccumulator.h"
|
---|
[878] | 44 | #include "STAttr.h"
|
---|
[805] | 45 | #include "STMath.h"
|
---|
[2] | 46 |
|
---|
[805] | 47 | using namespace casa;
|
---|
[2] | 48 |
|
---|
[83] | 49 | using namespace asap;
|
---|
[2] | 50 |
|
---|
[805] | 51 | STMath::STMath(bool insitu) :
|
---|
| 52 | insitu_(insitu)
|
---|
[716] | 53 | {
|
---|
| 54 | }
|
---|
[170] | 55 |
|
---|
| 56 |
|
---|
[805] | 57 | STMath::~STMath()
|
---|
[170] | 58 | {
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[805] | 61 | CountedPtr<Scantable>
|
---|
[977] | 62 | STMath::average( const std::vector<CountedPtr<Scantable> >& in,
|
---|
[858] | 63 | const std::vector<bool>& mask,
|
---|
[805] | 64 | const std::string& weight,
|
---|
[977] | 65 | const std::string& avmode)
|
---|
[262] | 66 | {
|
---|
[977] | 67 | if ( avmode == "SCAN" && in.size() != 1 )
|
---|
[805] | 68 | throw(AipsError("Can't perform 'SCAN' averaging on multiple tables"));
|
---|
| 69 | WeightType wtype = stringToWeight(weight);
|
---|
[926] | 70 |
|
---|
[805] | 71 | // output
|
---|
| 72 | // clone as this is non insitu
|
---|
| 73 | bool insitu = insitu_;
|
---|
| 74 | setInsitu(false);
|
---|
[977] | 75 | CountedPtr< Scantable > out = getScantable(in[0], true);
|
---|
[805] | 76 | setInsitu(insitu);
|
---|
[977] | 77 | std::vector<CountedPtr<Scantable> >::const_iterator stit = in.begin();
|
---|
[862] | 78 | ++stit;
|
---|
[977] | 79 | while ( stit != in.end() ) {
|
---|
[862] | 80 | out->appendToHistoryTable((*stit)->history());
|
---|
| 81 | ++stit;
|
---|
| 82 | }
|
---|
[294] | 83 |
|
---|
[805] | 84 | Table& tout = out->table();
|
---|
[701] | 85 |
|
---|
[805] | 86 | /// @todo check if all scantables are conformant
|
---|
[294] | 87 |
|
---|
[805] | 88 | ArrayColumn<Float> specColOut(tout,"SPECTRA");
|
---|
| 89 | ArrayColumn<uChar> flagColOut(tout,"FLAGTRA");
|
---|
| 90 | ArrayColumn<Float> tsysColOut(tout,"TSYS");
|
---|
| 91 | ScalarColumn<Double> mjdColOut(tout,"TIME");
|
---|
| 92 | ScalarColumn<Double> intColOut(tout,"INTERVAL");
|
---|
[1008] | 93 | ScalarColumn<uInt> cycColOut(tout,"CYCLENO");
|
---|
[262] | 94 |
|
---|
[805] | 95 | // set up the output table rows. These are based on the structure of the
|
---|
[862] | 96 | // FIRST scantable in the vector
|
---|
[977] | 97 | const Table& baset = in[0]->table();
|
---|
[262] | 98 |
|
---|
[805] | 99 | Block<String> cols(3);
|
---|
| 100 | cols[0] = String("BEAMNO");
|
---|
| 101 | cols[1] = String("IFNO");
|
---|
| 102 | cols[2] = String("POLNO");
|
---|
| 103 | if ( avmode == "SOURCE" ) {
|
---|
| 104 | cols.resize(4);
|
---|
| 105 | cols[3] = String("SRCNAME");
|
---|
[488] | 106 | }
|
---|
[977] | 107 | if ( avmode == "SCAN" && in.size() == 1) {
|
---|
[805] | 108 | cols.resize(4);
|
---|
| 109 | cols[3] = String("SCANNO");
|
---|
[2] | 110 | }
|
---|
[805] | 111 | uInt outrowCount = 0;
|
---|
| 112 | TableIterator iter(baset, cols);
|
---|
| 113 | while (!iter.pastEnd()) {
|
---|
| 114 | Table subt = iter.table();
|
---|
| 115 | // copy the first row of this selection into the new table
|
---|
| 116 | tout.addRow();
|
---|
| 117 | TableCopy::copyRows(tout, subt, outrowCount, 0, 1);
|
---|
| 118 | ++outrowCount;
|
---|
| 119 | ++iter;
|
---|
[144] | 120 | }
|
---|
[805] | 121 | RowAccumulator acc(wtype);
|
---|
[858] | 122 | Vector<Bool> cmask(mask);
|
---|
| 123 | acc.setUserMask(cmask);
|
---|
[805] | 124 | ROTableRow row(tout);
|
---|
| 125 | ROArrayColumn<Float> specCol, tsysCol;
|
---|
| 126 | ROArrayColumn<uChar> flagCol;
|
---|
| 127 | ROScalarColumn<Double> mjdCol, intCol;
|
---|
| 128 | ROScalarColumn<Int> scanIDCol;
|
---|
[144] | 129 |
|
---|
[805] | 130 | for (uInt i=0; i < tout.nrow(); ++i) {
|
---|
[996] | 131 | for ( int j=0; j < int(in.size()); ++j ) {
|
---|
[977] | 132 | const Table& tin = in[j]->table();
|
---|
[805] | 133 | const TableRecord& rec = row.get(i);
|
---|
| 134 | ROScalarColumn<Double> tmp(tin, "TIME");
|
---|
| 135 | Double td;tmp.get(0,td);
|
---|
| 136 | Table basesubt = tin(tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO"))
|
---|
| 137 | && tin.col("IFNO") == Int(rec.asuInt("IFNO"))
|
---|
| 138 | && tin.col("POLNO") == Int(rec.asuInt("POLNO")) );
|
---|
| 139 | Table subt;
|
---|
| 140 | if ( avmode == "SOURCE") {
|
---|
| 141 | subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME") );
|
---|
| 142 | } else if (avmode == "SCAN") {
|
---|
| 143 | subt = basesubt( basesubt.col("SCANNO") == Int(rec.asuInt("SCANNO")) );
|
---|
| 144 | } else {
|
---|
| 145 | subt = basesubt;
|
---|
| 146 | }
|
---|
| 147 | specCol.attach(subt,"SPECTRA");
|
---|
| 148 | flagCol.attach(subt,"FLAGTRA");
|
---|
| 149 | tsysCol.attach(subt,"TSYS");
|
---|
| 150 | intCol.attach(subt,"INTERVAL");
|
---|
| 151 | mjdCol.attach(subt,"TIME");
|
---|
| 152 | Vector<Float> spec,tsys;
|
---|
| 153 | Vector<uChar> flag;
|
---|
| 154 | Double inter,time;
|
---|
| 155 | for (uInt k = 0; k < subt.nrow(); ++k ) {
|
---|
| 156 | flagCol.get(k, flag);
|
---|
| 157 | Vector<Bool> bflag(flag.shape());
|
---|
| 158 | convertArray(bflag, flag);
|
---|
| 159 | if ( allEQ(bflag, True) ) {
|
---|
| 160 | continue;//don't accumulate
|
---|
[144] | 161 | }
|
---|
[805] | 162 | specCol.get(k, spec);
|
---|
| 163 | tsysCol.get(k, tsys);
|
---|
| 164 | intCol.get(k, inter);
|
---|
| 165 | mjdCol.get(k, time);
|
---|
| 166 | // spectrum has to be added last to enable weighting by the other values
|
---|
| 167 | acc.add(spec, !bflag, tsys, inter, time);
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 | //write out
|
---|
| 171 | specColOut.put(i, acc.getSpectrum());
|
---|
| 172 | const Vector<Bool>& msk = acc.getMask();
|
---|
| 173 | Vector<uChar> flg(msk.shape());
|
---|
| 174 | convertArray(flg, !msk);
|
---|
| 175 | flagColOut.put(i, flg);
|
---|
| 176 | tsysColOut.put(i, acc.getTsys());
|
---|
| 177 | intColOut.put(i, acc.getInterval());
|
---|
| 178 | mjdColOut.put(i, acc.getTime());
|
---|
[1008] | 179 | // we should only have one cycle now -> reset it to be 0
|
---|
| 180 | // frequency switched data has different CYCLENO for different IFNO
|
---|
| 181 | // which requires resetting this value
|
---|
| 182 | cycColOut.put(i, uInt(0));
|
---|
[805] | 183 | acc.reset();
|
---|
[144] | 184 | }
|
---|
[805] | 185 | return out;
|
---|
[2] | 186 | }
|
---|
[9] | 187 |
|
---|
[805] | 188 | CountedPtr< Scantable > STMath::getScantable(const CountedPtr< Scantable >& in,
|
---|
| 189 | bool droprows)
|
---|
[185] | 190 | {
|
---|
[805] | 191 | if (insitu_) return in;
|
---|
| 192 | else {
|
---|
| 193 | // clone
|
---|
| 194 | Scantable* tabp = new Scantable(*in, Bool(droprows));
|
---|
| 195 | return CountedPtr<Scantable>(tabp);
|
---|
[234] | 196 | }
|
---|
[805] | 197 | }
|
---|
[234] | 198 |
|
---|
[805] | 199 | CountedPtr< Scantable > STMath::unaryOperate( const CountedPtr< Scantable >& in,
|
---|
| 200 | float val,
|
---|
| 201 | const std::string& mode,
|
---|
| 202 | bool tsys )
|
---|
| 203 | {
|
---|
| 204 | // modes are "ADD" and "MUL"
|
---|
| 205 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 206 | Table& tab = out->table();
|
---|
| 207 | ArrayColumn<Float> specCol(tab,"SPECTRA");
|
---|
| 208 | ArrayColumn<Float> tsysCol(tab,"TSYS");
|
---|
| 209 | for (uInt i=0; i<tab.nrow(); ++i) {
|
---|
| 210 | Vector<Float> spec;
|
---|
| 211 | Vector<Float> ts;
|
---|
| 212 | specCol.get(i, spec);
|
---|
| 213 | tsysCol.get(i, ts);
|
---|
| 214 | if (mode == "MUL") {
|
---|
| 215 | spec *= val;
|
---|
| 216 | specCol.put(i, spec);
|
---|
| 217 | if ( tsys ) {
|
---|
| 218 | ts *= val;
|
---|
| 219 | tsysCol.put(i, ts);
|
---|
| 220 | }
|
---|
| 221 | } else if ( mode == "ADD" ) {
|
---|
| 222 | spec += val;
|
---|
| 223 | specCol.put(i, spec);
|
---|
| 224 | if ( tsys ) {
|
---|
| 225 | ts += val;
|
---|
| 226 | tsysCol.put(i, ts);
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
[234] | 229 | }
|
---|
[805] | 230 | return out;
|
---|
| 231 | }
|
---|
[234] | 232 |
|
---|
[805] | 233 | MaskedArray<Float> STMath::maskedArray( const Vector<Float>& s,
|
---|
| 234 | const Vector<uChar>& f)
|
---|
| 235 | {
|
---|
| 236 | Vector<Bool> mask;
|
---|
| 237 | mask.resize(f.shape());
|
---|
| 238 | convertArray(mask, f);
|
---|
| 239 | return MaskedArray<Float>(s,!mask);
|
---|
| 240 | }
|
---|
[248] | 241 |
|
---|
[805] | 242 | Vector<uChar> STMath::flagsFromMA(const MaskedArray<Float>& ma)
|
---|
| 243 | {
|
---|
| 244 | const Vector<Bool>& m = ma.getMask();
|
---|
| 245 | Vector<uChar> flags(m.shape());
|
---|
| 246 | convertArray(flags, !m);
|
---|
| 247 | return flags;
|
---|
| 248 | }
|
---|
[234] | 249 |
|
---|
[805] | 250 | CountedPtr< Scantable > STMath::quotient( const CountedPtr< Scantable >& in,
|
---|
| 251 | const std::string & mode,
|
---|
| 252 | bool preserve )
|
---|
| 253 | {
|
---|
| 254 | /// @todo make other modes available
|
---|
| 255 | /// modes should be "nearest", "pair"
|
---|
| 256 | // make this operation non insitu
|
---|
| 257 | const Table& tin = in->table();
|
---|
| 258 | Table ons = tin(tin.col("SRCTYPE") == Int(0));
|
---|
| 259 | Table offs = tin(tin.col("SRCTYPE") == Int(1));
|
---|
| 260 | if ( offs.nrow() == 0 )
|
---|
| 261 | throw(AipsError("No 'off' scans present."));
|
---|
| 262 | // put all "on" scans into output table
|
---|
[701] | 263 |
|
---|
[805] | 264 | bool insitu = insitu_;
|
---|
| 265 | setInsitu(false);
|
---|
| 266 | CountedPtr< Scantable > out = getScantable(in, true);
|
---|
| 267 | setInsitu(insitu);
|
---|
| 268 | Table& tout = out->table();
|
---|
[248] | 269 |
|
---|
[805] | 270 | TableCopy::copyRows(tout, ons);
|
---|
| 271 | TableRow row(tout);
|
---|
| 272 | ROScalarColumn<Double> offtimeCol(offs, "TIME");
|
---|
[234] | 273 |
|
---|
[805] | 274 | ArrayColumn<Float> outspecCol(tout, "SPECTRA");
|
---|
| 275 | ROArrayColumn<Float> outtsysCol(tout, "TSYS");
|
---|
| 276 | ArrayColumn<uChar> outflagCol(tout, "FLAGTRA");
|
---|
| 277 | for (uInt i=0; i < tout.nrow(); ++i) {
|
---|
| 278 | const TableRecord& rec = row.get(i);
|
---|
| 279 | Double ontime = rec.asDouble("TIME");
|
---|
| 280 | ROScalarColumn<Double> offtimeCol(offs, "TIME");
|
---|
| 281 | Double mindeltat = min(abs(offtimeCol.getColumn() - ontime));
|
---|
| 282 | Table sel = offs( abs(offs.col("TIME")-ontime) <= mindeltat
|
---|
| 283 | && offs.col("BEAMNO") == Int(rec.asuInt("BEAMNO"))
|
---|
| 284 | && offs.col("IFNO") == Int(rec.asuInt("IFNO"))
|
---|
| 285 | && offs.col("POLNO") == Int(rec.asuInt("POLNO")) );
|
---|
[780] | 286 |
|
---|
[805] | 287 | TableRow offrow(sel);
|
---|
| 288 | const TableRecord& offrec = offrow.get(0);//should only be one row
|
---|
| 289 | RORecordFieldPtr< Array<Float> > specoff(offrec, "SPECTRA");
|
---|
| 290 | RORecordFieldPtr< Array<Float> > tsysoff(offrec, "TSYS");
|
---|
| 291 | RORecordFieldPtr< Array<uChar> > flagoff(offrec, "FLAGTRA");
|
---|
| 292 | /// @fixme this assumes tsys is a scalar not vector
|
---|
| 293 | Float tsysoffscalar = (*tsysoff)(IPosition(1,0));
|
---|
| 294 | Vector<Float> specon, tsyson;
|
---|
| 295 | outtsysCol.get(i, tsyson);
|
---|
| 296 | outspecCol.get(i, specon);
|
---|
| 297 | Vector<uChar> flagon;
|
---|
| 298 | outflagCol.get(i, flagon);
|
---|
| 299 | MaskedArray<Float> mon = maskedArray(specon, flagon);
|
---|
| 300 | MaskedArray<Float> moff = maskedArray(*specoff, *flagoff);
|
---|
| 301 | MaskedArray<Float> quot = (tsysoffscalar * mon / moff);
|
---|
| 302 | if (preserve) {
|
---|
| 303 | quot -= tsysoffscalar;
|
---|
| 304 | } else {
|
---|
| 305 | quot -= tsyson[0];
|
---|
[701] | 306 | }
|
---|
[805] | 307 | outspecCol.put(i, quot.getArray());
|
---|
| 308 | outflagCol.put(i, flagsFromMA(quot));
|
---|
| 309 | }
|
---|
[926] | 310 | // renumber scanno
|
---|
| 311 | TableIterator it(tout, "SCANNO");
|
---|
| 312 | uInt i = 0;
|
---|
| 313 | while ( !it.pastEnd() ) {
|
---|
| 314 | Table t = it.table();
|
---|
| 315 | TableVector<uInt> vec(t, "SCANNO");
|
---|
| 316 | vec = i;
|
---|
| 317 | ++i;
|
---|
| 318 | ++it;
|
---|
| 319 | }
|
---|
[805] | 320 | return out;
|
---|
| 321 | }
|
---|
[234] | 322 |
|
---|
[805] | 323 | CountedPtr< Scantable > STMath::freqSwitch( const CountedPtr< Scantable >& in )
|
---|
| 324 | {
|
---|
| 325 | // make copy or reference
|
---|
| 326 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 327 | Table& tout = out->table();
|
---|
[1008] | 328 | Block<String> cols(4);
|
---|
[805] | 329 | cols[0] = String("SCANNO");
|
---|
[1008] | 330 | cols[1] = String("CYCLENO");
|
---|
| 331 | cols[2] = String("BEAMNO");
|
---|
| 332 | cols[3] = String("POLNO");
|
---|
[805] | 333 | TableIterator iter(tout, cols);
|
---|
| 334 | while (!iter.pastEnd()) {
|
---|
| 335 | Table subt = iter.table();
|
---|
| 336 | // this should leave us with two rows for the two IFs....if not ignore
|
---|
| 337 | if (subt.nrow() != 2 ) {
|
---|
| 338 | continue;
|
---|
[701] | 339 | }
|
---|
[1008] | 340 | ArrayColumn<Float> specCol(subt, "SPECTRA");
|
---|
| 341 | ArrayColumn<Float> tsysCol(subt, "TSYS");
|
---|
| 342 | ArrayColumn<uChar> flagCol(subt, "FLAGTRA");
|
---|
[805] | 343 | Vector<Float> onspec,offspec, ontsys, offtsys;
|
---|
| 344 | Vector<uChar> onflag, offflag;
|
---|
| 345 | tsysCol.get(0, ontsys); tsysCol.get(1, offtsys);
|
---|
| 346 | specCol.get(0, onspec); specCol.get(1, offspec);
|
---|
| 347 | flagCol.get(0, onflag); flagCol.get(1, offflag);
|
---|
| 348 | MaskedArray<Float> on = maskedArray(onspec, onflag);
|
---|
| 349 | MaskedArray<Float> off = maskedArray(offspec, offflag);
|
---|
| 350 | MaskedArray<Float> oncopy = on.copy();
|
---|
[248] | 351 |
|
---|
[805] | 352 | on /= off; on -= 1.0f;
|
---|
| 353 | on *= ontsys[0];
|
---|
| 354 | off /= oncopy; off -= 1.0f;
|
---|
| 355 | off *= offtsys[0];
|
---|
| 356 | specCol.put(0, on.getArray());
|
---|
| 357 | const Vector<Bool>& m0 = on.getMask();
|
---|
| 358 | Vector<uChar> flags0(m0.shape());
|
---|
| 359 | convertArray(flags0, !m0);
|
---|
| 360 | flagCol.put(0, flags0);
|
---|
[234] | 361 |
|
---|
[805] | 362 | specCol.put(1, off.getArray());
|
---|
| 363 | const Vector<Bool>& m1 = off.getMask();
|
---|
| 364 | Vector<uChar> flags1(m1.shape());
|
---|
| 365 | convertArray(flags1, !m1);
|
---|
| 366 | flagCol.put(1, flags1);
|
---|
[867] | 367 | ++iter;
|
---|
[130] | 368 | }
|
---|
[780] | 369 |
|
---|
[805] | 370 | return out;
|
---|
[9] | 371 | }
|
---|
[48] | 372 |
|
---|
[805] | 373 | std::vector< float > STMath::statistic( const CountedPtr< Scantable > & in,
|
---|
| 374 | const std::vector< bool > & mask,
|
---|
| 375 | const std::string& which )
|
---|
[130] | 376 | {
|
---|
| 377 |
|
---|
[805] | 378 | Vector<Bool> m(mask);
|
---|
| 379 | const Table& tab = in->table();
|
---|
| 380 | ROArrayColumn<Float> specCol(tab, "SPECTRA");
|
---|
| 381 | ROArrayColumn<uChar> flagCol(tab, "FLAGTRA");
|
---|
| 382 | std::vector<float> out;
|
---|
| 383 | for (uInt i=0; i < tab.nrow(); ++i ) {
|
---|
| 384 | Vector<Float> spec; specCol.get(i, spec);
|
---|
[867] | 385 | Vector<uChar> flag; flagCol.get(i, flag);
|
---|
| 386 | MaskedArray<Float> ma = maskedArray(spec, flag);
|
---|
| 387 | float outstat = 0.0;
|
---|
[805] | 388 | if ( spec.nelements() == m.nelements() ) {
|
---|
| 389 | outstat = mathutil::statistics(which, ma(m));
|
---|
| 390 | } else {
|
---|
| 391 | outstat = mathutil::statistics(which, ma);
|
---|
| 392 | }
|
---|
| 393 | out.push_back(outstat);
|
---|
[234] | 394 | }
|
---|
[805] | 395 | return out;
|
---|
[130] | 396 | }
|
---|
| 397 |
|
---|
[805] | 398 | CountedPtr< Scantable > STMath::bin( const CountedPtr< Scantable > & in,
|
---|
| 399 | int width )
|
---|
[144] | 400 | {
|
---|
[841] | 401 | if ( !in->getSelection().empty() ) throw(AipsError("Can't bin subset of the data."));
|
---|
[805] | 402 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 403 | Table& tout = out->table();
|
---|
| 404 | out->frequencies().rescale(width, "BIN");
|
---|
| 405 | ArrayColumn<Float> specCol(tout, "SPECTRA");
|
---|
| 406 | ArrayColumn<uChar> flagCol(tout, "FLAGTRA");
|
---|
| 407 | for (uInt i=0; i < tout.nrow(); ++i ) {
|
---|
| 408 | MaskedArray<Float> main = maskedArray(specCol(i), flagCol(i));
|
---|
| 409 | MaskedArray<Float> maout;
|
---|
| 410 | LatticeUtilities::bin(maout, main, 0, Int(width));
|
---|
| 411 | /// @todo implement channel based tsys binning
|
---|
| 412 | specCol.put(i, maout.getArray());
|
---|
| 413 | flagCol.put(i, flagsFromMA(maout));
|
---|
| 414 | // take only the first binned spectrum's length for the deprecated
|
---|
| 415 | // global header item nChan
|
---|
| 416 | if (i==0) tout.rwKeywordSet().define(String("nChan"),
|
---|
| 417 | Int(maout.getArray().nelements()));
|
---|
[169] | 418 | }
|
---|
[805] | 419 | return out;
|
---|
[146] | 420 | }
|
---|
| 421 |
|
---|
[805] | 422 | CountedPtr< Scantable > STMath::resample( const CountedPtr< Scantable >& in,
|
---|
| 423 | const std::string& method,
|
---|
| 424 | float width )
|
---|
[299] | 425 | //
|
---|
| 426 | // Should add the possibility of width being specified in km/s. This means
|
---|
[780] | 427 | // that for each freqID (SpectralCoordinate) we will need to convert to an
|
---|
| 428 | // average channel width (say at the reference pixel). Then we would need
|
---|
| 429 | // to be careful to make sure each spectrum (of different freqID)
|
---|
[299] | 430 | // is the same length.
|
---|
| 431 | //
|
---|
| 432 | {
|
---|
[996] | 433 | //InterpolateArray1D<Double,Float>::InterpolationMethod interp;
|
---|
[805] | 434 | Int interpMethod(stringToIMethod(method));
|
---|
[299] | 435 |
|
---|
[805] | 436 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 437 | Table& tout = out->table();
|
---|
[299] | 438 |
|
---|
| 439 | // Resample SpectralCoordinates (one per freqID)
|
---|
[805] | 440 | out->frequencies().rescale(width, "RESAMPLE");
|
---|
| 441 | TableIterator iter(tout, "IFNO");
|
---|
| 442 | TableRow row(tout);
|
---|
| 443 | while ( !iter.pastEnd() ) {
|
---|
| 444 | Table tab = iter.table();
|
---|
| 445 | ArrayColumn<Float> specCol(tab, "SPECTRA");
|
---|
| 446 | //ArrayColumn<Float> tsysCol(tout, "TSYS");
|
---|
| 447 | ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
|
---|
| 448 | Vector<Float> spec;
|
---|
| 449 | Vector<uChar> flag;
|
---|
| 450 | specCol.get(0,spec); // the number of channels should be constant per IF
|
---|
| 451 | uInt nChanIn = spec.nelements();
|
---|
| 452 | Vector<Float> xIn(nChanIn); indgen(xIn);
|
---|
| 453 | Int fac = Int(nChanIn/width);
|
---|
| 454 | Vector<Float> xOut(fac+10); // 10 to be safe - resize later
|
---|
| 455 | uInt k = 0;
|
---|
| 456 | Float x = 0.0;
|
---|
| 457 | while (x < Float(nChanIn) ) {
|
---|
| 458 | xOut(k) = x;
|
---|
| 459 | k++;
|
---|
| 460 | x += width;
|
---|
| 461 | }
|
---|
| 462 | uInt nChanOut = k;
|
---|
| 463 | xOut.resize(nChanOut, True);
|
---|
| 464 | // process all rows for this IFNO
|
---|
| 465 | Vector<Float> specOut;
|
---|
| 466 | Vector<Bool> maskOut;
|
---|
| 467 | Vector<uChar> flagOut;
|
---|
| 468 | for (uInt i=0; i < tab.nrow(); ++i) {
|
---|
| 469 | specCol.get(i, spec);
|
---|
| 470 | flagCol.get(i, flag);
|
---|
| 471 | Vector<Bool> mask(flag.nelements());
|
---|
| 472 | convertArray(mask, flag);
|
---|
[299] | 473 |
|
---|
[805] | 474 | IPosition shapeIn(spec.shape());
|
---|
| 475 | //sh.nchan = nChanOut;
|
---|
| 476 | InterpolateArray1D<Float,Float>::interpolate(specOut, maskOut, xOut,
|
---|
| 477 | xIn, spec, mask,
|
---|
| 478 | interpMethod, True, True);
|
---|
| 479 | /// @todo do the same for channel based Tsys
|
---|
| 480 | flagOut.resize(maskOut.nelements());
|
---|
| 481 | convertArray(flagOut, maskOut);
|
---|
| 482 | specCol.put(i, specOut);
|
---|
| 483 | flagCol.put(i, flagOut);
|
---|
| 484 | }
|
---|
| 485 | ++iter;
|
---|
[299] | 486 | }
|
---|
| 487 |
|
---|
[805] | 488 | return out;
|
---|
| 489 | }
|
---|
[299] | 490 |
|
---|
[805] | 491 | STMath::imethod STMath::stringToIMethod(const std::string& in)
|
---|
| 492 | {
|
---|
| 493 | static STMath::imap lookup;
|
---|
[299] | 494 |
|
---|
[805] | 495 | // initialize the lookup table if necessary
|
---|
| 496 | if ( lookup.empty() ) {
|
---|
[926] | 497 | lookup["nearest"] = InterpolateArray1D<Double,Float>::nearestNeighbour;
|
---|
| 498 | lookup["linear"] = InterpolateArray1D<Double,Float>::linear;
|
---|
| 499 | lookup["cubic"] = InterpolateArray1D<Double,Float>::cubic;
|
---|
| 500 | lookup["spline"] = InterpolateArray1D<Double,Float>::spline;
|
---|
[299] | 501 | }
|
---|
| 502 |
|
---|
[805] | 503 | STMath::imap::const_iterator iter = lookup.find(in);
|
---|
[299] | 504 |
|
---|
[805] | 505 | if ( lookup.end() == iter ) {
|
---|
| 506 | std::string message = in;
|
---|
| 507 | message += " is not a valid interpolation mode";
|
---|
| 508 | throw(AipsError(message));
|
---|
[299] | 509 | }
|
---|
[805] | 510 | return iter->second;
|
---|
[299] | 511 | }
|
---|
| 512 |
|
---|
[805] | 513 | WeightType STMath::stringToWeight(const std::string& in)
|
---|
[146] | 514 | {
|
---|
[805] | 515 | static std::map<std::string, WeightType> lookup;
|
---|
[434] | 516 |
|
---|
[805] | 517 | // initialize the lookup table if necessary
|
---|
| 518 | if ( lookup.empty() ) {
|
---|
| 519 | lookup["NONE"] = asap::NONE;
|
---|
| 520 | lookup["TINT"] = asap::TINT;
|
---|
| 521 | lookup["TINTSYS"] = asap::TINTSYS;
|
---|
| 522 | lookup["TSYS"] = asap::TSYS;
|
---|
| 523 | lookup["VAR"] = asap::VAR;
|
---|
| 524 | }
|
---|
[434] | 525 |
|
---|
[805] | 526 | std::map<std::string, WeightType>::const_iterator iter = lookup.find(in);
|
---|
[294] | 527 |
|
---|
[805] | 528 | if ( lookup.end() == iter ) {
|
---|
| 529 | std::string message = in;
|
---|
| 530 | message += " is not a valid weighting mode";
|
---|
| 531 | throw(AipsError(message));
|
---|
| 532 | }
|
---|
| 533 | return iter->second;
|
---|
[146] | 534 | }
|
---|
| 535 |
|
---|
[805] | 536 | CountedPtr< Scantable > STMath::gainElevation( const CountedPtr< Scantable >& in,
|
---|
[867] | 537 | const vector< float > & coeff,
|
---|
[805] | 538 | const std::string & filename,
|
---|
| 539 | const std::string& method)
|
---|
[165] | 540 | {
|
---|
[805] | 541 | // Get elevation data from Scantable and convert to degrees
|
---|
| 542 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
[926] | 543 | Table& tab = out->table();
|
---|
[805] | 544 | ROScalarColumn<Float> elev(tab, "ELEVATION");
|
---|
| 545 | Vector<Float> x = elev.getColumn();
|
---|
| 546 | x *= Float(180 / C::pi); // Degrees
|
---|
[165] | 547 |
|
---|
[867] | 548 | Vector<Float> coeffs(coeff);
|
---|
[805] | 549 | const uInt nc = coeffs.nelements();
|
---|
| 550 | if ( filename.length() > 0 && nc > 0 ) {
|
---|
| 551 | throw(AipsError("You must choose either polynomial coefficients or an ascii file, not both"));
|
---|
[315] | 552 | }
|
---|
[165] | 553 |
|
---|
[805] | 554 | // Correct
|
---|
| 555 | if ( nc > 0 || filename.length() == 0 ) {
|
---|
| 556 | // Find instrument
|
---|
| 557 | Bool throwit = True;
|
---|
| 558 | Instrument inst =
|
---|
[878] | 559 | STAttr::convertInstrument(tab.keywordSet().asString("AntennaName"),
|
---|
[805] | 560 | throwit);
|
---|
[165] | 561 |
|
---|
[805] | 562 | // Set polynomial
|
---|
| 563 | Polynomial<Float>* ppoly = 0;
|
---|
| 564 | Vector<Float> coeff;
|
---|
| 565 | String msg;
|
---|
| 566 | if ( nc > 0 ) {
|
---|
| 567 | ppoly = new Polynomial<Float>(nc);
|
---|
| 568 | coeff = coeffs;
|
---|
| 569 | msg = String("user");
|
---|
| 570 | } else {
|
---|
[878] | 571 | STAttr sdAttr;
|
---|
[805] | 572 | coeff = sdAttr.gainElevationPoly(inst);
|
---|
| 573 | ppoly = new Polynomial<Float>(3);
|
---|
| 574 | msg = String("built in");
|
---|
| 575 | }
|
---|
[532] | 576 |
|
---|
[805] | 577 | if ( coeff.nelements() > 0 ) {
|
---|
| 578 | ppoly->setCoefficients(coeff);
|
---|
| 579 | } else {
|
---|
| 580 | delete ppoly;
|
---|
| 581 | throw(AipsError("There is no known gain-elevation polynomial known for this instrument"));
|
---|
| 582 | }
|
---|
| 583 | ostringstream oss;
|
---|
| 584 | oss << "Making polynomial correction with " << msg << " coefficients:" << endl;
|
---|
| 585 | oss << " " << coeff;
|
---|
| 586 | pushLog(String(oss));
|
---|
| 587 | const uInt nrow = tab.nrow();
|
---|
| 588 | Vector<Float> factor(nrow);
|
---|
| 589 | for ( uInt i=0; i < nrow; ++i ) {
|
---|
| 590 | factor[i] = 1.0 / (*ppoly)(x[i]);
|
---|
| 591 | }
|
---|
| 592 | delete ppoly;
|
---|
| 593 | scaleByVector(tab, factor, true);
|
---|
[532] | 594 |
|
---|
[805] | 595 | } else {
|
---|
| 596 | // Read and correct
|
---|
| 597 | pushLog("Making correction from ascii Table");
|
---|
| 598 | scaleFromAsciiTable(tab, filename, method, x, true);
|
---|
[532] | 599 | }
|
---|
[805] | 600 | return out;
|
---|
| 601 | }
|
---|
[165] | 602 |
|
---|
[805] | 603 | void STMath::scaleFromAsciiTable(Table& in, const std::string& filename,
|
---|
| 604 | const std::string& method,
|
---|
| 605 | const Vector<Float>& xout, bool dotsys)
|
---|
| 606 | {
|
---|
[165] | 607 |
|
---|
[805] | 608 | // Read gain-elevation ascii file data into a Table.
|
---|
[165] | 609 |
|
---|
[805] | 610 | String formatString;
|
---|
| 611 | Table tbl = readAsciiTable(formatString, Table::Memory, filename, "", "", False);
|
---|
| 612 | scaleFromTable(in, tbl, method, xout, dotsys);
|
---|
| 613 | }
|
---|
[165] | 614 |
|
---|
[805] | 615 | void STMath::scaleFromTable(Table& in,
|
---|
| 616 | const Table& table,
|
---|
| 617 | const std::string& method,
|
---|
| 618 | const Vector<Float>& xout, bool dotsys)
|
---|
| 619 | {
|
---|
[780] | 620 |
|
---|
[805] | 621 | ROScalarColumn<Float> geElCol(table, "ELEVATION");
|
---|
| 622 | ROScalarColumn<Float> geFacCol(table, "FACTOR");
|
---|
| 623 | Vector<Float> xin = geElCol.getColumn();
|
---|
| 624 | Vector<Float> yin = geFacCol.getColumn();
|
---|
| 625 | Vector<Bool> maskin(xin.nelements(),True);
|
---|
[165] | 626 |
|
---|
[805] | 627 | // Interpolate (and extrapolate) with desired method
|
---|
[532] | 628 |
|
---|
[996] | 629 | InterpolateArray1D<Double,Float>::InterpolationMethod interp = stringToIMethod(method);
|
---|
[165] | 630 |
|
---|
[805] | 631 | Vector<Float> yout;
|
---|
| 632 | Vector<Bool> maskout;
|
---|
| 633 | InterpolateArray1D<Float,Float>::interpolate(yout, maskout, xout,
|
---|
[996] | 634 | xin, yin, maskin, interp,
|
---|
[805] | 635 | True, True);
|
---|
[165] | 636 |
|
---|
[805] | 637 | scaleByVector(in, Float(1.0)/yout, dotsys);
|
---|
[165] | 638 | }
|
---|
[167] | 639 |
|
---|
[805] | 640 | void STMath::scaleByVector( Table& in,
|
---|
| 641 | const Vector< Float >& factor,
|
---|
| 642 | bool dotsys )
|
---|
[177] | 643 | {
|
---|
[805] | 644 | uInt nrow = in.nrow();
|
---|
| 645 | if ( factor.nelements() != nrow ) {
|
---|
| 646 | throw(AipsError("factors.nelements() != table.nelements()"));
|
---|
| 647 | }
|
---|
| 648 | ArrayColumn<Float> specCol(in, "SPECTRA");
|
---|
| 649 | ArrayColumn<uChar> flagCol(in, "FLAGTRA");
|
---|
| 650 | ArrayColumn<Float> tsysCol(in, "TSYS");
|
---|
| 651 | for (uInt i=0; i < nrow; ++i) {
|
---|
| 652 | MaskedArray<Float> ma = maskedArray(specCol(i), flagCol(i));
|
---|
| 653 | ma *= factor[i];
|
---|
| 654 | specCol.put(i, ma.getArray());
|
---|
| 655 | flagCol.put(i, flagsFromMA(ma));
|
---|
| 656 | if ( dotsys ) {
|
---|
[926] | 657 | Vector<Float> tsys = tsysCol(i);
|
---|
[805] | 658 | tsys *= factor[i];
|
---|
[926] | 659 | tsysCol.put(i,tsys);
|
---|
[805] | 660 | }
|
---|
| 661 | }
|
---|
[177] | 662 | }
|
---|
| 663 |
|
---|
[805] | 664 | CountedPtr< Scantable > STMath::convertFlux( const CountedPtr< Scantable >& in,
|
---|
| 665 | float d, float etaap,
|
---|
| 666 | float jyperk )
|
---|
[221] | 667 | {
|
---|
[805] | 668 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 669 | Table& tab = in->table();
|
---|
| 670 | Unit fluxUnit(tab.keywordSet().asString("FluxUnit"));
|
---|
[221] | 671 | Unit K(String("K"));
|
---|
| 672 | Unit JY(String("Jy"));
|
---|
[701] | 673 |
|
---|
[805] | 674 | bool tokelvin = true;
|
---|
| 675 | Double cfac = 1.0;
|
---|
[716] | 676 |
|
---|
[805] | 677 | if ( fluxUnit == JY ) {
|
---|
[716] | 678 | pushLog("Converting to K");
|
---|
[701] | 679 | Quantum<Double> t(1.0,fluxUnit);
|
---|
| 680 | Quantum<Double> t2 = t.get(JY);
|
---|
[805] | 681 | cfac = (t2 / t).getValue(); // value to Jy
|
---|
[780] | 682 |
|
---|
[805] | 683 | tokelvin = true;
|
---|
| 684 | out->setFluxUnit("K");
|
---|
| 685 | } else if ( fluxUnit == K ) {
|
---|
[716] | 686 | pushLog("Converting to Jy");
|
---|
[701] | 687 | Quantum<Double> t(1.0,fluxUnit);
|
---|
| 688 | Quantum<Double> t2 = t.get(K);
|
---|
[805] | 689 | cfac = (t2 / t).getValue(); // value to K
|
---|
[780] | 690 |
|
---|
[805] | 691 | tokelvin = false;
|
---|
| 692 | out->setFluxUnit("Jy");
|
---|
[221] | 693 | } else {
|
---|
[701] | 694 | throw(AipsError("Unrecognized brightness units in Table - must be consistent with Jy or K"));
|
---|
[221] | 695 | }
|
---|
[701] | 696 | // Make sure input values are converted to either Jy or K first...
|
---|
[805] | 697 | Float factor = cfac;
|
---|
[221] | 698 |
|
---|
[701] | 699 | // Select method
|
---|
[805] | 700 | if (jyperk > 0.0) {
|
---|
| 701 | factor *= jyperk;
|
---|
| 702 | if ( tokelvin ) factor = 1.0 / jyperk;
|
---|
[716] | 703 | ostringstream oss;
|
---|
[805] | 704 | oss << "Jy/K = " << jyperk;
|
---|
[716] | 705 | pushLog(String(oss));
|
---|
[805] | 706 | Vector<Float> factors(tab.nrow(), factor);
|
---|
| 707 | scaleByVector(tab,factors, false);
|
---|
| 708 | } else if ( etaap > 0.0) {
|
---|
| 709 | Instrument inst =
|
---|
[878] | 710 | STAttr::convertInstrument(tab.keywordSet().asString("AntennaName"), True);
|
---|
| 711 | STAttr sda;
|
---|
[805] | 712 | if (d < 0) d = sda.diameter(inst);
|
---|
[996] | 713 | jyperk = STAttr::findJyPerK(etaap, d);
|
---|
[716] | 714 | ostringstream oss;
|
---|
[805] | 715 | oss << "Jy/K = " << jyperk;
|
---|
[716] | 716 | pushLog(String(oss));
|
---|
[805] | 717 | factor *= jyperk;
|
---|
| 718 | if ( tokelvin ) {
|
---|
[701] | 719 | factor = 1.0 / factor;
|
---|
| 720 | }
|
---|
[805] | 721 | Vector<Float> factors(tab.nrow(), factor);
|
---|
| 722 | scaleByVector(tab, factors, False);
|
---|
[354] | 723 | } else {
|
---|
[780] | 724 |
|
---|
[701] | 725 | // OK now we must deal with automatic look up of values.
|
---|
| 726 | // We must also deal with the fact that the factors need
|
---|
| 727 | // to be computed per IF and may be different and may
|
---|
| 728 | // change per integration.
|
---|
[780] | 729 |
|
---|
[716] | 730 | pushLog("Looking up conversion factors");
|
---|
[805] | 731 | convertBrightnessUnits(out, tokelvin, cfac);
|
---|
[701] | 732 | }
|
---|
[805] | 733 |
|
---|
| 734 | return out;
|
---|
[221] | 735 | }
|
---|
| 736 |
|
---|
[805] | 737 | void STMath::convertBrightnessUnits( CountedPtr<Scantable>& in,
|
---|
| 738 | bool tokelvin, float cfac )
|
---|
[227] | 739 | {
|
---|
[805] | 740 | Table& table = in->table();
|
---|
| 741 | Instrument inst =
|
---|
[878] | 742 | STAttr::convertInstrument(table.keywordSet().asString("AntennaName"), True);
|
---|
[805] | 743 | TableIterator iter(table, "FREQ_ID");
|
---|
| 744 | STFrequencies stfreqs = in->frequencies();
|
---|
[878] | 745 | STAttr sdAtt;
|
---|
[805] | 746 | while (!iter.pastEnd()) {
|
---|
| 747 | Table tab = iter.table();
|
---|
| 748 | ArrayColumn<Float> specCol(tab, "SPECTRA");
|
---|
| 749 | ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
|
---|
| 750 | ROScalarColumn<uInt> freqidCol(tab, "FREQ_ID");
|
---|
| 751 | MEpoch::ROScalarColumn timeCol(tab, "TIME");
|
---|
[234] | 752 |
|
---|
[805] | 753 | uInt freqid; freqidCol.get(0, freqid);
|
---|
| 754 | Vector<Float> tmpspec; specCol.get(0, tmpspec);
|
---|
[878] | 755 | // STAttr.JyPerK has a Vector interface... change sometime.
|
---|
[805] | 756 | Vector<Float> freqs(1,stfreqs.getRefFreq(freqid, tmpspec.nelements()));
|
---|
| 757 | for ( uInt i=0; i<tab.nrow(); ++i) {
|
---|
| 758 | Float jyperk = (sdAtt.JyPerK(inst, timeCol(i), freqs))[0];
|
---|
| 759 | Float factor = cfac * jyperk;
|
---|
| 760 | if ( tokelvin ) factor = Float(1.0) / factor;
|
---|
| 761 | MaskedArray<Float> ma = maskedArray(specCol(i), flagCol(i));
|
---|
| 762 | ma *= factor;
|
---|
| 763 | specCol.put(i, ma.getArray());
|
---|
| 764 | flagCol.put(i, flagsFromMA(ma));
|
---|
| 765 | }
|
---|
[867] | 766 | ++iter;
|
---|
[234] | 767 | }
|
---|
[230] | 768 | }
|
---|
[227] | 769 |
|
---|
[805] | 770 | CountedPtr< Scantable > STMath::opacity( const CountedPtr< Scantable > & in,
|
---|
| 771 | float tau )
|
---|
[234] | 772 | {
|
---|
[805] | 773 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
[926] | 774 |
|
---|
| 775 | Table tab = out->table();
|
---|
[234] | 776 | ROScalarColumn<Float> elev(tab, "ELEVATION");
|
---|
[805] | 777 | ArrayColumn<Float> specCol(tab, "SPECTRA");
|
---|
| 778 | ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
|
---|
| 779 | for ( uInt i=0; i<tab.nrow(); ++i) {
|
---|
| 780 | Float zdist = Float(C::pi_2) - elev(i);
|
---|
| 781 | Float factor = exp(tau)/cos(zdist);
|
---|
[926] | 782 | MaskedArray<Float> ma = maskedArray(specCol(i), flagCol(i));
|
---|
[805] | 783 | ma *= factor;
|
---|
| 784 | specCol.put(i, ma.getArray());
|
---|
| 785 | flagCol.put(i, flagsFromMA(ma));
|
---|
[234] | 786 | }
|
---|
[805] | 787 | return out;
|
---|
[234] | 788 | }
|
---|
| 789 |
|
---|
[805] | 790 | CountedPtr< Scantable > STMath::smooth( const CountedPtr< Scantable >& in,
|
---|
| 791 | const std::string& kernel, float width )
|
---|
[457] | 792 | {
|
---|
[805] | 793 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
[1033] | 794 | Table& table = out->table();
|
---|
[805] | 795 | VectorKernel::KernelTypes type = VectorKernel::toKernelType(kernel);
|
---|
| 796 | // same IFNO should have same no of channels
|
---|
| 797 | // this saves overhead
|
---|
| 798 | TableIterator iter(table, "IFNO");
|
---|
| 799 | while (!iter.pastEnd()) {
|
---|
| 800 | Table tab = iter.table();
|
---|
| 801 | ArrayColumn<Float> specCol(tab, "SPECTRA");
|
---|
| 802 | ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
|
---|
| 803 | Vector<Float> tmpspec; specCol.get(0, tmpspec);
|
---|
| 804 | uInt nchan = tmpspec.nelements();
|
---|
| 805 | Vector<Float> kvec = VectorKernel::make(type, width, nchan, True, False);
|
---|
| 806 | Convolver<Float> conv(kvec, IPosition(1,nchan));
|
---|
| 807 | Vector<Float> spec;
|
---|
| 808 | Vector<uChar> flag;
|
---|
| 809 | for ( uInt i=0; i<tab.nrow(); ++i) {
|
---|
| 810 | specCol.get(i, spec);
|
---|
| 811 | flagCol.get(i, flag);
|
---|
| 812 | Vector<Bool> mask(flag.nelements());
|
---|
| 813 | convertArray(mask, flag);
|
---|
| 814 | Vector<Float> specout;
|
---|
| 815 | if ( type == VectorKernel::HANNING ) {
|
---|
| 816 | Vector<Bool> maskout;
|
---|
[1033] | 817 | mathutil::hanning(specout, maskout, spec , !mask);
|
---|
| 818 | convertArray(flag, !maskout);
|
---|
[805] | 819 | flagCol.put(i, flag);
|
---|
[1033] | 820 | specCol.put(i, specout);
|
---|
| 821 | } else {
|
---|
[805] | 822 | mathutil::replaceMaskByZero(specout, mask);
|
---|
| 823 | conv.linearConv(specout, spec);
|
---|
[1033] | 824 | specCol.put(i, specout);
|
---|
[354] | 825 | }
|
---|
[805] | 826 | }
|
---|
[867] | 827 | ++iter;
|
---|
[701] | 828 | }
|
---|
[805] | 829 | return out;
|
---|
[701] | 830 | }
|
---|
[841] | 831 |
|
---|
| 832 | CountedPtr< Scantable >
|
---|
| 833 | STMath::merge( const std::vector< CountedPtr < Scantable > >& in )
|
---|
| 834 | {
|
---|
| 835 | if ( in.size() < 2 ) {
|
---|
[862] | 836 | throw(AipsError("Need at least two scantables to perform a merge."));
|
---|
[841] | 837 | }
|
---|
| 838 | std::vector<CountedPtr < Scantable > >::const_iterator it = in.begin();
|
---|
| 839 | bool insitu = insitu_;
|
---|
| 840 | setInsitu(false);
|
---|
[862] | 841 | CountedPtr< Scantable > out = getScantable(*it, false);
|
---|
[841] | 842 | setInsitu(insitu);
|
---|
| 843 | Table& tout = out->table();
|
---|
| 844 | ScalarColumn<uInt> freqidcol(tout,"FREQ_ID"), molidcol(tout, "MOLECULE_ID");
|
---|
[917] | 845 | ScalarColumn<uInt> scannocol(tout,"SCANNO"), focusidcol(tout,"FOCUS_ID");
|
---|
| 846 | // Renumber SCANNO to be 0-based
|
---|
[926] | 847 | Vector<uInt> scannos = scannocol.getColumn();
|
---|
| 848 | uInt offset = min(scannos);
|
---|
[917] | 849 | scannos -= offset;
|
---|
[926] | 850 | scannocol.putColumn(scannos);
|
---|
| 851 | uInt newscanno = max(scannos)+1;
|
---|
[862] | 852 | ++it;
|
---|
[841] | 853 | while ( it != in.end() ){
|
---|
| 854 | if ( ! (*it)->conformant(*out) ) {
|
---|
| 855 | // log message: "ignoring scantable i, as it isn't
|
---|
| 856 | // conformant with the other(s)"
|
---|
| 857 | cerr << "oh oh" << endl;
|
---|
| 858 | ++it;
|
---|
| 859 | continue;
|
---|
| 860 | }
|
---|
[862] | 861 | out->appendToHistoryTable((*it)->history());
|
---|
[841] | 862 | const Table& tab = (*it)->table();
|
---|
| 863 | TableIterator scanit(tab, "SCANNO");
|
---|
| 864 | while (!scanit.pastEnd()) {
|
---|
| 865 | TableIterator freqit(scanit.table(), "FREQ_ID");
|
---|
| 866 | while ( !freqit.pastEnd() ) {
|
---|
| 867 | Table thetab = freqit.table();
|
---|
| 868 | uInt nrow = tout.nrow();
|
---|
| 869 | //tout.addRow(thetab.nrow());
|
---|
| 870 | TableCopy::copyRows(tout, thetab, nrow, 0, thetab.nrow());
|
---|
| 871 | ROTableRow row(thetab);
|
---|
| 872 | for ( uInt i=0; i<thetab.nrow(); ++i) {
|
---|
| 873 | uInt k = nrow+i;
|
---|
| 874 | scannocol.put(k, newscanno);
|
---|
| 875 | const TableRecord& rec = row.get(i);
|
---|
| 876 | Double rv,rp,inc;
|
---|
| 877 | (*it)->frequencies().getEntry(rp, rv, inc, rec.asuInt("FREQ_ID"));
|
---|
| 878 | uInt id;
|
---|
| 879 | id = out->frequencies().addEntry(rp, rv, inc);
|
---|
| 880 | freqidcol.put(k,id);
|
---|
| 881 | String name,fname;Double rf;
|
---|
| 882 | (*it)->molecules().getEntry(rf, name, fname, rec.asuInt("MOLECULE_ID"));
|
---|
| 883 | id = out->molecules().addEntry(rf, name, fname);
|
---|
| 884 | molidcol.put(k, id);
|
---|
[961] | 885 | Float frot,fax,ftan,fhand,fmount,fuser, fxy, fxyp;
|
---|
| 886 | (*it)->focus().getEntry(fax, ftan, frot, fhand,
|
---|
| 887 | fmount,fuser, fxy, fxyp,
|
---|
| 888 | rec.asuInt("FOCUS_ID"));
|
---|
| 889 | id = out->focus().addEntry(fax, ftan, frot, fhand,
|
---|
| 890 | fmount,fuser, fxy, fxyp);
|
---|
[841] | 891 | focusidcol.put(k, id);
|
---|
| 892 | }
|
---|
| 893 | ++freqit;
|
---|
| 894 | }
|
---|
| 895 | ++newscanno;
|
---|
| 896 | ++scanit;
|
---|
| 897 | }
|
---|
| 898 | ++it;
|
---|
| 899 | }
|
---|
| 900 | return out;
|
---|
| 901 | }
|
---|
[896] | 902 |
|
---|
| 903 | CountedPtr< Scantable >
|
---|
| 904 | STMath::invertPhase( const CountedPtr < Scantable >& in )
|
---|
| 905 | {
|
---|
[996] | 906 | return applyToPol(in, &STPol::invertPhase, Float(0.0));
|
---|
[896] | 907 | }
|
---|
| 908 |
|
---|
| 909 | CountedPtr< Scantable >
|
---|
| 910 | STMath::rotateXYPhase( const CountedPtr < Scantable >& in, float phase )
|
---|
| 911 | {
|
---|
| 912 | return applyToPol(in, &STPol::rotatePhase, Float(phase));
|
---|
| 913 | }
|
---|
| 914 |
|
---|
| 915 | CountedPtr< Scantable >
|
---|
| 916 | STMath::rotateLinPolPhase( const CountedPtr < Scantable >& in, float phase )
|
---|
| 917 | {
|
---|
| 918 | return applyToPol(in, &STPol::rotateLinPolPhase, Float(phase));
|
---|
| 919 | }
|
---|
| 920 |
|
---|
| 921 | CountedPtr< Scantable > STMath::applyToPol( const CountedPtr<Scantable>& in,
|
---|
| 922 | STPol::polOperation fptr,
|
---|
| 923 | Float phase )
|
---|
| 924 | {
|
---|
| 925 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 926 | Table& tout = out->table();
|
---|
| 927 | Block<String> cols(4);
|
---|
| 928 | cols[0] = String("SCANNO");
|
---|
| 929 | cols[1] = String("BEAMNO");
|
---|
| 930 | cols[2] = String("IFNO");
|
---|
| 931 | cols[3] = String("CYCLENO");
|
---|
| 932 | TableIterator iter(tout, cols);
|
---|
[1015] | 933 | STPol* stpol = STPol::getPolClass(out->factories_, out->getPolType() );
|
---|
[896] | 934 | while (!iter.pastEnd()) {
|
---|
| 935 | Table t = iter.table();
|
---|
| 936 | ArrayColumn<Float> speccol(t, "SPECTRA");
|
---|
[1015] | 937 | ScalarColumn<uInt> focidcol(t, "FOCUS_ID");
|
---|
| 938 | ScalarColumn<Float> parancol(t, "PARANGLE");
|
---|
[896] | 939 | Matrix<Float> pols = speccol.getColumn();
|
---|
| 940 | try {
|
---|
| 941 | stpol->setSpectra(pols);
|
---|
[1015] | 942 | Float fang,fhand,parang;
|
---|
| 943 | fang = in->focusTable_.getTotalFeedAngle(focidcol(0));
|
---|
| 944 | fhand = in->focusTable_.getFeedHand(focidcol(0));
|
---|
| 945 | parang = parancol(0);
|
---|
| 946 | /// @todo re-enable this
|
---|
| 947 | // disable total feed angle to support paralactifying Caswell style
|
---|
| 948 | stpol->setPhaseCorrections(parang, -parang, fhand);
|
---|
[896] | 949 | (stpol->*fptr)(phase);
|
---|
| 950 | speccol.putColumn(stpol->getSpectra());
|
---|
[1015] | 951 | Matrix<Float> tmp = stpol->getSpectra();
|
---|
[896] | 952 | } catch (AipsError& e) {
|
---|
| 953 | delete stpol;stpol=0;
|
---|
| 954 | throw(e);
|
---|
| 955 | }
|
---|
| 956 | ++iter;
|
---|
| 957 | }
|
---|
[934] | 958 | delete stpol;stpol=0;
|
---|
[896] | 959 | return out;
|
---|
| 960 | }
|
---|
| 961 |
|
---|
| 962 | CountedPtr< Scantable >
|
---|
| 963 | STMath::swapPolarisations( const CountedPtr< Scantable > & in )
|
---|
| 964 | {
|
---|
| 965 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
| 966 | Table& tout = out->table();
|
---|
| 967 | Table t0 = tout(tout.col("POLNO") == 0);
|
---|
| 968 | Table t1 = tout(tout.col("POLNO") == 1);
|
---|
| 969 | if ( t0.nrow() != t1.nrow() )
|
---|
| 970 | throw(AipsError("Inconsistent number of polarisations"));
|
---|
| 971 | ArrayColumn<Float> speccol0(t0, "SPECTRA");
|
---|
| 972 | ArrayColumn<uChar> flagcol0(t0, "FLAGTRA");
|
---|
| 973 | ArrayColumn<Float> speccol1(t1, "SPECTRA");
|
---|
| 974 | ArrayColumn<uChar> flagcol1(t1, "FLAGTRA");
|
---|
| 975 | Matrix<Float> s0 = speccol0.getColumn();
|
---|
| 976 | Matrix<uChar> f0 = flagcol0.getColumn();
|
---|
| 977 | speccol0.putColumn(speccol1.getColumn());
|
---|
| 978 | flagcol0.putColumn(flagcol1.getColumn());
|
---|
| 979 | speccol1.putColumn(s0);
|
---|
| 980 | flagcol1.putColumn(f0);
|
---|
| 981 | return out;
|
---|
| 982 | }
|
---|
[917] | 983 |
|
---|
| 984 | CountedPtr< Scantable >
|
---|
[940] | 985 | STMath::averagePolarisations( const CountedPtr< Scantable > & in,
|
---|
| 986 | const std::vector<bool>& mask,
|
---|
| 987 | const std::string& weight )
|
---|
| 988 | {
|
---|
| 989 | if (in->getPolType() != "linear" || in->npol() != 2 )
|
---|
| 990 | throw(AipsError("averagePolarisations can only be applied to two linear polarisations."));
|
---|
[1010] | 991 | bool insitu = insitu_;
|
---|
| 992 | setInsitu(false);
|
---|
| 993 | CountedPtr< Scantable > pols = getScantable(in, false);
|
---|
| 994 | setInsitu(insitu);
|
---|
| 995 | Table& tout = pols->table();
|
---|
| 996 | // give all rows the same POLNO
|
---|
| 997 | TableVector<uInt> vec(tout,"POLNO");
|
---|
[940] | 998 | vec = 0;
|
---|
[1010] | 999 | pols->table_.rwKeywordSet().define("nPol",Int(1));
|
---|
| 1000 | std::vector<CountedPtr<Scantable> > vpols;
|
---|
| 1001 | vpols.push_back(pols);
|
---|
| 1002 | CountedPtr< Scantable > out = average(vpols, mask, weight, "NONE");
|
---|
[940] | 1003 | return out;
|
---|
| 1004 | }
|
---|
| 1005 |
|
---|
| 1006 |
|
---|
| 1007 | CountedPtr< Scantable >
|
---|
[917] | 1008 | asap::STMath::frequencyAlign( const CountedPtr< Scantable > & in,
|
---|
| 1009 | const std::string & refTime,
|
---|
[926] | 1010 | const std::string & method)
|
---|
[917] | 1011 | {
|
---|
[940] | 1012 | // clone as this is not working insitu
|
---|
| 1013 | bool insitu = insitu_;
|
---|
| 1014 | setInsitu(false);
|
---|
[917] | 1015 | CountedPtr< Scantable > out = getScantable(in, false);
|
---|
[940] | 1016 | setInsitu(insitu);
|
---|
[917] | 1017 | Table& tout = out->table();
|
---|
| 1018 | // Get reference Epoch to time of first row or given String
|
---|
| 1019 | Unit DAY(String("d"));
|
---|
| 1020 | MEpoch::Ref epochRef(in->getTimeReference());
|
---|
| 1021 | MEpoch refEpoch;
|
---|
| 1022 | if (refTime.length()>0) {
|
---|
| 1023 | Quantum<Double> qt;
|
---|
| 1024 | if (MVTime::read(qt,refTime)) {
|
---|
| 1025 | MVEpoch mv(qt);
|
---|
| 1026 | refEpoch = MEpoch(mv, epochRef);
|
---|
| 1027 | } else {
|
---|
| 1028 | throw(AipsError("Invalid format for Epoch string"));
|
---|
| 1029 | }
|
---|
| 1030 | } else {
|
---|
| 1031 | refEpoch = in->timeCol_(0);
|
---|
| 1032 | }
|
---|
| 1033 | MPosition refPos = in->getAntennaPosition();
|
---|
[940] | 1034 |
|
---|
[996] | 1035 | InterpolateArray1D<Double,Float>::InterpolationMethod interp = stringToIMethod(method);
|
---|
[917] | 1036 | // test if user frame is different to base frame
|
---|
| 1037 | if ( in->frequencies().getFrameString(true)
|
---|
| 1038 | == in->frequencies().getFrameString(false) ) {
|
---|
[985] | 1039 | throw(AipsError("Can't convert as no output frame has been set"
|
---|
| 1040 | " (use set_freqframe) or it is aligned already."));
|
---|
[917] | 1041 | }
|
---|
| 1042 | MFrequency::Types system = in->frequencies().getFrame();
|
---|
[940] | 1043 | MVTime mvt(refEpoch.getValue());
|
---|
| 1044 | String epochout = mvt.string(MVTime::YMD) + String(" (") + refEpoch.getRefString() + String(")");
|
---|
| 1045 | ostringstream oss;
|
---|
| 1046 | oss << "Aligned at reference Epoch " << epochout
|
---|
| 1047 | << " in frame " << MFrequency::showType(system);
|
---|
| 1048 | pushLog(String(oss));
|
---|
[917] | 1049 | // set up the iterator
|
---|
[926] | 1050 | Block<String> cols(4);
|
---|
| 1051 | // select by constant direction
|
---|
[917] | 1052 | cols[0] = String("SRCNAME");
|
---|
| 1053 | cols[1] = String("BEAMNO");
|
---|
| 1054 | // select by IF ( no of channels varies over this )
|
---|
| 1055 | cols[2] = String("IFNO");
|
---|
[926] | 1056 | // select by restfrequency
|
---|
| 1057 | cols[3] = String("MOLECULE_ID");
|
---|
[917] | 1058 | TableIterator iter(tout, cols);
|
---|
[926] | 1059 | while ( !iter.pastEnd() ) {
|
---|
[917] | 1060 | Table t = iter.table();
|
---|
| 1061 | MDirection::ROScalarColumn dirCol(t, "DIRECTION");
|
---|
[926] | 1062 | TableIterator fiter(t, "FREQ_ID");
|
---|
[917] | 1063 | // determine nchan from the first row. This should work as
|
---|
[926] | 1064 | // we are iterating over BEAMNO and IFNO // we should have constant direction
|
---|
| 1065 |
|
---|
[917] | 1066 | ROArrayColumn<Float> sCol(t, "SPECTRA");
|
---|
[926] | 1067 | MDirection direction = dirCol(0);
|
---|
[917] | 1068 | uInt nchan = sCol(0).nelements();
|
---|
[926] | 1069 | while ( !fiter.pastEnd() ) {
|
---|
| 1070 | Table ftab = fiter.table();
|
---|
| 1071 | ScalarColumn<uInt> freqidCol(ftab, "FREQ_ID");
|
---|
| 1072 | // get the SpectralCoordinate for the freqid, which we are iterating over
|
---|
| 1073 | SpectralCoordinate sC = in->frequencies().getSpectralCoordinate(freqidCol(0));
|
---|
| 1074 | FrequencyAligner<Float> fa( sC, nchan, refEpoch,
|
---|
| 1075 | direction, refPos, system );
|
---|
| 1076 | // realign the SpectralCoordinate and put into the output Scantable
|
---|
| 1077 | Vector<String> units(1);
|
---|
| 1078 | units = String("Hz");
|
---|
| 1079 | Bool linear=True;
|
---|
| 1080 | SpectralCoordinate sc2 = fa.alignedSpectralCoordinate(linear);
|
---|
| 1081 | sc2.setWorldAxisUnits(units);
|
---|
[934] | 1082 | uInt id = out->frequencies().addEntry(sc2.referencePixel()[0],
|
---|
| 1083 | sc2.referenceValue()[0],
|
---|
| 1084 | sc2.increment()[0]);
|
---|
| 1085 | TableVector<uInt> tvec(ftab, "FREQ_ID");
|
---|
| 1086 | tvec = id;
|
---|
[926] | 1087 | // create the "global" abcissa for alignment with same FREQ_ID
|
---|
| 1088 | Vector<Double> abc(nchan);
|
---|
[917] | 1089 | Double w;
|
---|
| 1090 | for (uInt i=0; i<nchan; i++) {
|
---|
| 1091 | sC.toWorld(w,Double(i));
|
---|
| 1092 | abc[i] = w;
|
---|
| 1093 | }
|
---|
[926] | 1094 | // cache abcissa for same time stamps, so iterate over those
|
---|
| 1095 | TableIterator timeiter(ftab, "TIME");
|
---|
| 1096 | while ( !timeiter.pastEnd() ) {
|
---|
| 1097 | Table tab = timeiter.table();
|
---|
| 1098 | ArrayColumn<Float> specCol(tab, "SPECTRA");
|
---|
| 1099 | ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
|
---|
| 1100 | MEpoch::ROScalarColumn timeCol(tab, "TIME");
|
---|
| 1101 | // use align abcissa cache after the first row
|
---|
| 1102 | bool first = true;
|
---|
| 1103 | // these rows should be just be POLNO
|
---|
[996] | 1104 | for (int i=0; i<int(tab.nrow()); ++i) {
|
---|
[926] | 1105 | // input values
|
---|
| 1106 | Vector<uChar> flag = flagCol(i);
|
---|
| 1107 | Vector<Bool> mask(flag.shape());
|
---|
| 1108 | Vector<Float> specOut, spec;
|
---|
| 1109 | spec = specCol(i);
|
---|
| 1110 | Vector<Bool> maskOut;Vector<uChar> flagOut;
|
---|
| 1111 | convertArray(mask, flag);
|
---|
| 1112 | // alignment
|
---|
| 1113 | Bool ok = fa.align(specOut, maskOut, abc, spec,
|
---|
| 1114 | mask, timeCol(i), !first,
|
---|
| 1115 | interp, False);
|
---|
| 1116 | // back into scantable
|
---|
| 1117 | flagOut.resize(maskOut.nelements());
|
---|
| 1118 | convertArray(flagOut, maskOut);
|
---|
| 1119 | flagCol.put(i, flagOut);
|
---|
| 1120 | specCol.put(i, specOut);
|
---|
| 1121 | // start abcissa caching
|
---|
| 1122 | first = false;
|
---|
[917] | 1123 | }
|
---|
[926] | 1124 | // next timestamp
|
---|
| 1125 | ++timeiter;
|
---|
[917] | 1126 | }
|
---|
[940] | 1127 | // next FREQ_ID
|
---|
[926] | 1128 | ++fiter;
|
---|
[917] | 1129 | }
|
---|
| 1130 | // next aligner
|
---|
| 1131 | ++iter;
|
---|
| 1132 | }
|
---|
[940] | 1133 | // set this afterwards to ensure we are doing insitu correctly.
|
---|
| 1134 | out->frequencies().setFrame(system, true);
|
---|
[917] | 1135 | return out;
|
---|
| 1136 | }
|
---|
[992] | 1137 |
|
---|
| 1138 | CountedPtr<Scantable>
|
---|
| 1139 | asap::STMath::convertPolarisation( const CountedPtr<Scantable>& in,
|
---|
| 1140 | const std::string & newtype )
|
---|
| 1141 | {
|
---|
| 1142 | if (in->npol() != 2 && in->npol() != 4)
|
---|
| 1143 | throw(AipsError("Can only convert two or four polarisations."));
|
---|
| 1144 | if ( in->getPolType() == newtype )
|
---|
| 1145 | throw(AipsError("No need to convert."));
|
---|
[1000] | 1146 | if ( ! in->selector_.empty() )
|
---|
| 1147 | throw(AipsError("Can only convert whole scantable. Unset the selection."));
|
---|
[992] | 1148 | bool insitu = insitu_;
|
---|
| 1149 | setInsitu(false);
|
---|
| 1150 | CountedPtr< Scantable > out = getScantable(in, true);
|
---|
| 1151 | setInsitu(insitu);
|
---|
| 1152 | Table& tout = out->table();
|
---|
| 1153 | tout.rwKeywordSet().define("POLTYPE", String(newtype));
|
---|
| 1154 |
|
---|
| 1155 | Block<String> cols(4);
|
---|
| 1156 | cols[0] = "SCANNO";
|
---|
| 1157 | cols[1] = "CYCLENO";
|
---|
| 1158 | cols[2] = "BEAMNO";
|
---|
| 1159 | cols[3] = "IFNO";
|
---|
| 1160 | TableIterator it(in->originalTable_, cols);
|
---|
| 1161 | String basetype = in->getPolType();
|
---|
| 1162 | STPol* stpol = STPol::getPolClass(in->factories_, basetype);
|
---|
| 1163 | try {
|
---|
| 1164 | while ( !it.pastEnd() ) {
|
---|
| 1165 | Table tab = it.table();
|
---|
| 1166 | uInt row = tab.rowNumbers()[0];
|
---|
| 1167 | stpol->setSpectra(in->getPolMatrix(row));
|
---|
| 1168 | Float fang,fhand,parang;
|
---|
| 1169 | fang = in->focusTable_.getTotalFeedAngle(in->mfocusidCol_(row));
|
---|
| 1170 | fhand = in->focusTable_.getFeedHand(in->mfocusidCol_(row));
|
---|
| 1171 | parang = in->paraCol_(row);
|
---|
| 1172 | /// @todo re-enable this
|
---|
| 1173 | // disable total feed angle to support paralactifying Caswell style
|
---|
| 1174 | stpol->setPhaseCorrections(parang, -parang, fhand);
|
---|
| 1175 | Int npolout = 0;
|
---|
| 1176 | for (uInt i=0; i<tab.nrow(); ++i) {
|
---|
| 1177 | Vector<Float> outvec = stpol->getSpectrum(i, newtype);
|
---|
| 1178 | if ( outvec.nelements() > 0 ) {
|
---|
| 1179 | tout.addRow();
|
---|
| 1180 | TableCopy::copyRows(tout, tab, tout.nrow()-1, 0, 1);
|
---|
| 1181 | ArrayColumn<Float> sCol(tout,"SPECTRA");
|
---|
| 1182 | ScalarColumn<uInt> pCol(tout,"POLNO");
|
---|
| 1183 | sCol.put(tout.nrow()-1 ,outvec);
|
---|
| 1184 | pCol.put(tout.nrow()-1 ,uInt(npolout));
|
---|
| 1185 | npolout++;
|
---|
| 1186 | }
|
---|
| 1187 | }
|
---|
| 1188 | tout.rwKeywordSet().define("nPol", npolout);
|
---|
| 1189 | ++it;
|
---|
| 1190 | }
|
---|
| 1191 | } catch (AipsError& e) {
|
---|
| 1192 | delete stpol;
|
---|
| 1193 | throw(e);
|
---|
| 1194 | }
|
---|
| 1195 | delete stpol;
|
---|
| 1196 | return out;
|
---|
| 1197 | }
|
---|