source: trunk/src/STGrid.h@ 2683

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

New Development: No

JIRA Issue: Yes CAS-4429

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Implemented gauss and gjinc gridding. Added some arguments to
pass necessary parameters for those grid functions.

Also, defined helper function that plots current grid function
against radius in pixel.


File size: 8.0 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//private:
81protected:
82 void init() ;
83
84 // actual gridding
85 void gridPerRow() ;
86 void gridPerRowWithClipping() ;
87
88 // clipping
89 void clipMinMax( Array<Complex> &data,
90 Array<Float> &weight,
91 Array<Int> &npoints,
92 Array<Complex> &clipmin,
93 Array<Float> &clipwmin,
94 Array<Float> &clipcmin,
95 Array<Complex> &clipmax,
96 Array<Float> &clipwmax,
97 Array<Float> &clipcmax ) ;
98
99
100 void setupGrid() ;
101 void setupGrid( Int &nx,
102 Int &ny,
103 String &cellx,
104 String &celly,
105 Double &xmin,
106 Double &xmax,
107 Double &ymin,
108 Double &ymax,
109 String &center ) ;
110 void mapExtent( Double &xmin, Double &xmax,
111 Double &ymin, Double &ymax ) ;
112
113 void setData( Array<Complex> &gdata,
114 Array<Float> &gwgt ) ;
115
116 Int getDataChunk( IPosition const &wshape,
117 IPosition const &vshape,
118 IPosition const &dshape,
119 Array<Complex> &spectra,
120 Array<Double> &direction,
121 Array<Int> &flagtra,
122 Array<Int> &rflag,
123 Array<Float> &weight ) ;
124 Int getDataChunk( Array<Complex> &spectra,
125 Array<Double> &direction,
126 Array<Int> &flagtra,
127 Array<Int> &rflag,
128 Array<Float> &weight ) ;
129 Int getDataChunk( Array<Float> &spectra,
130 Array<Double> &direction,
131 Array<uChar> &flagtra,
132 Array<uInt> &rflag,
133 Array<Float> &weight ) ;
134
135 void getWeight( Array<Float> &w,
136 Array<Float> &tsys,
137 Array<Double> &tint ) ;
138
139 void toInt( Array<uChar> &u, Array<Int> &v ) ;
140 void toInt( Array<uInt> &u, Array<Int> &v ) ;
141
142 void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
143
144 void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
145 void spheroidalFunc( Vector<Float> &convFunc ) ;
146 void gaussFunc( Vector<Float> &convFunc, Double hwhm, Double truncate ) ;
147 void gjincFunc( Vector<Float> &convFunc, Double hwhm, Double c, Double truncate );
148 void pbFunc( Vector<Float> &convFunc ) ;
149 void setConvFunc( Vector<Float> &convFunc ) ;
150
151 void prepareTable( Table &tab, String &name ) ;
152
153 void selectData() ;
154 void setupArray() ;
155
156 void updateChunkShape() ;
157 void attach( Table &tab ) ;
158
159 void call_ggridsd( Array<Double> &xy,
160 Array<Complex> &values,
161 Int &nvispol,
162 Int &nvischan,
163 Array<Int> &flag,
164 Array<Int> &rflag,
165 Array<Float> &weight,
166 Int &nrow,
167 Int &irow,
168 Array<Complex> &grid,
169 Array<Float> &wgrid,
170 Int &nx,
171 Int &ny,
172 Int &npol,
173 Int &nchan,
174 Int &support,
175 Int &sampling,
176 Vector<Float> &convFunc,
177 Int *chanMap,
178 Int *polMap ) ;
179 void call_ggridsd2( Array<Double> &xy,
180 Array<Complex> &values,
181 Int &nvispol,
182 Int &nvischan,
183 Array<Int> &flag,
184 Array<Int> &rflag,
185 Array<Float> &weight,
186 Int &nrow,
187 Int &irow,
188 Array<Complex> &grid,
189 Array<Float> &wgrid,
190 Array<Int> &npoints,
191 Array<Complex> &clipmin,
192 Array<Float> &clipwmin,
193 Array<Float> &clipcmin,
194 Array<Complex> &clipmax,
195 Array<Float> &clipwmax,
196 Array<Float> &clipcmax,
197 Int &nx,
198 Int &ny,
199 Int &npol,
200 Int &nchan,
201 Int &support,
202 Int &sampling,
203 Vector<Float> &convFunc,
204 Int *chanMap,
205 Int *polMap ) ;
206
207 void initPol( Int ipol ) ;
208 void initTable( uInt idx ) ;
209 Bool isMultiIF( Table &tab ) ;
210 void fillMainColumns( Table &tab ) ;
211 void fillTable( Table &tab ) ;
212 virtual void table( Table &tab, uInt i ) ;
213 static bool produceChunk(void *ctx) throw(concurrent::PCException);
214 static void consumeChunk(void *ctx) throw(concurrent::PCException);
215 static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException);
216
217
218 // user input
219 Int nxUI_ ;
220 Int nyUI_ ;
221 String cellxUI_ ;
222 String cellyUI_ ;
223 String centerUI_ ;
224
225 Block<String> infileList_ ;
226 uInt nfile_ ;
227 Int ifno_ ;
228 Bool doclip_ ;
229
230 Int nx_ ;
231 Int ny_ ;
232 Int npol_ ;
233 Int npolOrg_ ;
234 Int nchan_ ;
235 Double cellx_ ;
236 Double celly_ ;
237 Vector<Double> center_ ;
238 String convType_ ;
239 Int convSupport_ ;
240 Int userSupport_ ;
241 String gwidth_;
242 String jwidth_;
243 String truncate_;
244 Int convSampling_ ;
245 Vector<uInt> pollist_ ;
246 Vector<uInt> scanlist_ ;
247 String wtype_ ;
248 Block<Table> tableList_ ;
249 Vector<uInt> rows_ ;
250 Int nchunk_ ;
251 CountedPtr<DirectionCoordinate> dircoord_;
252
253 /////////////// gridPerRow variable
254 IPosition vshape_;
255 IPosition wshape_;
256 IPosition dshape_;
257 // loop variable
258 Int nrow_ ;
259 Array<Float> data_ ;
260
261 Table tab_ ;
262 // per pol
263 Table ptab_ ;
264 ROArrayColumn<Float> spectraCol_ ;
265 ROArrayColumn<uChar> flagtraCol_ ;
266 ROArrayColumn<Double> directionCol_ ;
267 ROScalarColumn<uInt> flagRowCol_ ;
268 ROArrayColumn<Float> tsysCol_ ;
269 ROScalarColumn<Double> intervalCol_ ;
270
271 Int nprocessed_ ;
272
273
274 double eGetData_;
275 double eToPixel_;
276 double eGGridSD_;
277};
278
279class STGrid2 : public STGrid
280{
281public:
282 STGrid2() ;
283 STGrid2( const ScantableWrapper &s ) ;
284 STGrid2( const vector<ScantableWrapper> &v ) ;
285 void setScantable( const ScantableWrapper &s ) ;
286 void setScantableList( const vector<ScantableWrapper> &v ) ;
287 void selectData() ;
288 virtual void table( Table &tab, uInt i ) ;
289 ScantableWrapper getResultAsScantable( int tp ) ;
290
291private:
292 Block<ScantableWrapper> dataList_ ;
293};
294}
295#endif
Note: See TracBrowser for help on using the repository browser.