source: branches/casa-release-4_3-test02/src/STGrid.h@ 3128

Last change on this file since 3128 was 2851, checked in by Takeshi Nakazato, 11 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: test_sdgrid[sdgrid_flagging]

Put in Release Notes: No

Module(s): sd

Description: Describe your changes here...

Handle channel flags properly.


File size: 8.1 KB
Line 
1//
2// C++ Interface: STGrid
3//
4// Description:
5//
6//
7// Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2011
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef ASAPSTGRID_H
13#define ASAPSTGRID_H
14
15#include <iostream>
16#include <fstream>
17#include <string>
18#include <vector>
19
20#include <casa/BasicSL/String.h>
21#include <casa/Arrays/Array.h>
22#include <casa/Arrays/Vector.h>
23#include <casa/Containers/RecordField.h>
24#include <casa/Utilities/CountedPtr.h>
25
26#include <tables/Tables/Table.h>
27#include <tables/Tables/ScalarColumn.h>
28#include <tables/Tables/ArrayColumn.h>
29
30#include <coordinates/Coordinates/DirectionCoordinate.h>
31
32#include "ScantableWrapper.h"
33#include "Scantable.h"
34#include "concurrent.h"
35
36using namespace std ;
37using namespace casa ;
38
39namespace asap {
40class STGrid
41{
42public:
43 STGrid() ;
44 STGrid( const string infile ) ;
45 STGrid( const vector<string> infile ) ;
46 virtual ~STGrid() {} ;
47
48 void setFileIn( const string infile ) ;
49 void setFileList( const vector<string> infile ) ;
50
51 void setIF( unsigned int ifno ) { ifno_ = ifno ; } ;
52
53 void setPolList( vector<unsigned int> pols ) ;
54
55 void setScanList( vector<unsigned int> scans ) ;
56
57 void defineImage( int nx=-1,
58 int ny=-1,
59 string scellx="",
60 string scelly="",
61 string scenter="" ) ;
62 void setFunc( string convtype="box",
63 int convsupport=-1,
64 string truncate="",
65 string gwidth="",
66 string jwidth="" ) ;
67
68 void setWeight( const string wType="uniform" ) ;
69
70 void enableClip() { doclip_ = True ; } ;
71 void disableClip() { doclip_ = False ; } ;
72
73 void grid() ;
74
75 string saveData( string outfile="" ) ;
76
77 // support function to know how grid function looks like
78 vector<float> getConvFunc();
79
80 // for plotting
81 vector<int> getResultantMapSize();
82 vector<double> getResultantCellSize();
83
84//private:
85protected:
86 void init() ;
87
88 // actual gridding
89 void gridPerRow() ;
90 void gridPerRowWithClipping() ;
91
92 // clipping
93 void clipMinMax( Array<Complex> &data,
94 Array<Float> &weight,
95 Array<Int> &npoints,
96 Array<Complex> &clipmin,
97 Array<Float> &clipwmin,
98 Array<Float> &clipcmin,
99 Array<Complex> &clipmax,
100 Array<Float> &clipwmax,
101 Array<Float> &clipcmax ) ;
102
103
104 void setupGrid() ;
105 void setupGrid( Int &nx,
106 Int &ny,
107 String &cellx,
108 String &celly,
109 Double &xmin,
110 Double &xmax,
111 Double &ymin,
112 Double &ymax,
113 String &center ) ;
114 void mapExtent( Double &xmin, Double &xmax,
115 Double &ymin, Double &ymax ) ;
116
117 void setData( Array<Complex> &gdata,
118 Array<Float> &gwgt ) ;
119
120 Int getDataChunk( IPosition const &wshape,
121 IPosition const &vshape,
122 IPosition const &dshape,
123 Array<Complex> &spectra,
124 Array<Double> &direction,
125 Array<Int> &flagtra,
126 Array<Int> &rflag,
127 Array<Float> &weight ) ;
128 Int getDataChunk( Array<Complex> &spectra,
129 Array<Double> &direction,
130 Array<Int> &flagtra,
131 Array<Int> &rflag,
132 Array<Float> &weight ) ;
133 Int getDataChunk( Array<Float> &spectra,
134 Array<Double> &direction,
135 Array<uChar> &flagtra,
136 Array<uInt> &rflag,
137 Array<Float> &weight ) ;
138
139 void getWeight( Array<Float> &w,
140 Array<Float> &tsys,
141 Array<Double> &tint ) ;
142
143 void toInt( Array<uChar> &u, Array<Int> &v ) ;
144 void toInt( Array<uInt> &u, Array<Int> &v ) ;
145
146 void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
147
148 void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
149 void spheroidalFunc( Vector<Float> &convFunc ) ;
150 void gaussFunc( Vector<Float> &convFunc, Double hwhm, Double truncate ) ;
151 void gjincFunc( Vector<Float> &convFunc, Double hwhm, Double c, Double truncate );
152 void pbFunc( Vector<Float> &convFunc ) ;
153 void setConvFunc( Vector<Float> &convFunc ) ;
154
155 void prepareTable( Table &tab, String &name ) ;
156
157 void selectData() ;
158 void setupArray() ;
159
160 void updateChunkShape() ;
161 void attach( Table &tab ) ;
162
163 void call_ggridsd( Array<Double> &xy,
164 Array<Complex> &values,
165 Int &nvispol,
166 Int &nvischan,
167 Array<Int> &flag,
168 Array<Int> &rflag,
169 Array<Float> &weight,
170 Int &nrow,
171 Int &irow,
172 Array<Complex> &grid,
173 Array<Float> &wgrid,
174 Int &nx,
175 Int &ny,
176 Int &npol,
177 Int &nchan,
178 Int &support,
179 Int &sampling,
180 Vector<Float> &convFunc,
181 Int *chanMap,
182 Int *polMap ) ;
183 void call_ggridsd2( Array<Double> &xy,
184 Array<Complex> &values,
185 Int &nvispol,
186 Int &nvischan,
187 Array<Int> &flag,
188 Array<Int> &rflag,
189 Array<Float> &weight,
190 Int &nrow,
191 Int &irow,
192 Array<Complex> &grid,
193 Array<Float> &wgrid,
194 Array<Int> &npoints,
195 Array<Complex> &clipmin,
196 Array<Float> &clipwmin,
197 Array<Float> &clipcmin,
198 Array<Complex> &clipmax,
199 Array<Float> &clipwmax,
200 Array<Float> &clipcmax,
201 Int &nx,
202 Int &ny,
203 Int &npol,
204 Int &nchan,
205 Int &support,
206 Int &sampling,
207 Vector<Float> &convFunc,
208 Int *chanMap,
209 Int *polMap ) ;
210
211 void initPol( Int ipol ) ;
212 void initTable( uInt idx ) ;
213 Bool isMultiIF( Table &tab ) ;
214 void fillMainColumns( Table &tab ) ;
215 void fillTable( Table &tab ) ;
216 virtual void table( Table &tab, uInt i ) ;
217 static bool produceChunk(void *ctx) throw(concurrent::PCException);
218 static void consumeChunk(void *ctx) throw(concurrent::PCException);
219 static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException);
220
221
222 // user input
223 Int nxUI_ ;
224 Int nyUI_ ;
225 String cellxUI_ ;
226 String cellyUI_ ;
227 String centerUI_ ;
228
229 Block<String> infileList_ ;
230 uInt nfile_ ;
231 Int ifno_ ;
232 Bool doclip_ ;
233
234 Int nx_ ;
235 Int ny_ ;
236 Int npol_ ;
237 Int npolOrg_ ;
238 Int nchan_ ;
239 Double cellx_ ;
240 Double celly_ ;
241 Vector<Double> center_ ;
242 String convType_ ;
243 Int convSupport_ ;
244 Int userSupport_ ;
245 String gwidth_;
246 String jwidth_;
247 String truncate_;
248 Int convSampling_ ;
249 Vector<uInt> pollist_ ;
250 Vector<uInt> scanlist_ ;
251 String wtype_ ;
252 Block<Table> tableList_ ;
253 Vector<uInt> rows_ ;
254 Int nchunk_ ;
255 CountedPtr<DirectionCoordinate> dircoord_;
256
257 /////////////// gridPerRow variable
258 IPosition vshape_;
259 IPosition wshape_;
260 IPosition dshape_;
261 // loop variable
262 Int nrow_ ;
263 Array<Float> data_ ;
264 Array<uChar> flag_ ;
265
266 Table tab_ ;
267 // per pol
268 Table ptab_ ;
269 ROArrayColumn<Float> spectraCol_ ;
270 ROArrayColumn<uChar> flagtraCol_ ;
271 ROArrayColumn<Double> directionCol_ ;
272 ROScalarColumn<uInt> flagRowCol_ ;
273 ROArrayColumn<Float> tsysCol_ ;
274 ROScalarColumn<Double> intervalCol_ ;
275
276 Int nprocessed_ ;
277
278
279 double eGetData_;
280 double eToPixel_;
281 double eGGridSD_;
282};
283
284class STGrid2 : public STGrid
285{
286public:
287 STGrid2() ;
288 STGrid2( const ScantableWrapper &s ) ;
289 STGrid2( const vector<ScantableWrapper> &v ) ;
290 void setScantable( const ScantableWrapper &s ) ;
291 void setScantableList( const vector<ScantableWrapper> &v ) ;
292 void selectData() ;
293 virtual void table( Table &tab, uInt i ) ;
294 ScantableWrapper getResultAsScantable( int tp ) ;
295
296private:
297 Block<ScantableWrapper> dataList_ ;
298};
299}
300#endif
Note: See TracBrowser for help on using the repository browser.