source: trunk/src/STCalSkyOtfAlma.cpp@ 2757

Last change on this file since 2757 was 2757, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: Yes CAS-4770

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs:

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

First version of Calibrator class for OTF scan without OFF.


File size: 4.8 KB
Line 
1//
2// C++ Implementation: STCalSkyOtfAlma
3//
4// Description:
5//
6//
7// Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp> (C) 2012
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12
13#include <vector>
14#include "STSelector.h"
15#include "STCalSkyOtfAlma.h"
16#include "RowAccumulator.h"
17#include "STIdxIter.h"
18#include "STDefs.h"
19#include "EdgeMarker.h"
20
21#include <atnf/PKSIO/SrcType.h>
22
23using namespace std;
24using namespace casa;
25
26namespace asap {
27 STCalSkyOtfAlma::STCalSkyOtfAlma(CountedPtr<Scantable> &s, bool israster)
28 : STCalSkyPSAlma(s),
29 israster_(israster)
30{}
31
32void STCalSkyOtfAlma::setupSelector()
33{
34 sel_.reset();
35
36 // Detect edges using EdgeMarker
37 EdgeMarker marker(false); // generic (non-raster) scan pattern
38 marker.setdata(scantable_, True); // we can set insitu=True since we only need
39 // a list of rows to be marked. No marking is
40 // done here.
41 marker.setoption(options_);
42 marker.detect();
43 Block<uInt> rows = marker.getDetectedRows();
44 vector<int> vectorRows(rows.nelements());
45 for (size_t i = 0; i < vectorRows.size(); ++i)
46 vectorRows[i] = rows[i];
47
48 // Set list of row indices to selector
49 sel_.setRows(vectorRows);
50}
51
52// void STCalSkyOtfAlma::fillCalTable()
53// {
54// RowAccumulator acc(W_TINT);
55
56// vector<string> cols(3);
57// cols[0] = "IFNO";
58// cols[1] = "POLNO";
59// cols[2] = "BEAMNO";
60// STIdxIterAcc iter(scantable_, cols);
61
62// ROScalarColumn<Double> *tcol = new ROScalarColumn<Double>(scantable_->table(), "TIME");
63// Vector<Double> timeSec = tcol->getColumn() * 86400.0;
64// tcol->attach(scantable_->table(), "INTERVAL");
65// Vector<Double> intervalSec = tcol->getColumn();
66// delete tcol;
67// ROScalarColumn<Float> *ecol = new ROScalarColumn<Float>(scantable_->table(), "ELEVATION");
68// Vector<Float> elevation = ecol->getColumn();
69// delete ecol;
70
71// ROArrayColumn<Float> specCol(scantable_->table(), "SPECTRA");
72// ROArrayColumn<uChar> flagCol(scantable_->table(), "FLAGTRA");
73// ROScalarColumn<uInt> freqidCol(scantable_->table(), "FREQ_ID");
74
75// // dummy Tsys: the following process doesn't need Tsys but RowAccumulator
76// // requires to set it with spectral data
77// Vector<Float> tsys(1, 1.0);
78
79// Double timeCen = 0.0;
80// Float elCen = 0.0;
81// uInt count = 0;
82
83// while(!iter.pastEnd()) {
84// Vector<uInt> rows = iter.getRows(SHARE);
85// Vector<uInt> current = iter.current();
86// uInt len = rows.nelements();
87// if (len == 0) {
88// iter.next();
89// continue;
90// }
91// else if (len == 1) {
92// STCalSkyTable *p = dynamic_cast<STCalSkyTable *>(&(*applytable_));
93// uInt irow = rows[0];
94// p->appenddata(0, 0, current[2], current[0], current[1],
95// freqidCol(irow), timeSec[irow], elevation[irow], specCol(irow));
96// iter.next();
97// continue;
98// }
99
100// uInt nchan = scantable_->nchan(scantable_->getIF(rows[0]));
101// Vector<uChar> flag(nchan);
102// Vector<Bool> bflag(nchan);
103// Vector<Float> spec(nchan);
104
105// Vector<Double> timeSep(len);
106// for (uInt i = 0; i < len-1; i++) {
107// timeSep[i] = timeSec[rows[i+1]] - timeSec[rows[i]] ;
108// }
109// Double tMedian = median(timeSep(IPosition(1,0), IPosition(1,len-2)));
110// timeSep[len-1] = tMedian * 10000.0 ; // any large value
111
112// uInt irow ;
113// uInt jrow ;
114// for (uInt i = 0; i < len; i++) {
115// irow = rows[i];
116// jrow = (i < len-1) ? rows[i+1] : rows[i];
117// // accumulate data
118// flagCol.get(irow, flag);
119// convertArray(bflag, flag);
120// specCol.get(irow, spec);
121// if ( !allEQ(bflag,True) )
122// acc.add( spec, !bflag, tsys, intervalSec[irow], timeSec[irow] ) ;
123// timeCen += timeSec[irow];
124// elCen += elevation[irow];
125// count++;
126
127// // check time gap
128// double gap = 2.0 * timeSep[i] / (intervalSec[jrow] + intervalSec[irow]);
129// if ( gap > 1.1 ) {
130// if ( acc.state() ) {
131// acc.replaceNaN() ;
132// // const Vector<Bool> &msk = acc.getMask();
133// // convertArray(flag, !msk);
134// // for (uInt k = 0; k < nchan; ++k) {
135// // uChar userFlag = 1 << 7;
136// // if (msk[k]==True) userFlag = 0 << 7;
137// // flag(k) = userFlag;
138// // }
139// timeCen /= (Double)count * 86400.0; // sec->day
140// elCen /= (Float)count;
141// STCalSkyTable *p = dynamic_cast<STCalSkyTable *>(&(*applytable_));
142// p->appenddata(0, 0, current[2], current[0], current[1],
143// freqidCol(irow), timeCen, elCen, acc.getSpectrum());
144// }
145// acc.reset() ;
146// timeCen = 0.0;
147// elCen = 0.0;
148// count = 0;
149// }
150// }
151
152// iter.next() ;
153// }
154// }
155
156}
Note: See TracBrowser for help on using the repository browser.